xiang90721 发表于 2017-5-7 20:00:49

emWin multipage如何关闭?

主界面上有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;
}
}


wenyangzeng 发表于 2018-5-14 09:40:19

只要多建一个“返回键”控件就可以了。

wolfgang2015 发表于 2018-5-14 11:10:32

页面绘制和菜单控制的问题了,返回就要做上一级页面的重绘制。
内存有富余的就要开辟内存缓冲区,不富裕的就调用Flash上级页面;
另外有动态显示的内容,还得加动态数据窗口,显示返回值。
页: [1]
查看完整版本: emWin multipage如何关闭?