emWin界面刷新

1、在对话框回调函数中定时重绘按键

_cbDialogHome(WM_MESSAGE*  pMsg)
{
	Switch(pMsg -> MsgId){
		Case   WM_INIT_DIALOG:
			WM_CreateTimer(pMsg -> hWin,0,100,0);//创建窗口定时器
		Case   WM_PAINT:   //窗口重绘
		Case   WM_NOTIFY_PARENT://按键消息处理
			Id = WM_GetId(pMsg -> hWinSrc);//哪个按键
			NCode = pMsg -> Data.v;//是点击还是松开
			Switch(Id){
				Case ID_BUTTON_0:
					Switch(NCode){
						Case    WM_NOTIFICATION_CLICKED://点击
						Case    WM_NOTIFICATION_RELEASED://松开按钮
}
}
		Case WM_TIMER:
			WM_RestartTimer(pMsg -> Data.v,100);//重启定时器,因为窗口定时器是单次的
			If( I % 10 == 0 ){
				WM_InvalidateWindow(pMsg -> hWin);//使窗口无效,重绘整个窗口
			}else{
				hItem = WM_GetDialogItem(pMsg -> hWin, ID_BUTTON_0);//获取按键句柄
				WM_InvalidateWindow(hItem);//使按键无效,重绘按键
}
}
}

2、在按键回调函数中刷新按键图片

_cbButtonStart(WM_MESSAGE*  pMsg){
	Switch(pMsg -> MsgId){
		Case WM_PAINT:
			WM_GetClientRect(&Rect);//获取按键矩形
			If(BUTTON_IsPressed(hWin)){//按键按下
}else {
	GUI_DrawStreamedBitmapAuto(imgLocate[IMG].addr,0,0);//绘制按键
}
}
}




你可能感兴趣的:(emWin)