硬汉嵌入式论坛

 找回密码
 立即注册
查看: 4427|回复: 22
收起左侧

[emWin] 请教emwin中二维码显示的问题

[复制链接]

9

主题

39

回帖

66

积分

初级会员

只要努力,没有什么办不到

积分
66
发表于 2019-9-18 18:35:29 | 显示全部楼层 |阅读模式
如题,在使用emwin5.40中的二维码显示,碰到个问题,就是屏幕更新,偶尔会将二维码刷掉一部分,导致显示不完整,目前这块只能自已维护,在可能会刷掉二维码的时候,手动调用GUI_QR_Draw重新绘制二维码,         感觉这样不是很方便,我想请问下大家,二维码能不能像其它控件设置回调函数来管理,通过无效化来重绘么?

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107643
QQ
发表于 2019-9-18 18:44:31 | 显示全部楼层
直接放在一个窗口的WM_PAINT消息里面绘制即可。
回复

使用道具 举报

9

主题

39

回帖

66

积分

初级会员

只要努力,没有什么办不到

积分
66
 楼主| 发表于 2019-9-18 23:19:07 | 显示全部楼层
eric2013 发表于 2019-9-18 18:44
直接放在一个窗口的WM_PAINT消息里面绘制即可。

多谢硬汉回复,我可能没描述清楚,我的意思是我的二维码已经放在windows窗口上,windows窗口放了一整张图片,上面有ICON、文本、二维码等控件,平时ICON和文本更新没有用窗口回调的WM_PAINT更新,都是通过修改属性后emwin自已管理更新的,现在新加的二维码,好像是属于2D绘图,必须要用户自已更新,或者通过回调的WM_PAINT消息来更新,但是查了下emwin手册,二维码控件不能单独设置回调,请问是放到windows窗口的回调函数WM_PAINT消息来更新吗?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107643
QQ
发表于 2019-9-19 00:53:43 | 显示全部楼层
billy226 发表于 2019-9-18 23:19
多谢硬汉回复,我可能没描述清楚,我的意思是我的二维码已经放在windows窗口上,windows窗口放了一整张图 ...

方便的话,贴下下代码看下
回复

使用道具 举报

9

主题

39

回帖

66

积分

初级会员

只要努力,没有什么办不到

积分
66
 楼主| 发表于 2019-9-19 09:32:25 | 显示全部楼层
eric2013 发表于 2019-9-19 00:53
方便的话,贴下下代码看下

1、首先在emwin启动时创建了二维码并显示,这个时候显示二维码是正常的
02a.png 05.png

2、然后在window窗口回调中WM_PAINT中重绘,但是发现这样在更新屏幕其它内容时偶尔会刷掉二维码,重绘也不能让二维码显示正常,一直像下图这样,好像重绘不起作用,见下图
01.png 04.png

3、最后在可能会刷掉二维的地方,改成如下方式自已维护调用,二维码就不会被刷掉
03.png

问题:这样需要自已维护,有点不方便,还是想通过回调的方式让emwin自已管理,请问为什么我在windows窗口回调在处理,还是会被刷掉?


回复

使用道具 举报

9

主题

140

回帖

187

积分

初级会员

积分
187
QQ
发表于 2019-9-19 11:29:12 | 显示全部楼层
billy226 发表于 2019-9-19 09:32
1、首先在emwin启动时创建了二维码并显示,这个时候显示二维码是正常的

用一个TEXT或IMG控件,自定义它的回调函数,在它的回调PAINT里面画二维就好,
回复

使用道具 举报

12

主题

104

回帖

140

积分

初级会员

积分
140
发表于 2019-9-19 16:28:30 | 显示全部楼层
用个wm_createwinaschild()做个透明的窗口自动管理会不会更好呢。而且这个是无边框透明的。。
回复

使用道具 举报

9

主题

39

回帖

66

积分

初级会员

只要努力,没有什么办不到

积分
66
 楼主| 发表于 2019-9-19 18:04:31 | 显示全部楼层
