初级会员
- 积分
- 94
- 金钱
- 94
- 注册时间
- 2014-10-22
- 在线时间
- 24 小时
|
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); //框架窗口句柄
...
|