|
发表于 2015-4-20 22:20:57
|
显示全部楼层
看来你真的是使用局部变量使用习惯了,能不能把变量i也设置成全局变量。修改后就没有问题了,完整代码如下,在模拟器上面可以正常运行:
- /*********************************************************************
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- **********************************************************************
- * *
- * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- ** emWin V5.28 - Graphical user interface for embedded applications **
- emWin is protected by international copyright laws. Knowledge of the
- source code may not be used to write a similar product. This file may
- only be used in accordance with a license and should not be re-
- distributed in any way. We appreciate your understanding and fairness.
- ----------------------------------------------------------------------
- File : GUIDEMO_Start.c
- Purpose : GUIDEMO initialization
- ----------------------------------------------------------------------
- */
- #include "GUI.h"
- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.22 *
- * Compiled Jul 4 2013, 15:16:01 *
- * (c) 2013 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_WINDOW_0 (GUI_ID_USER + 0x00)
- #define ID_BUTTON_0 (GUI_ID_USER + 0x01)
- #define ID_EDIT_0 (GUI_ID_USER + 0x02)
- #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x03)
- #define ID_BUTTON_1 (GUI_ID_USER + 0x04)
- // 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, "Window", ID_WINDOW_0, 24, 0, 271, 479, 0, 0x0, 0 },
- { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 83, 87, 80, 20, 0, 0x64, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = {
- { FRAMEWIN_CreateIndirect, "408", ID_FRAMEWIN_0, 50, 150, 100, 100, 0, 0x64, 0 },
- { BUTTON_CreateIndirect, "1", ID_BUTTON_1, 10, 10, 43, 20, 0, 0x0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- WM_HWIN hWin2;
- static unsigned char i = 0;
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
-
- int NCode;
- int Id;
-
- // USER START (Optionally insert additional variables)
- // USER END
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Edit'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
- EDIT_SetDecMode(hItem,600,0,10000,0,0);
- // WIDGET_SetEffect(hItem, DEFAULT_WIDGET_EFFECT);
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id) {
- case ID_EDIT_0: // Notifications sent by 'Edit'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- i=!i;
- if(i)
- {
- hWin2 = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), NULL,0, 0, 0);
- }
- else
- GUI_EndDialog(hWin2, 0);
- // EDIT_SetValue(WM_GetDialogItem(pMsg->hWin, ID_EDIT_0), 23);
- // 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_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;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateWindow
- */
- WM_HWIN CreateWindow(void);
- WM_HWIN CreateWindow(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
- void MainTask(void)
- {
- GUI_Init();
- CreateWindow();
- while(1)
- {
- GUI_Delay(20);
- }
- }
- /*************************** End of file ****************************/
复制代码 |
|