|
用GUIBuilder做了一个界面,在UP和DOWN设置了两个LED灯亮灭的功能,我发现只要WM_INIT_DIALOG:中不加入FRAMEWIN_SetTextColor(hItem, 0x0000FFFF);设置标题颜色按键就不会响应是屏幕上所有按键都无效,设置了之后才会响应,到底是怎么回事?谢谢!
#include "..\User\usart\bsp_usart1.h"
#include "DIALOG.h"
#include "..\User\lcd\bsp_ili9341_lcd.h"
#include "..\User\led\bsp_led.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x02)
#define ID_BUTTON_1 (GUI_ID_USER + 0x03)
#define ID_BUTTON_2 (GUI_ID_USER + 0x04)
#define ID_BUTTON_3 (GUI_ID_USER + 0x05)
#define ID_BUTTON_4 (GUI_ID_USER + 0x06)
#define ID_BUTTON_5 (GUI_ID_USER + 0x07)
#define ID_BUTTON_6 (GUI_ID_USER + 0x08)
#define ID_BUTTON_7 (GUI_ID_USER + 0x09)
#define ID_BUTTON_8 (GUI_ID_USER + 0x0A)
#define ID_TEXT_0 (GUI_ID_USER + 0x0B)
#define ID_TEXT_1 (GUI_ID_USER + 0x0C)
#define ID_TEXT_2 (GUI_ID_USER + 0x0D)
#define ID_TEXT_3 (GUI_ID_USER + 0x0E)
#define ID_TEXT_4 (GUI_ID_USER + 0x0F)
#define ID_EDIT_0 (GUI_ID_USER + 0x12)
#define ID_EDIT_1 (GUI_ID_USER + 0x13)
#define ID_EDIT_2 (GUI_ID_USER + 0x14)
#define ID_EDIT_3 (GUI_ID_USER + 0x15)
#define ID_TEXT_5 (GUI_ID_USER + 0x16)
#define ID_TEXT_6 (GUI_ID_USER + 0x18)
#define ID_EDIT_4 (GUI_ID_USER + 0x19)
#define ID_TEXT_7 (GUI_ID_USER + 0x1A)
#define ID_TEXT_8 (GUI_ID_USER + 0x1B)
#define ID_EDIT_5 (GUI_ID_USER + 0x1C)
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "JT", ID_FRAMEWIN_0, 0, 0, 240, 320, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, "Rest", ID_BUTTON_0, 17, 205, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Speed", ID_BUTTON_1, 149, 270, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Down", ID_BUTTON_2, 83, 270, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Spindle", ID_BUTTON_3, 17, 270, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Right", ID_BUTTON_4, 149, 238, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Measure", ID_BUTTON_5, 83, 238, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Left", ID_BUTTON_6, 17, 238, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, " rint", ID_BUTTON_7, 149, 205, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Up", ID_BUTTON_8, 83, 205, 50, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Torque:", ID_TEXT_0, 9, 22, 80, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "SP:", ID_TEXT_1, 18, 59, 16, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "C", ID_TEXT_2, 182, 22, 10, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "T:", ID_TEXT_3, 128, 22, 10, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "%", ID_TEXT_4, 90, 22, 10, 20, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "0.0", ID_EDIT_0, 48, 20, 40, 20, 0, 0x64, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_1, 140, 20, 40, 20, 0, 0x64, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_2, 48, 57, 40, 20, 0, 0x64, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_3, 125, 57, 45, 20, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "RPM", ID_TEXT_5, 174, 59, 80, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Viscosity:", ID_TEXT_6, 12, 93, 45, 20, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_4, 58, 90, 60, 20, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "mPa.s", ID_TEXT_7, 122, 93, 80, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, " /T:", ID_TEXT_8, 16, 130, 25, 20, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_5, 42, 128, 80, 20, 0, 0x64, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'JT'
//
hItem = pMsg->hWin;
FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
FRAMEWIN_SetTextColor(hItem, 0x0000FFFF); //去掉屏幕所有地方都不响应
//
// Initialization of '0.0'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
EDIT_SetText(hItem, "0.0");
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
EDIT_SetText(hItem, "0.0");
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2);
EDIT_SetText(hItem, "0");
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3);
EDIT_SetText(hItem, "000.0");
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_4);
EDIT_SetText(hItem, "0");
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_5);
EDIT_SetText(hItem, "00:00");
// 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_BUTTON_0: // Notifications sent by 'Rest'
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;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_1: // Notifications sent by 'Speed'
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;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_2: // Notifications sent by 'Down'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
LED2_TOGGLE;
// 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;
case ID_BUTTON_3: // Notifications sent by 'Spindle'
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;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_4: // Notifications sent by 'Right'
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;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_5: // Notifications sent by 'Measure'
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;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_6: // Notifications sent by 'Left'
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;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_7: // Notifications sent by ' rint'
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;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_8: // Notifications sent by 'Up'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
LED1_TOGGLE;
// 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;
case ID_EDIT_0: // Notifications sent by '0.0'
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_VALUE_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;
case ID_EDIT_1: // Notifications sent by 'Edit'
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_VALUE_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;
case ID_EDIT_2: // Notifications sent by 'Edit'
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_VALUE_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;
case ID_EDIT_3: // Notifications sent by 'Edit'
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_VALUE_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;
case ID_EDIT_4: // Notifications sent by 'Edit'
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_VALUE_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;
case ID_EDIT_5: // Notifications sent by 'Edit'
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_VALUE_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
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateJT
*/
WM_HWIN CreateJT(void);
WM_HWIN CreateJT(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/
void MainTask(void)
{
//WM_SetCreateFlags(WM_CF_MEMDEV);
GUI_Init();
CreateJT();
LCD_BK_EN;
while(1)
{
GUI_Delay(10);
}
} |
|