OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 4212|回复: 2

emWin multipage如何关闭?

[复制链接]

15

主题

49

帖子

0

精华

初级会员

Rank: 2

积分
94
金钱
94
注册时间
2014-10-22
在线时间
24 小时
发表于 2017-5-7 19:15:00 | 显示全部楼层 |阅读模式
10金钱
主界面上有icon,点击icon后建立一个frame,然后这个frame上有两个控件,一个 ok button和一个multipage,multipage中有三个页面,问题是如何关闭frame回到主界面?
原本想按ok button关闭frame回到主界面?但在vs仿真执行就出现dereference free block in GUI_ALLC_h2p()错误,求解?
贴出回调函数代码,大家帮忙看看,谢谢:
这个是multipage的第一个页面的回调函数,这个页面就是一个button,想按这个button销毁frame回到主界面上,但是不行
static void _cbDialog_Page1(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  WM_HWIN hItem2;
  int     NCode;
  int     Id;
  WM_MESSAGE msg;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON0);
    BUTTON_SetSkin(hItem, _DrawSkin_Button);

    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case GUI_ID_BUTTON0: // Notifications sent by 'Checkbox'
      switch(pMsg->Data.v) {
      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)
        // USER END
        #if 0
                hItem = WM_GetParent(pMsg->hWin);
        hItem2 = WM_GetParent(hItem );
        hItem = MULTIPAGE_GetWindow(hItem2,0);
        WM_DeleteWindow(hItem);
        hItem = MULTIPAGE_GetWindow(hItem2,1);
        WM_DeleteWindow(hItem);
        hItem = MULTIPAGE_GetWindow(hItem2,2);
        WM_DeleteWindow(hItem);
        GUI_EndDialog(hItem2, 0);
        #endif
        hItem = (WM_GetParent(WM_GetParent(pMsg->hWin)));
        hItem2 = WM_GetParent(hItem );
        WM_DeleteWindow(hItem);
        //GUI_EndDialog(hItem2, 0);
        msg.MsgId = WM_DELETE;
        WM_SendMessage(hItem2,&msg);
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // 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)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}


这个是frame的回调函数,frame中有个button,想按这个button销毁frame回到主界面也是不行。求解啊
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  WM_HWIN hItem2;
  WM_HWIN hDialog;
  WM_MESSAGE msg;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Multipage'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0);

    hDialog = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), _cbDialog_Page1,       WM_UNATTACHED, 0, 0);
    //WM_SetCallback(hDialog, _cbDialog_Page1);
    MULTIPAGE_AddPage(hItem, hDialog, "setup1");
    GUI_Delay(500);
    hDialog = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), NULL,       WM_UNATTACHED, 0, 0);
    MULTIPAGE_AddPage(hItem, hDialog, "setup2");
    GUI_Delay(500);
    hDialog = GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), NULL,       WM_UNATTACHED, 0, 0);
    MULTIPAGE_AddPage(hItem, hDialog, "about");
    GUI_Delay(500);
    //
    // Initialization of 'OK'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetFont(hItem, GUI_FONT_16_ASCII);
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_MULTIPAGE_0: // Notifications sent by 'Multipage'
      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)
        // USER END
        break;
      case WM_NOTIFICATION_MOVED_OUT:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_0: // Notifications sent by 'OK'
      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)
        // USER END
        //hItem2 = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0);

        //hItem = MULTIPAGE_GetWindow(hItem2,0);
        //WM_DeleteWindow(hItem);
        //hItem = MULTIPAGE_GetWindow(hItem2,1);
        //WM_DeleteWindow(hItem);
        //hItem = MULTIPAGE_GetWindow(hItem2,2);
        //WM_DeleteWindow(hItem);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE_0);
        WM_DeleteWindow(hItem);
        hItem = WM_GetParent(pMsg->hWin);
        WM_DeleteWindow(hItem, 0);       
        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
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}


最佳答案

查看完整内容[请看2#楼]

[mw_shl_code=c,true]case WM_NOTIFICATION_RELEASED:[mw_shl_code=c,true] case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetParent(pMsg->hWin); //页面窗口句柄 hItem = WM_GetParent(hItem); //客户端窗口句柄 hItem = WM_GetParent(hItem); //multipage窗口句柄 hItem = WM_GetParent(hItem); //框架窗口句柄 ...
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

0

主题

1

帖子

0

精华

新手上路

积分
22
金钱
22
注册时间
2017-5-31
在线时间
1 小时
发表于 2017-5-7 19:15:01 | 显示全部楼层
[mw_shl_code=c,true]case WM_NOTIFICATION_RELEASED:[mw_shl_code=c,true]
case WM_NOTIFICATION_RELEASED:
                                // USER START (Optionally insert code for reacting on notification message)                               
                                hItem = WM_GetParent(pMsg->hWin); //页面窗口句柄
                                hItem =  WM_GetParent(hItem); //客户端窗口句柄
                                hItem =  WM_GetParent(hItem); //multipage窗口句柄
                                hItem =  WM_GetParent(hItem); //框架窗口句柄
                                GUI_EndDialog(hItem,0);
                                // USER END
                                break;[/mw_shl_code]

注意multipage的窗口结构,准确找到父窗口,才能关闭。。
QQ截图20170531160541.jpg
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165309
金钱
165309
注册时间
2010-12-1
在线时间
2108 小时
发表于 2017-5-8 01:29:13 | 显示全部楼层
帮顶
回复

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-11-23 08:23

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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