初级会员
- 积分
- 74
- 金钱
- 74
- 注册时间
- 2017-4-25
- 在线时间
- 13 小时
|
1金钱
问题描述:创建LISTBOX工具后,通过外部实体按键发送GUI_SendKeyMsg(GUI_KEY_DOWN, 1)或者GUI_SendKeyMsg(GUI_KEY_UP, 1)消息,
程序死机。
查看手册说,LISTBOX接收GUI_KEY_DOWN/GUI_KEY_UP,通过这来切换当前选中的哪个,
当我发送GUI_SendKeyMsg(GUI_KEY_DOWN, 1)或者GUI_SendKeyMsg(GUI_KEY_UP, 1)时候程序就进hartfault了
代码如下
[mw_shl_code=c,true]static const GUI_ConstString _ListBox[] = {
"aaa",
"bbb",
"ccc",
NULL
};
LISTBOX_Handle hListBox;
void _cbManualWindow(WM_MESSAGE* pMsg)
{
WM_HWIN hWin = pMsg->hWin;
uint8_t uiOffSet= 20;
GUI_RECT r={0,240,40,280};
WM_HWIN hItem;
switch (pMsg->MsgId) {
case WM_CREATE:
/* 设置聚焦 */
GUI_SetBkColor(GUI_BLACK);
GUI_SetFont(&GUI_FontFontSong24);
GUI_SetTextMode(GUI_TM_TRANS);
GUI_ClearRectEx(&r);
GUI_SetFont(&GUI_FontFontSong24);
GUI_SetTextMode(GUI_TM_TRANS);
hListBox = LISTBOX_CreateEx(0, 40, 120, 240, hWin,WM_CF_SHOW,0,0,_ListBox);
LISTBOX_SetFont(hListBox, &GUI_FontFontSong24);
// LISTBOX_SetBkColor(hListBox,LISTBOX_CI_UNSEL, GUI_BLACK);
// LISTBOX_SetBkColor(hListBox,LISTBOX_CI_SEL, GUI_DARKBLUE);
// LISTBOX_SetBkColor(hListBox,LISTBOX_CI_SELFOCUS,GUI_LIGHTBLUE);
// LISTBOX_SetBkColor(hListBox,LISTBOX_CI_DISABLED,GUI_GRAY);
////
// LISTBOX_SetTextColor(hListBox,LISTBOX_CI_UNSEL, GUI_WHITE);
// LISTBOX_SetTextColor(hListBox,LISTBOX_CI_SEL, GUI_WHITE);
// LISTBOX_SetTextColor(hListBox,LISTBOX_CI_SELFOCUS,GUI_WHITE);
// LISTBOX_SetTextColor(hListBox,LISTBOX_CI_DISABLED,GUI_GRAY);
//
// LISTBOX_SetItemSpacing(hListBox,10);
// LISTBOX_SetTextAlign(hListBox,GUI_TA_HCENTER|GUI_TA_VCENTER);
// SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL);
WM_SetFocus(hListBox);
break;
case WM_PAINT:
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) {
case GUI_KEY_UP:
// WM_SetFocus(hListBox);
// WM_SetFocusOnPrevChild(hWin);
WM_SetFocus(hListBox);
LISTBOX_InvalidateItem(hListBox, LISTBOX_ALL_ITEMS);
break;
case GUI_KEY_DOWN:
// WM_SetFocus(hListBox);
// WM_SetFocusOnNextChild(hWin);
WM_SetFocus(hListBox);
LISTBOX_InvalidateItem(hListBox, LISTBOX_ALL_ITEMS);
break;
default:break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
[/mw_shl_code]
|
|