项目需要,在窗体中显示触摸效果,在网上搜索办法,搜到安富来的一篇教程
http://blog.sina.com.cn/s/blog_98ee3a930102wqwi.html
按照里面的办法,我在WM_TOUCH事件里获取触摸的坐标,并画点,显示成功
case WM_TOUCH:
{
GUI_PID_STATE TouchState;
GUI_TOUCH_GetState(&TouchState);
hWinOld= WM_SelectWindow(WM_GetClientWindow(pMsg->hWin));
GUI_SetColor(GUI_RED);
GUI_SetPenSize(5);
GUI_DrawPoint(TouchState.x,TouchState.y);
WM_SelectWindow(hWinOld);
}
但在销毁窗口时,程序进入hardfault,当程序做以下改进后,正常了
case WM_TOUCH:
{
GUI_PID_STATE TouchState;
GUI_TOUCH_GetState(&TouchState);
if(TouchState.Pressed)
{
hWinOld= WM_SelectWindow(WM_GetClientWindow(pMsg->hWin));
GUI_SetColor(GUI_RED);
GUI_SetPenSize(5);
GUI_DrawPoint(TouchState.x,TouchState.y);
WM_SelectWindow(hWinOld);
}
}