高中生
最后登录1970-1-1
在线时间 小时
注册时间2014-8-20
|
自己定义了一个消息,然后在出函数里面每1s发送一次消息,再调用WM_InvalidateWindow(hWin);执行WM_PAINT改变窗体的颜色,为什么颜色没有被改变。感觉是消息没有发送过来。求大神帮忙解答。
#include <stddef.h>
#include "GUI.h"
#include "DIALOG.h"
#include "WM.h"
/*********************************************************************
*
* static data
*
**********************************************************************
*/
#define WM_UPDATE WM_USER+1
GUI_COLOR _acColor[3] = {GUI_BLUE,GUI_RED,GUI_YELLOW};
static char ucBackColor;
void PaintDialog(WM_MESSAGE *pMsg)
{
WM_HWIN hWin = pMsg->hWin;
GUI_SetBkColor(_acColor[ucBackColor]);
GUI_Clear();
}
/*********************************************************************
*
* Dialog resource
*
* This table conatins the info required to create the dialog.
* It has been created by ucGUIbuilder.
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Caption", 0, 0, 0, 320,240,FRAMEWIN_CF_MOVEABLE,0},
{ BUTTON_CreateIndirect, "BUTTON2", GUI_ID_BUTTON0, 162,36, 89, 51, 0,0},
{ BUTTON_CreateIndirect, "BUTTON1", GUI_ID_BUTTON0, 33, 36, 90, 51, 0,0}
};
/*****************************************************************
** FunctionName:void InitDialog(WM_MESSAGE * pMsg)
** Function: to initialize the Dialog items
**
** call this function in _cbCallback --> WM_INIT_DIALOG
*****************************************************************/
void InitDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hWin = pMsg->hWin;
//
//FRAMEWIN
//
FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0);
FRAMEWIN_AddMaxButton(hWin, FRAMEWIN_BUTTON_RIGHT, 1);
FRAMEWIN_AddMinButton(hWin, FRAMEWIN_BUTTON_RIGHT, 2);
ucBackColor=0;
}
/*********************************************************************
*
* Dialog callback routine
*/
static void _cbCallback(WM_MESSAGE * pMsg)
{
int NCode, Id;
WM_HWIN hWin = pMsg->hWin;
switch (pMsg->MsgId)
{
case WM_UPDATE:
ucBackColor++;
if(ucBackColor == 3)
{
ucBackColor = 0;
}
WM_InvalidateWindow(hWin);
break;
case WM_PAINT:
PaintDialog(pMsg);
break;
case WM_INIT_DIALOG:
InitDialog(pMsg);
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
{
case GUI_KEY_ESCAPE:
GUI_EndDialog(hWin, 1);
break;
case GUI_KEY_ENTER:
GUI_EndDialog(hWin, 0);
break;
}
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (Id)
{
case GUI_ID_OK:
if(NCode==WM_NOTIFICATION_RELEASED)
GUI_EndDialog(hWin, 0);
break;
case GUI_ID_CANCEL:
if(NCode==WM_NOTIFICATION_RELEASED)
GUI_EndDialog(hWin, 0);
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* MainTask
*
**********************************************************************
*/
void MainTask(void)
{
unsigned char i;
WM_HWIN hDlg;
GUI_Init();
WM_SetDesktopColor(GUI_WHITE); /* Automacally update desktop window */
WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */
hDlg = GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);
while(1)
{
WM_SendMessageNoPara(WM_GetClientWindow(hDlg),WM_UPDATE);
GUI_Delay(1000);
}
}
|
|