|
发表于 2018-11-30 11:24:55
|
显示全部楼层
eric2013您好:
我使用code:Blocks模擬,寫一個簡單的WM_SetUserData()和WM_GetUserData(),創建窗口後呼叫WM_SetUserData()把值傳入,按下button後用WM_GetUserData()讀出資料。但只要按A、C兩鍵程式就會當掉,按B卻不會 。感謝你。- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.32 *
- * Compiled Oct 8 2015, 11:59:02 *
- * (c) 2015 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_BUTTON_1 (GUI_ID_USER + 0x02)
- #define ID_BUTTON_2 (GUI_ID_USER + 0x03)
- // 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, 0, 0, 480, 272, 0, 0x0, 12 },
- { BUTTON_CreateIndirect, "B", ID_BUTTON_0, 145, 183, 80, 60, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "A", ID_BUTTON_1, 26, 187, 80, 56, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "C", ID_BUTTON_2, 292, 190, 80, 46, 0, 0x0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem,hWin_temp[3];
- int NCode;
- int Id;
- // USER START (Optionally insert additional variables)
- // USER END
- hItem = pMsg->hWin;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Window'
- //
- hItem = pMsg->hWin;
- WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x0000FFFF));
- // 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 'B'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- WM_GetUserData(hItem,hWin_temp,12);
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- case ID_BUTTON_1: // Notifications sent by 'A'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- WM_GetUserData(hItem,hWin_temp,12);
- // 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 'C'
- switch(NCode) {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- WM_GetUserData(hItem,hWin_temp,12);
- // 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_temp[3];
- hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- hWin_temp[0] =11;
- hWin_temp[1] =88;
- hWin_temp[2] =99;
- WM_SetUserData(hWin,hWin_temp,12);
- return hWin;
- }
- // USER START (Optionally insert additional public code)
- // USER END
- /*************************** End of file ****************************/
- void MainTask(void) {
- WM_HWIN Whin;
- GUI_Init();
- CreateWindow();
- while (1) {
- //WM_ForEachDesc(WM_HBKWIN, _cbDoSomething, (void *)&Value);
- //Value *= -1;
- GUI_Delay(1);
- }
- }
复制代码 |
|