allyzc 发表于 2019-9-19 11:29
用一个TEXT或IMG控件,自定义它的回调函数,在它的回调PAINT里面画二维就好,

谢谢兄台,我来试试看
回复

使用道具 举报

9

主题

39

回帖

66

积分

初级会员

只要努力,没有什么办不到

积分
66
 楼主| 发表于 2019-9-19 18:10:27 | 显示全部楼层
cz123123 发表于 2019-9-19 16:28
用个wm_createwinaschild()做个透明的窗口自动管理会不会更好呢。而且这个是无边框透明的。。

你说的是用这个函数WM_CreateWindowAsChild创建子窗口吧,然后在子窗口回调函数里更新二维码?这个子窗口是emwin自动管理么?还是需要发通知它才会更新,我想要的效果是像TEXT一样,让emwin自已维护更新
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107643
QQ
发表于 2019-9-20 14:20:12 | 显示全部楼层
billy226 发表于 2019-9-19 09:32
1、首先在emwin启动时创建了二维码并显示,这个时候显示二维码是正常的

不能正常重绘,说明你的程序有其它问题。
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-17 10:54:08 | 显示全部楼层
谢谢分享,学习一下,我最近也遇到这方面的问题了
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-18 13:09:19 | 显示全部楼层
大侠,我比较郁闷的问题是:在vs2019上仿真正常,移植到stm32上就死机。主机面上点击一个按钮,切换到子界面上显示二维码。
QR1.jpg
QR1-1.jpg
QR1-2.jpg
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-18 13:13:09 | 显示全部楼层
stm32F407zgt6不知道是为什么,一点击主界面的按钮就死机

FramewinMainDLG.c

7.11 KB, 下载次数: 0

maintask.c

1019 Bytes, 下载次数: 0

WindowBkgdDLG.c

4.88 KB, 下载次数: 0

回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-18 13:16:13 | 显示全部楼层
#include "dialog.h"
WM_HWIN hPage[3] = {0, 0, 0};
void MainTask(void)
{
  GUI_Init();

  //CreateFramewinMain();   //test
  CreateWindowBkgd();
  //CreateFramewinMain();

//  if(!hPage[0])
//          hPage[0] = CreateWindowBkgd(WM_HBKWIN);        //Determine whether the handle is 0 before creating the window,clear when deleted
//  if(!hPage[1])
//          hPage[1] = CreateFramewinMain(hPage[0]);



  //WM_AttachWindow(hPage[1], hPage[0]);              //make hPage[1] as hPage[0]'s child window


//  if(!hPage[2])
//          hPage[2] = CreateFramewinSub(hPage[1]);
  //WM_AttachWindow(hPage[2], hPage[1]);              //make hPage[2] as hPage[1]'s child window
// WM_MoveChildTo(hPage[2], 5, 156);
  //WM_SetFocus(hPage[1]);                            //emwin will look for and focuses on the first widget in the hPage[1] window
  //WM_SetFocus(hPage[0]);
  
  
  while(1)
  {
          GUI_Delay(20);
  }//Call GUI_Delay() function delay 20ms,The ultimate goal is to call the GUI_Exec() function
}




/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.30                          *
*        Compiled Jul  1 2015, 10:50:32                              *
*        (c) 2015 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"
#include "stdio.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_WINDOW_0     (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x02)


// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { WINDOW_CreateIndirect, "WindowBkgd", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "QRcode", ID_BUTTON_0, 115, 170, 80, 30, 0, 0x0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

// USER START (Optionally insert additional static code)
// USER END

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  // USER START (Optionally insert additional variables)
  // USER END

  int     NCode;
  int     Id;

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'WindowBkgd'
    //
    hItem = pMsg->hWin;
    WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00FFFF00));
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  // USER START (Optionally insert additional message handling)
  // USER END

  case WM_NOTIFY_PARENT:
      Id = WM_GetId(pMsg->hWinSrc);
      NCode = pMsg->Data.v;
      switch (Id) {
      case ID_BUTTON_0: // Notifications sent by 'Button'
          switch (NCode) {
          case WM_NOTIFICATION_CLICKED:
              // USER START (Optionally insert code for reacting on notification message)
              // USER END
              break;
          case WM_NOTIFICATION_RELEASED:
              // USER START (Optionally insert code for reacting on notification message)
              GUI_EndDialog(pMsg->hWin, 0);          //2020-9-18 结束本对话框
              CreateFramewinMain(WM_HBKWIN);          //2020-9-18
            // USER END
              break;
              // USER START (Optionally insert additional code for further notification handling)
              // USER END
          }
          break;
          // USER START (Optionally insert additional code for further Ids)
          // USER END
      }
      break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateWindowBkgd
