完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
ucgui3.98移植完成之后,编写了一个实例如下,但是发现按按键没有反应,调试的时候发现 Id = WM_Getid(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(NCode) NCode 这个地方一直是WM_NOTIFICATION_CLICKED而不是WM_NOTIFICATION_RELEASED。所以导致按键均无效。不知论坛有没有朋友遇到过这样的情况。或者一起来探讨一下原因?触摸问题或者uCGUI移植问题? #include "GUI.h" #include "DIALOG.h" #include "WM.h" #include "BUTTON.h" #include "CHECKBOX.h" #include "DROPDOWN.h" #include "EDIT.h" #include "FRAMEWIN.h" #include "LISTBOX.h" #include "MULTIEDIT.h" #include "RADIO.h" #include "SLIDER.h" #include "TEXT.h" #include "PROGBAR.h" #include "SCROLLBAR.h" #include "LISTVIEW.h" #include "MULTIPAGE.h" #include "GRAPH.h" #include "MainPanel.h" #if 0 WM_HWIN PanelhWin; extern void TouchCalibrate(void); static const GUI_WIDGET_CREATE_INFO _PANEL_TABLE[] = { { FRAMEWIN_CreateIndirect, "Test System", 0, 0, 0, 800,480,FRAMEWIN_CF_ACTIVE,0}, //FRAMEWIN_CF_MOVEABLE FRAMEWIN_CF_ACTIVE, { BUTTON_CreateIndirect, "NowTest", GUI_ID_BUTTON0, 200-65,200,100,100, 0,0},//实时测试 50,200,100,100, 0,0 { BUTTON_CreateIndirect, "DataLog", GUI_ID_BUTTON1, 350-65,200,100,100, 0,0},//出场调试 { BUTTON_CreateIndirect, "SystSet", GUI_ID_BUTTON2, 500-65,200,100,100, 0,0},//登陆 { BUTTON_CreateIndirect, "SelMode", GUI_ID_BUTTON3, 650-65,200,100,100, 0,0},//型号选择 { TEXT_CreateIndirect, "", GUI_ID_TEXT0, 520,440,260,30, 0,0}, //A387_VERSION }; static u8 InitDialogPanel(WM_MESSAGE * pMsg) { u8 i; WM_HWIN hWin = pMsg->hWin; //------------------------------------------------------------------------------------- //对话框控件初始化 //FRAMEWIN_SetTitleVis(hWin,0); //标题隐藏 FRAMEWIN_SetFont(hWin,&GUI_Font16B_ASCII); FRAMEWIN_SetClientColor(hWin,GUI_BLACK);//设置背景色 GUI_BLACK FRAMEWIN_SetBorderSize(hWin,0);//设置边框尺寸 FRAMEWIN_SetTextAlign(hWin,GUI_TA_VCENTER|GUI_TA_CENTER);//设置标题对其方式 //--------------------------------------------------------------------------------------------------------------------------- //复选框控件初始化 for(i=0; i<4; i++) { BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON0+i),&GUI_Font16B_ASCII); BUTTON_SetBkColor(WM_GetDialogItem(hWin,GUI_ID_BUTTON0+i),BUTTON_CI_UNPRESSED,GUI_LIGHTYELLOW); BUTTON_SetFocussable(WM_GetDialogItem(hWin,GUI_ID_BUTTON0+i), 0); } TEXT_SetTextColor(WM_GetDialogItem(hWin,GUI_ID_TEXT0), GUI_WHITE); TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT0), &GUI_Font16B_ASCII); TEXT_SetTextAlign(WM_GetDialogItem(hWin,GUI_ID_TEXT0),GUI_TA_TOP|GUI_TA_CENTER); return 1; } static void _cbCallbackPanel(WM_MESSAGE * pMsg) { int NCode, Id; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: break; case WM_INIT_DIALOG: InitDialogPanel(pMsg); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hWin, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(NCode) { case WM_NOTIFICATION_RELEASED: if(Id == GUI_ID_BUTTON0) { GUI_MessageBox("This is Check1", "My Check",GUI_MESSAGEBOX_CF_MOVEABLE); GUI_EndDialog(hWin, 0); } else if(Id == GUI_ID_BUTTON1) { GUI_MessageBox("This is Check2", "My Check",GUI_MESSAGEBOX_CF_MOVEABLE); GUI_EndDialog(hWin, 0); } else if(Id == GUI_ID_BUTTON2) { GUI_MessageBox("This is Check3", "My Check",GUI_MESSAGEBOX_CF_MOVEABLE); GUI_EndDialog(hWin, 0); } else { if(Id == GUI_ID_BUTTON3) { GUI_EndDialog(hWin, 0); } } case WM_NOTIFICATION_SEL_CHANGED: break; } break; default: WM_DefaultProc(pMsg); } } /************************************************************************************** 名 称:MainDialogBox() 功 能:建立对话框 输入参数:无 返回参数:0 备 注: ***************************************************************************************/ void PanelDialogBox(void) { PanelhWin = GUI_CreateDialogBox(_PANEL_TABLE, GUI_COUNTOF(_PANEL_TABLE), &_cbCallbackPanel, 0, 0, 0);//创建一个非阻塞式对话框 } #endif /********************************************************************* * * Dialog resource keyboard * * This table conatins the info required to create the dialog. * It has been created by ucGUIbuilder. */ #define GUI_ID_BUTTON10 0x810 #define GUI_ID_BUTTON11 0x811 static const GUI_WIDGET_CREATE_INFO _aDialogCreate_kb[] = { { FRAMEWIN_CreateIndirect, "Set", 0, 0, 0, 240,320,0,0}, { BUTTON_CreateIndirect, "0", GUI_ID_BUTTON0, 96, 240,40, 40, 0,0}, { BUTTON_CreateIndirect, "1", GUI_ID_BUTTON1, 32, 102,40, 40, 0,0}, { BUTTON_CreateIndirect, "2", GUI_ID_BUTTON2, 96, 102,40, 40, 0,0}, { BUTTON_CreateIndirect, "3", GUI_ID_BUTTON3, 157,102,40, 40, 0,0}, { BUTTON_CreateIndirect, "4", GUI_ID_BUTTON4, 32, 148,40, 40, 0,0}, { BUTTON_CreateIndirect, "5", GUI_ID_BUTTON5, 96, 148,40, 40, 0,0}, { BUTTON_CreateIndirect, "6", GUI_ID_BUTTON6, 157,148,40, 40, 0,0}, { BUTTON_CreateIndirect, "7", GUI_ID_BUTTON7, 32, 194,40, 40, 0,0}, { BUTTON_CreateIndirect, "8", GUI_ID_BUTTON8, 96, 194,40, 40, 0,0}, { BUTTON_CreateIndirect, "9", GUI_ID_BUTTON9, 157,194,40, 40, 0,0}, { BUTTON_CreateIndirect, "OK", GUI_ID_OK, 32, 240,40, 40, 0,0}, { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 157,240,40, 40, 0,0}, { EDIT_CreateIndirect, "", GUI_ID_EDIT0, 17, 31, 193,32, 0,0}, { BUTTON_CreateIndirect, "'", GUI_ID_BUTTON10, 96, 70, 40, 26, 0,0}, { BUTTON_CreateIndirect, "Delete", GUI_ID_BUTTON11, 157,71, 40, 25, 0,0} }; /***************************************************************** ** FunctionName:void PaintDialog(WM_MESSAGE * pMsg) ** Function: to initialize the Dialog items ** ** call this function in _cbCallback --> WM_PAINT *****************************************************************/ void PaintDialog_kb(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; } /***************************************************************** ** FunctionName:void InitDialog(WM_MESSAGE * pMsg) ** Function: to initialize the Dialog items ** ** call this function in _cbCallback --> WM_INIT_DIALOG *****************************************************************/ void InitDialog_kb(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; // //FRAMWIN // FRAMEWIN_SetTitleHeight(hWin,16); FRAMEWIN_SetFont(hWin,&GUI_Font16B_ASCII); // //GUI_ID_BUTTON0 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON0),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON1 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON1),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON2 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON2),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON3 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON3),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON4 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON4),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON5 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON5),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON6 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON6),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON7 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON7),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON8 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON8),&GUI_Font24B_ASCII); // //GUI_ID_BUTTON9 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON9),&GUI_Font24B_ASCII); // //GUI_ID_EDIT0 // EDIT_SetFont(WM_GetDialogItem(hWin,GUI_ID_EDIT0),&GUI_Font24_ASCII); // EDIT_SetValue(WM_GetDialogItem(hWin,GUI_ID_EDIT0),0); EDIT_SetMaxLen(WM_GetDialogItem(hWin,GUI_ID_EDIT0),9); // EDIT_SetDecMode(WM_GetDialogItem(hWin,GUI_ID_EDIT0),0,0,999.9999,4,0); // //GUI_ID_BUTTON12 // BUTTON_SetFont(WM_GetDialogItem(hWin,GUI_ID_BUTTON10),&GUI_Font24B_ASCII); } /********************************************************************* * * Dialog callback routine */ static void _cbCallback_kb(WM_MESSAGE * pMsg) { int NCode, Id; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: PaintDialog_kb(pMsg); break; case WM_INIT_DIALOG: InitDialog_kb(pMsg); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hWin, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(NCode) { case WM_NOTIFICATION_RELEASED: switch (Id) { case GUI_ID_OK: EDIT_AddKey(WM_GetDialogItem(hWin,GUI_ID_EDIT0),' |