目前沒有讀過ucgui的源代碼,經過應用代碼測試出在FRAMEWIN的控件焦點順序是樣的: html
按資源列表裏建立的控件,默認將焦點落在第一個可接收焦點的控件,目前知道不可接收 測試
焦點的控件有TEXT,在FRAMEWIN上安排有如下的控件: ui
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { spa
{ FRAMEWIN_CreateIndirect, NULL, 0, 0, 0, 128, 64, 0,0}, 3d
{ TEXT_CreateIndirect, NULL, GUI_ID_TEXT0, 25, 0, 50, 13, 0,0}, htm
{ MULTIEDIT_CreateIndirect, NULL, GUI_ID_MULTIEDIT0, 65, 0, 42, 13, 0,0}, blog
{ CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK0, 4, 4, 51, 0, 0, 0 }, 資源
{ TEXT_CreateIndirect, NULL, GUI_ID_TEXT1, 25, 15, 50, 13, 0,0}, get
{ MULTIEDIT_CreateIndirect, NULL, GUI_ID_MULTIEDIT1, 65, 15, 42, 13, 0,0}, it
{ TEXT_CreateIndirect, NULL, GUI_ID_TEXT2, 0, 30, 64, 13, 0,0},
{ MULTIEDIT_CreateIndirect, NULL, GUI_ID_MULTIEDIT2, 65, 30, 42, 13, 0,0},
};
從列表中看出默認的窗口焦點是CHECKBOX控件,若是將CHECKBOX0 刪除,那麼默認的焦點是MULTIEIDT0
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, NULL, 0, 0, 0, 128, 64, 0,0},
{ TEXT_CreateIndirect, NULL, GUI_ID_TEXT0, 25, 0, 50, 13, 0,0},
{ MULTIEDIT_CreateIndirect, NULL, GUI_ID_MULTIEDIT0, 65, 0, 42, 13, 0,0},
{ TEXT_CreateIndirect, NULL, GUI_ID_TEXT1, 25, 15, 50, 13, 0,0},
{ MULTIEDIT_CreateIndirect, NULL, GUI_ID_MULTIEDIT1, 65, 15, 42, 13, 0,0},
{ TEXT_CreateIndirect, NULL, GUI_ID_TEXT2, 0, 30, 64, 13, 0,0},
{ MULTIEDIT_CreateIndirect, NULL, GUI_ID_MULTIEDIT2, 65, 30, 42, 13, 0,0},
};
那麼問題就來了,若是焦點在MULTIEIDT控件上,想以ESC作爲本窗口的銷燬退出處理,發如今FRAMEWIN的回調裏沒法收到ESC鍵擡起的消息,即:
case WM_KEY:
switch (((WM_KEY_INFO *)(pMsg->Data.p))->Key){
case GUI_KEY_ESCAPE:
if(((WM_KEY_INFO *)(pMsg->Data.p))->PressedCnt == 0) //起鍵判斷
窗口銷燬操做;
在MultiEdit裏當按下ESC鍵時有按下((WM_KEY_INFO *)(pMsg->Data.p))->PressedCnt == 1,可是沒有擡起:((WM_KEY_INFO *)(pMsg->Data.p))->PressedCnt == 0,若是一按鍵觸發退出會致使連級退出,參考文章:
http://www.cnblogs.com/worldsing/p/4165919.html
因此代碼沒法運行到窗口銷燬的部分,我嘗試將焦點落在其餘控件上能夠銷燬窗口,初步懷疑MULTIEDIT把起鍵消息過濾了,若是窗口上只有MULTIEDIT控件該如何實現這樣的功能?
處理辦法是收到ESC鍵按下的消息是,觸發定時器在指定的時間內退出並銷燬窗口:
case WM_KEY:
switch (((WM_KEY_INFO *)(pMsg->Data.p))->Key){
case GUI_KEY_ESCAPE:
WM_CreateTimer(WM_GetClientWindow(hWin), 0, 100, 0);
break;
}
break;
case WM_TIMER:
WIN_Exit(0);
break;