中级会员
- 积分
- 297
- 金钱
- 297
- 注册时间
- 2016-6-2
- 在线时间
- 49 小时
|
1金钱
下面为回调函数,动态创建的按钮,按下为啥没有事件产生?
static void _cbKeyPad(WM_MESSAGE * pMsg) {
static int LowerCase;
WM_HWIN hWin;
WM_HWIN hButton,hEdit;
char c;
int Id;
int NCode;
int xSize;
int ySize;
unsigned i;
unsigned char keystr[5];
int keystatus=0; //0- Upcaps; 1- LowCaps; 2 - Number;
hWin = pMsg->hWin;
switch (pMsg->MsgId) {
case APP_INIT_LOWERCASE:
LowerCase = 0;
break;
case WM_CREATE:
//
// Create the keyboard buttons
//
//hEdit = EDIT_CreateEx(6, 6, 180, 24, hWin, WM_CF_SHOW, 0, ID_EDIT_1,"");
hEdit = WM_GetDialogItem(hWin, ID_EDIT_1);
WM_SetFocus(hEdit);
keystatus = 0;
for (i = 0; i < GUI_COUNTOF(_aButtonData); i++) {
hButton = BUTTON_CreateEx(_aButtonData.xPos, _aButtonData.yPos+10, _aButtonData.xSize, _aButtonData.ySize,
hWin, WM_CF_SHOW | WM_CF_HASTRANS, 0, ID_BUTTON + i);
BUTTON_SetText(hButton, _aButtonData.acLabel1);
BUTTON_SetFocussable(hButton, 0);
}
break;
case WM_PAINT:
//
// Draw background
//
xSize = WM_GetWindowSizeX(hWin);
ySize = WM_GetWindowSizeY(hWin);
GUI_SetColor(COLOR_BORDER);
GUI_DrawRect(0, 0, xSize - 1, ySize - 1);
GUI_DrawGradientV(1, 1, xSize - 2, ySize - 2, COLOR_KEYPAD0, COLOR_KEYPAD1);
break;
case WM_NOTIFY_PARENT:
//
// Send key message to currently focused window
//
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (NCode) {
case WM_NOTIFICATION_RELEASED: //下面的代码无法调用。。。。因为没有事件
hButton = WM_GetDialogItem(hWin, Id);
BUTTON_GetText(hButton, keystr, 5);
if (strlen(keystr)>1)
{
if (!strcmp(keystr,"ABC")){
keystatus = 0;
update_key(hWin, keystatus);
}
if (!strcmp(keystr, "Num")){
keystatus = 2;
update_key(hWin, keystatus);
}
if (!strcmp(keystr, "Caps")){
if (keystatus==0)
{
keystatus = 1;
}
else
{
keystatus = 0;
}
update_key(hWin, keystatus);
}
if (!strcmp(keystr, "Esc")){
GUI_MEMDEV_ShiftOutWindow(hWin, 500, GUI_MEMDEV_EDGE_BOTTOM);
GUI_EndDialog(hWin, 0);
}
}
else
{
c = keystr[0];
if (c == 0x0d)
{
hEdit = WM_GetDialogItem(hWin, ID_EDIT_1);
EDIT_GetText(hEdit, returnstr, 30);
GUI_MEMDEV_ShiftOutWindow(hWin, 500, GUI_MEMDEV_EDGE_BOTTOM);
GUI_EndDialog(hWin, 0);
}
GUI_StoreKeyMsg(c, 1);
GUI_StoreKeyMsg(c, 0);
}
}
break;
}
}
|
|