*/
WM_HWIN CreateWindowBkgd(void);
WM_HWIN CreateWindowBkgd(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  return hWin;
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/





/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.30                          *
*        Compiled Jul  1 2015, 10:50:32                              *
*        (c) 2015 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
//#define ID_TEXT_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_0 (GUI_ID_USER + 0x02)


// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { FRAMEWIN_CreateIndirect, "FramewinMain", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x0, 0 },
  //{ TEXT_CreateIndirect, "Text", ID_TEXT_0, 2, 0, 300, 16, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Return", ID_BUTTON_0, 115, 170, 80, 30, 0, 0x0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

/*
// USER START (Optionally insert additional static code)
static void GUI_renew_gui_memory(WM_HWIN hParent, int textID)
{
  char buff[48];
  sprintf(buff, "Memory used: %dKBytes  free: %dKBytes", GUI_ALLOC_GetNumUsedBytes()/1024, GUI_ALLOC_GetNumFreeBytes()/1024);
  //TEXT_SetTextColor(WM_GetDialogItem(hParent, textID), (0x008000FF));
  TEXT_SetText(WM_GetDialogItem(hParent, textID), buff);
}*/
// USER END

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  static GUI_HMEM hMem[3] = {0, 0, 0};
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'FramewinMain'
    //
    //hItem = pMsg->hWin;
    //FRAMEWIN_SetTitleHeight(hItem, 16);
    //
    // Initialization of 'Text'
    //
   // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    //TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
    // USER START (Optionally insert additional code for further widget initialization)
   // FRAMEWIN_SetMoveable(pMsg->hWin, 1);
   // FRAMEWIN_SetTitleHeight(pMsg->hWin, 16);
   // FRAMEWIN_AddCloseButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);
   // FRAMEWIN_AddMaxButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);
   // FRAMEWIN_AddMinButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);

    //不能重复创建,否则内存越占越多(比如不能放在WM_PAINT消息中)
    if(!hMem[0]) hMem[0] = GUI_QR_Create("http://www.neqee.com/", 4, GUI_QR_ECLEVEL_L, 0);   //(1):屏蔽此段而保留下面的 WM_PAINT:下的显示函数,二维码显示不成功;得出必须同时保留这两部分才能显示,
    if(!hMem[1]) hMem[1] = GUI_QR_Create("http://www.baidu.com/", 3, GUI_QR_ECLEVEL_L, 0);
    if(!hMem[2]) hMem[2] = GUI_QR_Create("http://www.segger.com/", 2, GUI_QR_ECLEVEL_L, 0);

    //GUI_renew_gui_memory(pMsg->hWin, ID_TEXT_0);//Update memory usage. Note: It also needs to be executed where memory changes.
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
          GUI_EndDialog(pMsg->hWin, 0);          //2020-9-18 结束本对话框
          CreateWindowBkgd(WM_HBKWIN);           //2020-9-18
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  //窗口重绘消息,这个比较难说明白,反正在Framewin或Window窗口之中我们一般是用控件,如果要在Framewin或Window窗口之中显示文字或绘制直线、矩形、圆等在这里实现.
  //Window redraw message, this is difficult to explain,anyway,we usually use widget in framewin or windows,If we want to draw lines,rectangles,circles,etc. in framewin or windows,we can do it here.
  
    case WM_PAINT:                                         //2020-11-17 (2):屏蔽此段保留上面的创建,就不显示二维码了
    GUI_SetColor(GUI_BLUE);
    GUI_DispStringAt("http://www.neqee.com/", 2, 18);
    GUI_QR_Draw(hMem[0], 10, 30);

    GUI_SetColor(GUI_GREEN);
    GUI_DispStringAt("http://www.baidu.com/", 170, 18);
    GUI_QR_Draw(hMem[1], 190, 30);

    GUI_SetColor(GUI_RED);
    GUI_DispStringAt("http://www.segger.com/", 170, 135);
    GUI_QR_Draw(hMem[2], 210, 148);
    break;  
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateFramewinMain
*/
WM_HWIN CreateFramewinMain(void);
WM_HWIN CreateFramewinMain(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  return hWin;
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/
回复

使用道具 举报

20

主题

397

回帖

457

积分

高级会员

积分
457
发表于 2020-11-18 14:16:09 | 显示全部楼层
这位兄弟,是否能标个箭头之类的提示一下在哪个地方可能有问题?要不然看的很晕呀
回复

使用道具 举报

20

主题

397

回帖

457

积分

高级会员

积分
457
发表于 2020-11-18 15:33:50 | 显示全部楼层
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107643
QQ
发表于 2020-11-19 08:21:19 | 显示全部楼层
jinniuxing 发表于 2020-11-18 13:13
stm32F407zgt6不知道是为什么,一点击主界面的按钮就死机

二维码显示占用的是emWin的动态内存,你的GUIConf.c中分配的动态内存一定要够大才行。

方便起见,你可以仅显示一个非常小的二维码,看看动态内存还够不
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-19 20:28:33 | 显示全部楼层
h_007 发表于 2020-11-18 14:16
这位兄弟,是否能标个箭头之类的提示一下在哪个地方可能有问题?要不然看的很晕呀

哦,谢谢回复,参考硬汉大神的 V2版emwin 第65章内容修改:1.不在初始化消息下创建和绘制,2.在按钮释放消息下创建并绘制QRCode,3.同时在WM_PAINT消息下绘制,这样就成功显示了二维码
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-19 20:34:46 | 显示全部楼层
eric2013 发表于 2020-11-19 08:21
二维码显示占用的是emWin的动态内存,你的GUIConf.c中分配的动态内存一定要够大才行。

方便起见,你可 ...

谢谢,硬汉大神回复啊,参考你写的 V6 emwin 第65章,在按钮释放消息下,创建与绘制,现在已经成功显示了二维码。只不过,第一次点了主界面上的QRCode按钮,进入子界面并不显示,按下子界面的Return按钮回到主界面;然后再点击主界面的QRCode按钮,才能显示,不知道是何故?可能是我对消息机制理解不到位,
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-19 20:53:27 | 显示全部楼层
图片发不上来了
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-19 21:09:00 | 显示全部楼层
  1. /*********************************************************************
  2. *                                                                    *
  3. *                SEGGER Microcontroller GmbH & Co. KG                *
  4. *        Solutions for real time microcontroller applications        *
  5. *                                                                    *
  6. **********************************************************************
  7. *                                                                    *
  8. * C-file generated by:                                               *
  9. *                                                                    *
  10. *        GUI_Builder for emWin version 5.30                          *
  11. *        Compiled Jul  1 2015, 10:50:32                              *
  12. *        (c) 2015 Segger Microcontroller GmbH & Co. KG               *
  13. *                                                                    *
  14. **********************************************************************
  15. *                                                                    *
  16. *        Internet: www.segger.com  Support: support@segger.com       *
  17. *                                                                    *
  18. **********************************************************************
  19. */

  20. // USER START (Optionally insert additional includes)
  21. // USER END

  22. #include "DIALOG.h"

  23. /*********************************************************************
  24. *
  25. *       Defines
  26. *
  27. **********************************************************************
  28. */
  29. #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
  30. //#define ID_TEXT_0 (GUI_ID_USER + 0x01)
  31. #define ID_BUTTON_0 (GUI_ID_USER + 0x02)


  32. // USER START (Optionally insert additional defines)
  33. // USER END

  34. /*********************************************************************
  35. *
  36. *       Static data
  37. *
  38. **********************************************************************
  39. */

  40. // USER START (Optionally insert additional static data)
  41. // USER END

  42. /*********************************************************************
  43. *
  44. *       _aDialogCreate
  45. */
  46. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  47.   { FRAMEWIN_CreateIndirect, "FramewinMain", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x0, 0 },
  48.   //{ TEXT_CreateIndirect, "Text", ID_TEXT_0, 2, 0, 300, 16, 0, 0x0, 0 },
  49.   { BUTTON_CreateIndirect, "Return", ID_BUTTON_0, 115, 170, 80, 30, 0, 0x0, 0 },
  50.   // USER START (Optionally insert additional widgets)
  51.   // USER END
  52. };

  53. /*********************************************************************
  54. *
  55. *       Static code
  56. *
  57. **********************************************************************
  58. */

  59. /*
  60. // USER START (Optionally insert additional static code)
  61. static void GUI_renew_gui_memory(WM_HWIN hParent, int textID)
  62. {
  63.   char buff[48];
  64.   sprintf(buff, "Memory used: %dKBytes  free: %dKBytes", GUI_ALLOC_GetNumUsedBytes()/1024, GUI_ALLOC_GetNumFreeBytes()/1024);
  65.   //TEXT_SetTextColor(WM_GetDialogItem(hParent, textID), (0x008000FF));
  66.   TEXT_SetText(WM_GetDialogItem(hParent, textID), buff);
  67. }*/
  68. // USER END

  69. /*********************************************************************
  70. *
  71. *       _cbDialog
  72. */
  73. static void _cbDialog(WM_MESSAGE * pMsg) {
  74.   WM_HWIN hItem, hWinOld;
  75.   int     NCode;
  76.   int     Id;
  77.   // USER START (Optionally insert additional variables)
  78.   static GUI_HMEM hMem[3] = {0, 0, 0};
  79.   // USER END

  80.   switch (pMsg->MsgId) {
  81.   case WM_INIT_DIALOG:
  82.     //
  83.     // Initialization of 'FramewinMain'
  84.     //
  85.     //hItem = pMsg->hWin;
  86.     //FRAMEWIN_SetTitleHeight(hItem, 16);
  87.     //
  88.     // Initialization of 'Text'
  89.     //
  90.    // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
  91.     //TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
  92.     // USER START (Optionally insert additional code for further widget initialization)
  93.    // FRAMEWIN_SetMoveable(pMsg->hWin, 1);
  94.    // FRAMEWIN_SetTitleHeight(pMsg->hWin, 16);
  95.    // FRAMEWIN_AddCloseButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);
  96.    // FRAMEWIN_AddMaxButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);
  97.    // FRAMEWIN_AddMinButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0);

  98.     //不能重复创建,否则内存越占越多(比如不能放在WM_PAINT消息中)
  99. //    if(!hMem[0]) hMem[0] = GUI_QR_Create("http://www.neqee.com/", 4, GUI_QR_ECLEVEL_L, 0);   //(1):屏蔽此段而保留下面的 WM_PAINT:下的显示函数,二维码显示不成功;得出必须同时保留这两部分才能显示,
  100. //    if(!hMem[1]) hMem[1] = GUI_QR_Create("http://www.baidu.com/", 3, GUI_QR_ECLEVEL_L, 0);
  101. //    if(!hMem[2]) hMem[2] = GUI_QR_Create("http://www.segger.com/", 2, GUI_QR_ECLEVEL_L, 0);

  102.     //GUI_renew_gui_memory(pMsg->hWin, ID_TEXT_0);//Update memory usage. Note: It also needs to be executed where memory changes.
  103.     // USER END
  104.     break;
  105.   case WM_NOTIFY_PARENT:
  106.     Id    = WM_GetId(pMsg->hWinSrc);
  107.     NCode = pMsg->Data.v;
  108.     switch(Id) {
  109.     case ID_BUTTON_0: // Notifications sent by 'Return'
  110.       switch(NCode) {
  111.       case WM_NOTIFICATION_CLICKED:
  112.         // USER START (Optionally insert code for reacting on notification message)
  113.         // USER END
  114.         break;
  115.       case WM_NOTIFICATION_RELEASED:
  116.         // USER START (Optionally insert code for reacting on notification message)
  117.           //GUI_EndDialog(pMsg->hWin, 0);          //2020-9-18 结束本对话框
  118.           //CreateWindowBkgd(WM_HBKWIN);           //2020-9-18
  119.            
  120.               //hWinOld = WM_SelectWindow(WM_GetClientWindow(pMsg->hWin));
  121.               hMem[0] = GUI_QR_Create("http://www.baidu.com/", 4, GUI_QR_ECLEVEL_L, 0);  
  122.               GUI_QR_Draw(hMem[0], 10, 30);
  123.               //WM_SelectWindow(hWinOld);
  124.           
  125.                     GUI_EndDialog(pMsg->hWin, 0);          //2020-9-18 结束本对话框
  126.                CreateFramewin();  
  127.           // USER END
  128.         break;
  129.       // USER START (Optionally insert additional code for further notification handling)
  130.       // USER END
  131.       }
  132.       break;
  133.     // USER START (Optionally insert additional code for further Ids)
  134.     // USER END
  135.     }
  136.     break;
  137.   // USER START (Optionally insert additional message handling)
  138.   //窗口重绘消息,这个比较难说明白,反正在Framewin或Window窗口之中我们一般是用控件,如果要在Framewin或Window窗口之中显示文字或绘制直线、矩形、圆等在这里实现.
  139.   //Window redraw message, this is difficult to explain,anyway,we usually use widget in framewin or windows,If we want to draw lines,rectangles,circles,etc. in framewin or windows,we can do it here.
  140.   
  141.     case WM_PAINT:                                         //2020-11-17 (2):屏蔽此段保留上面的创建,就不显示二维码了
  142.     GUI_SetColor(GUI_BLUE);
  143.     GUI_DispStringAt("http://www.baidu.com/", 2, 18);
  144.     GUI_QR_Draw(hMem[0], 10, 30);

  145. //    GUI_SetColor(GUI_GREEN);
  146. //    GUI_DispStringAt("http://www.baidu.com/", 170, 18);
  147. //    GUI_QR_Draw(hMem[1], 190, 30);

  148. //    GUI_SetColor(GUI_RED);
  149. //    GUI_DispStringAt("http://www.segger.com/", 170, 135);
  150. //    GUI_QR_Draw(hMem[2], 210, 148);
  151.     break;  
  152.   // USER END
  153.   default:
  154.     WM_DefaultProc(pMsg);
  155.     break;
  156.   }
  157. }

  158. /*********************************************************************
  159. *
  160. *       Public code
  161. *
  162. **********************************************************************
  163. */
  164. /*********************************************************************
  165. *
  166. *       CreateFramewinMain
  167. */
  168. WM_HWIN CreateFramewinQRCode(void);
  169. WM_HWIN CreateFramewinQRCode(void) {
  170.   WM_HWIN hWin;

  171.   hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  172.   return hWin;
  173. }

  174. // USER START (Optionally insert additional public code)
  175. // USER END

  176. /*************************** End of file ****************************/
复制代码
回复

使用道具 举报

0

主题

22

回帖

22

积分

新手上路

积分
22
发表于 2020-11-20 09:49:06 | 显示全部楼层
这些是现象
微信图片_20201120094420.jpg
微信图片_20201120094511.jpg
微信图片_20201120094516.jpg
微信图片_20201120094524.jpg
微信图片_20201120094539.jpg
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107643
QQ
发表于 2020-11-20 10:05:23 | 显示全部楼层
jinniuxing 发表于 2020-11-19 20:34
谢谢,硬汉大神回复啊,参考你写的 V6 emwin 第65章,在按钮释放消息下,创建与绘制,现在已经成功显示了 ...

不可以直接在按钮消息里面绘制,即调用GUI_QR_Draw

这个需要你调用WM_SelectWindow
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-6-10 01:48 , Processed in 0.243520 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表