|
外接实体按键,触发创建一个新的对话框,但新建对话框范围以外的屏也刷新了,导致之前的内容无序了。调试时发现回调函数里在对话框建立完成后一直触发WM_GET_ID事件,导致范围外的不良刷新。代码如下:
[s:138]
新人什么都没有,无以回报[s:129]
/*********************************************************************
* *
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
* *
**********************************************************************
* *
* C-file generated by: *
* *
* GUI_Builder for emWin version 5.22 *
* Compiled Jul 4 2013, 15:16:01 *
* (c) 2013 Segger Microcontroller GmbH & Co. KG *
* *
**********************************************************************
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
*/
// USER START (Optionally insert additional includes)
// USER END
#include "DIALOG.h"
#include "WindowDlg.h"
/*********************************************************************
*
* Debug data
*
**********************************************************************
*/
// USER START (Optionally insert additional data declaration)
int logFlag = 0;
int _logBuff[100] = {0};
int _logIndex = 0;
// USER END
TagPosition _aPosition = { 0 };
WM_HWIN CreateChildWindow(void);
/*********************************************************************
*
* 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, 800, 480, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_0, 0, 0, 800, 40, 0, 0x64, 0 },
{ LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_0, 0, 40, 800, 320, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* _aChildDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aChildDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_1, 240, 100, 320, 240, 0, 0x0, 0 },
{ LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_1, 0, 0, 320, 240, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* _aTable1
*/
GUI_ConstString _aTable1[16][8] = {
{ "1-01", "1-02", "1-03", "1-04", "1-05", "1-06", "1-07", "1-08" },
{ "1-09", "1-10", "1-11", "1-12", "1-13", "1-14", "1-15", "1-16" },
{ "1-17", "1-18", "1-19", "1-20", "1-21", "1-22", "1-23", "1-24" },
{ "1-25", "1-26", "1-27", "1-28", "1-29", "1-30", "1-31", "1-32" },
{ "2-01", "2-02", "2-03", "2-04", "2-05", "2-06", "2-07", "2-08" },
{ "2-09", "2-10", "2-11", "2-12", "2-13", "2-14", "2-15", "2-16" },
{ "2-17", "2-18", "2-19", "2-20", "2-21", "2-22", "2-23", "2-24" },
{ "2-25", "2-26", "2-27", "2-28", "2-29", "2-30", "2-31", "2-32" },
{ "3-01", "3-02", "3-03", "3-04", "3-05", "3-06", "3-07", "3-08" },
{ "3-09", "3-10", "3-11", "3-12", "3-13", "3-14", "3-15", "3-16" },
{ "3-17", "3-18", "3-19", "3-20", "3-21", "3-22", "3-23", "3-24" },
{ "3-25", "3-26", "3-27", "3-28", "3-29", "3-30", "3-31", "3-32" },
{ "4-01", "4-02", "4-03", "4-04", "4-05", "4-06", "4-07", "4-08" },
{ "4-09", "4-10", "4-11", "4-12", "4-13", "4-14", "4-15", "4-16" },
{ "4-17", "4-18", "4-19", "4-20", "4-21", "4-22", "4-23", "4-24" },
{ "4-25", "4-26", "4-27", "4-28", "4-29", "4-30", "4-31", "4-32" },
};
/*********************************************************************
*
* _aTable2
*/
GUI_ConstString _aTable2[][8] = {
{ "2-01", "2-02", "2-03", "2-04", "2-05", "2-06", "2-07", "2-08" },
{ "2-09", "2-10", "2-11", "2-12", "2-13", "2-14", "2-15", "2-16" },
{ "2-17", "2-18", "2-19", "2-20", "2-21", "2-22", "2-23", "2-24" },
{ "2-25", "2-26", "2-27", "2-28", "2-29", "2-30", "2-31", "2-32" },
};
/*********************************************************************
*
* _aTable3
*/
GUI_ConstString _aTable3[][8] = {
{ "3-01", "3-02", "3-03", "3-04", "3-05", "3-06", "3-07", "3-08" },
{ "3-09", "3-10", "3-11", "3-12", "3-13", "3-14", "3-15", "3-16" },
{ "3-17", "3-18", "3-19", "3-20", "3-21", "3-22", "3-23", "3-24" },
{ "3-25", "3-26", "3-27", "3-28", "3-29", "3-30", "3-31", "3-32" },
};
/*********************************************************************
*
* _aTable4
*/
GUI_ConstString _aTable4[][8] = {
{ "4-01", "4-02", "4-03", "4-04", "4-05", "4-06", "4-07", "4-08" },
{ "4-09", "4-10", "4-11", "4-12", "4-13", "4-14", "4-15", "4-16" },
{ "4-17", "4-18", "4-19", "4-20", "4-21", "4-22", "4-23", "4-24" },
{ "4-25", "4-26", "4-27", "4-28", "4-29", "4-30", "4-31", "4-32" },
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbChildDialog
*/
static void _cbChildDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
WM_HWIN hDlg;
int NCode;
int Id;
//GUI_RECT *Rect;
// USER START (Optionally insert additional variables)
// USER END
hDlg = pMsg->hWin;
//if(logFlag)_logBuff[_logIndex++] = pMsg->MsgId;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Listview'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
LISTVIEW_AddColumn(hItem, 50, "Name", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 50, "Value", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetGridVis(hItem, 1);
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
case WM_NOTIFY_PARENT:
hItem = WM_GetFocussedWindow();
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (Id) {
case ID_LISTVIEW_0: // Notifications sent by 'Listview'
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_SEL_CHANGED:
// 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;
case WM_KEY:
//hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
GUI_EndDialog(hDlg,0);
WM_SetFocus(WM_GetDialogItem(WM_HBKWIN,ID_LISTVIEW_0));
break;
// USER START (Optionally insert additional message handling)
// USER END
case WM_GET_ID:
//pMsg->Data.v = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
int i,j;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Window'
//
hItem = pMsg->hWin;
WINDOW_SetBkColor(hItem, 0x00FFFFFF);
//
// Initialization of 'Text'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
TEXT_SetTextColor(hItem, 0x00000000);
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
TEXT_SetFont(hItem, GUI_FONT_32B_ASCII);
TEXT_SetText(hItem, "Building Fir Door Monitor&Control System");
//
// Initialization of 'Listview'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_GREEN);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 100, " ", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_SetGridVis(hItem, 1);
LISTVIEW_SetHeaderHeight(hItem, 0);
LISTVIEW_SetRowHeight(hItem, 80);
LISTVIEW_SetFont(hItem, GUI_FONT_32B_1);
for (i = 0; i < 4; i++){
LISTVIEW_AddRow(hItem, _aTable1);
//GUI_Delay(1);
}
// 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_LISTVIEW_0: // Notifications sent by 'Listview'
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_SEL_CHANGED:
// 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
case WM_KEY:
// Id = WM_GetId(pMsg->hWinSrc);
// switch(Id){
// case ID_LISTVIEW_0:
hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key){
case GUI_KEY_F3:
if ((_aPosition.x - 1) < 0)_aPosition.x = 15;
else _aPosition.x--;
if (_aPosition.x/4 != _aPosition.page){
_aPosition.page = _aPosition.x / 4;
for (i = 0; i < 4;i++){
for (j = 0; j < 8; j++){
LISTVIEW_SetItemText(hItem, j, i, _aTable1[(_aPosition.page*4) + i][j]);
}
}
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, 0, LISTVIEW_CI_UNSEL, GUI_BLACK);
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, 3, LISTVIEW_CI_UNSEL, GUI_WHITE);
}
else{
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, (_aPosition.x-_aPosition.page*4)+1, LISTVIEW_CI_UNSEL, GUI_BLACK);
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, (_aPosition.x-_aPosition.page*4), LISTVIEW_CI_UNSEL, GUI_WHITE);
}
break;
case GUI_KEY_F4:
if ((_aPosition.x + 1) > 15)_aPosition.x = 0;
else _aPosition.x++;
if (_aPosition.x / 4 != _aPosition.page){
_aPosition.page = _aPosition.x / 4;
for (i = 0; i < 4; i++){
for (j = 0; j < 8; j++){
LISTVIEW_SetItemText(hItem, j, i, _aTable1[(_aPosition.page*4) + i][j]);
}
}
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, 3, LISTVIEW_CI_UNSEL, GUI_BLACK);
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, 0, LISTVIEW_CI_UNSEL, GUI_WHITE);
}
else{
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, (_aPosition.x-_aPosition.page*4) - 1, LISTVIEW_CI_UNSEL, GUI_BLACK);
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, (_aPosition.x-_aPosition.page*4), LISTVIEW_CI_UNSEL, GUI_WHITE);
}
break;
case GUI_KEY_F1:
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, _aPosition.x, LISTVIEW_CI_UNSEL, GUI_BLACK);
if ((_aPosition.y - 1) <0)_aPosition.y = 7;
else _aPosition.y--;
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, _aPosition.x, LISTVIEW_CI_UNSEL, GUI_WHITE);
break;
case GUI_KEY_F2:
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, _aPosition.x, LISTVIEW_CI_UNSEL, GUI_BLACK);
if ((_aPosition.y + 1) >7)_aPosition.y = 0;
else _aPosition.y++;
LISTVIEW_SetItemTextColor(hItem, _aPosition.y, _aPosition.x, LISTVIEW_CI_UNSEL, GUI_WHITE);
break;
case GUI_KEY_OK:
// hItem = WM_GetDialogItem(WM_HBKWIN, ID_WINDOW_0);
// hItem = LISTVIEW_CreateEx(200,50,100,150,hItem,WM_CF_SHOW,0,ID_LISTVIEW_1);
// LISTVIEW_AddColumn(hItem, 50, "Name", GUI_TA_HCENTER | GUI_TA_VCENTER);
// LISTVIEW_AddColumn(hItem, 50, "Value", GUI_TA_HCENTER | GUI_TA_VCENTER);
// LISTVIEW_SetGridVis(hItem, 1);
// LISTVIEW_SetRowHeight(hItem, 30);
CreateChildWindow();
logFlag = 1;
break;
}
// break;
// case ID_LISTVIEW_1:
//
// break;
// }
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateWindow
*/
WM_HWIN CreateWindow(void);
WM_HWIN CreateWindow(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
/*********************************************************************
*
* CreateChildWindow
*/
WM_HWIN CreateChildWindow(void) {
WM_HWIN hWin,htem;
hWin = WM_GetDialogItem(WM_HBKWIN, ID_LISTVIEW_0);
htem = GUI_CreateDialogBox(_aChildDialogCreate, GUI_COUNTOF(_aChildDialogCreate), _cbChildDialog, hWin, 0, 0);
//WM_MakeModal(hWin);
// WM_InvalidateWindow(hWin);
//WM_Paint(hWin);
return htem;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/ |
|