|

楼主 |
发表于 2018-3-27 16:39:22
|
显示全部楼层
我在模拟器上测试单独对话框的时候是可以的,但是加上其他的就不行了(主界面有一个按钮调出该对话框,关闭按钮关闭该对话框,结果关于Framewin的设置就失效了),我把代码贴给你运行下看看- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.40 *
- * Compiled Jun 22 2017, 10:13:26 *
- * (c) 2017 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_BUTTON_0 (GUI_ID_USER + 0x01)
- #define ID_BUTTON_1 (GUI_ID_USER + 0x02)
- #define ID_BUTTON_2 (GUI_ID_USER + 0x03)
- #define ID_BUTTON_3 (GUI_ID_USER + 0x04)
- #define ID_BUTTON_4 (GUI_ID_USER + 0x05)
- // 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, "Framewin", ID_FRAMEWIN_0, 8, 8, 800, 480, 0, 0x64, 0 },
- { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 35, 49, 80, 20, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 157, 53, 80, 20, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "Button", ID_BUTTON_2, 40, 113, 80, 20, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "Button", ID_BUTTON_3, 162, 115, 80, 20, 0, 0x0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- *
- *********************************************************************/
- static int _DrawSkinFlex_FRAME(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
- {
- GUI_SetColor(0XFFB3B3);
- switch (pDrawItemInfo->Cmd)
- {
- case WIDGET_ITEM_DRAW_BACKGROUND:
- break;
-
- case WIDGET_ITEM_DRAW_FRAME:
- GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1-1,
- pDrawItemInfo->y1-1, 0);
- break;
-
- default:
- return FRAMEWIN_DrawSkinFlex(pDrawItemInfo);
- }
- return 0;
- }
- /*********************************************************************
- *
- *
- *********************************************************************/
- static void _Framewin(WM_MESSAGE * pMsg)
- {
- WM_HWIN hWin = pMsg->hWin;
- switch (pMsg->MsgId) {
- case WM_NOTIFY_PARENT:
- if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) {
- int Id = WM_GetId(pMsg->hWinSrc);
- if (Id == GUI_ID_CLOSE) {
- GUI_EndDialog(hWin,0);
- hWin = 0;
-
- }
- }
- break;
- }
- }
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- WM_HWIN hWin = pMsg->hWin;
- int NCode;
- int Id;
- WM_SetCallback(WM_GetParent(hWin),_Framewin);
- // USER START (Optionally insert additional variables)
- // USER END
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Framewin'
- //
- hItem = pMsg->hWin;
- FRAMEWIN_SetText(hItem, "set");
- FRAMEWIN_SetFont(hItem, GUI_FONT_20B_ASCII);
- FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
- FRAMEWIN_SetSkin(hWin, _DrawSkinFlex_FRAME );
- // 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_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)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- case ID_BUTTON_1: // 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)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- case ID_BUTTON_2: // 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)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- case ID_BUTTON_3: // 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)
- // 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;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateFramewin
- */
- static void _cbMain(WM_MESSAGE * pMsg) {
- WM_HWIN hButton;
- int NCode, Id;
- WM_HWIN hWin = pMsg->hWin;
- switch(pMsg->MsgId)
- {
- case WM_PAINT: /*立即绘制或重绘一个窗口*/
- {
- GUI_SetBkColor(0XFFFFFF);
- GUI_Clear();
- }
- break;
- case WM_CREATE: //ID_BUTTON_4
- {
- hButton = BUTTON_CreateEx(80, 30, 120, 145,
- hWin, WM_CF_SHOW, 0, ID_BUTTON_4); //ID_BUTTON_MAIN_SET
- BUTTON_SetFont(hButton, GUI_FONT_20B_ASCII);
- BUTTON_SetText(hButton, "Osci");
- }
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id)
- {
- case ID_BUTTON_4:
- {
- WM_HWIN hSetHwin;
- hSetHwin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- GUI_ExecCreatedDialog(hSetHwin);
- }
- break;
- }
- break;
- }
- }
- // USER START (Optionally insert additional public code)
- // USER END
- void MainTask(void)
- {
- WM_HWIN hWin;
- GUI_Init();
- hWin = WM_CreateWindow(0,0,800,480, WM_CF_SHOW,_cbMain,0);
- while(1)
- {
- GUI_Delay(1000);
- }
- }
- /*************************** End of file ****************************/
复制代码 |
|