DavidZH 发表于 2017-11-8 18:13
有事件的
我在窗口上放了一个按钮,但触摸该按钮时一直没反应,直接显示触摸点数据是没问题的,是不是我哪里配置有问题呀?看别的例程里都没有添加WM_TOUCH事件消息。我的代码如下,
#include "DIALOG.h"
#include "stdio.h"
#include "math.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_1 (GUI_ID_USER + 0x02)
#define ID_BUTTON_2 (GUI_ID_USER + 0x03)
#define ID_TEXT_1 (GUI_ID_USER + 0x04)
#define ID_TEXT_2 (GUI_ID_USER + 0x05)
extern GUI_CONST_STORAGE GUI_FONT GUI_FontsongFont16;
extern int abs(int);
// USER START (Optionally insert additional defines)
/*void GUI_intToString(int num,char *s)
{
int temp,i;
i = 0;
if(num == 0)
{
*s = '0';
}
else if(num=1000)
temp%=1000;
while(temp>0)
{
*buf++=temp%10;
temp/=10;
}
}
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
//GUI_PID_STATE TouchState;
static int flag = 0;
int NCode;
int Id;
//char touchBuf[3];
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_PAINT:
if(!flag){
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem, &GUI_Font16_ASCII);
TEXT_SetText(hItem,"Hello World!");
}
break;
case WM_INIT_DIALOG:
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetFont(hItem, &GUI_Font16_ASCII);
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
BUTTON_SetFont(hItem, &GUI_Font16_ASCII);
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
BUTTON_SetFont(hItem, &GUI_Font16_ASCII);
// USER START (Optionally insert additional code for further widget initialization)
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
TEXT_SetFont(hItem, &GUI_Font16_ASCII);
// 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 'Button'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_1:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
flag = !flag;
WM_InvalidateWindow(pMsg->hWin);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem, &GUI_Font16_ASCII);
TEXT_SetText(hItem,"Hello World!");
break;
}
break;
case ID_BUTTON_2:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
}
break;
case WM_TOUCH:
break;
//hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
//TEXT_SetFont(hItem, &GUI_Font16_ASCII);
//GUI_TOUCH_GetState(&TouchState);
//TEXT_SetText(hItem,"Hello World!");
//GUI_intToString(TouchState.x,touchBuf);
//TEXT_SetText(hItem,touchBuf);
//hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
//TEXT_SetFont(hItem, &GUI_Font16_ASCII);
//GUI_intToString(TouchState.y,touchBuf);
//TEXT_SetText(hItem,touchBuf);
// USER START (Optionally insert additional message handling)
// USER END
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;
}
// USER START (Optionally insert additional public code)
// USER END
/*************************** End of file ****************************/复制代码