初中生
最后登录1970-1-1
在线时间 小时
注册时间2017-4-9
|
下面的程序的目的是500ms改变一次对话框的背景色,但是不能够实现该功能,哪位大神能帮我看看这是怎么回事
#include <stddef.h>
#include "GUI.h"
#include "DIALOG.h"
#include "WM.h"
#include "BUTTON.h"
#include "CHECKBOX.h"
#include "EDIT.h"
#include "FRAMEWIN.h"
#include "LISTBOX.h"
#include "MULTIEDIT.h"
#include "RADIO.h"
#include "SLIDER.h"
#include "TEXT.h"
#include "PROGBAR.h"
#include "SCROLLBAR.h"
#include "LISTVIEW.h"
#define WM_Update WM_USER+1
GUI_COLOR _acColor[3] = {GUI_WHITE,GUI_RED,GUI_YELLOW};
static char ucBackColor;
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "armfly", 0, 50, 60, 200, 120, FRAMEWIN_CF_MOVEABLE },
{ BUTTON_CreateIndirect, "Button0", GUI_ID_BUTTON0, 100, 10, 80, 80 },
{ BUTTON_CreateIndirect, "Button1", GUI_ID_BUTTON1, 10, 10, 60, 20 }
};
static void PaintDialog(WM_MESSAGE* pMsg)
{
WM_HWIN hWin = pMsg->hWin;
GUI_SetBkColor(_acColor[ucBackColor]);
GUI_Clear();
}
static void InitDialog(WM_MESSAGE* pMsg)
{
WM_HWIN hWin = pMsg->hWin;
FRAMEWIN_SetFont(hWin,&GUI_Font24B_ASCII); //设置框架窗口字体
FRAMEWIN_SetTextAlign(hWin,GUI_TA_HCENTER|GUI_TA_VCENTER);
FRAMEWIN_SetText(hWin,"armfly"); //设置标题
hWin = WM_GetDialogItem(hWin,GUI_ID_BUTTON0); //获取BUtton的句柄
BUTTON_SetFont(hWin,&GUI_Font24B_ASCII);//设置Button的字体
BUTTON_SetText(hWin,"armfly");//设置button的名称
ucBackColor = 0;
}
static void _cbCallback(WM_MESSAGE* pMsg)
{
int Id;
int NCode;
GUI_HWIN hWin= pMsg->hWin;
switch(pMsg->MsgId)
{
case WM_PAINT:
PaintDialog(pMsg);
break;
case WM_Update:
ucBackColor++;
if (ucBackColor==3)
{
ucBackColor = 0;
}
WM_InvalidateWindow(pMsg->hWin);
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(pMsg->hWin,1);
break;
case GUI_KEY_ENTER:
GUI_EndDialog(pMsg->hWin,0);
break;
}
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id)
{
case GUI_ID_BUTTON0:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
/*ucBackColor++;
if (ucBackColor == 3)
{
ucBackColor = 0;
}
WM_InvalidateWindow(hWin);*/
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_MOVED_OUT:
break;
}
break;
case GUI_ID_BUTTON1:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
/*ucBackColor--;
if (ucBackColor < 0)
{
ucBackColor = 2;
}
WM_InvalidateWindow(hWin);*/
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_MOVED_OUT:
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
static void _cbDialog(WM_MESSAGE*pMsg)
{
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
FRAMEWIN_SetFont(hItem,&GUI_Font24B_ASCII); //设置框架窗口字体
FRAMEWIN_SetTextAlign(hItem,GUI_TA_HCENTER|GUI_TA_VCENTER);
FRAMEWIN_SetText(hItem,"armfly"); //设置标题
hItem = WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON0); //获取BUtton的句柄
BUTTON_SetFont(hItem,&GUI_Font24B_ASCII);//设置Button的字体
BUTTON_SetText(hItem,"armfly");//设置button的名称
ucBackColor =0;
break;
case WM_PAINT:
GUI_SetBkColor(_acColor[ucBackColor]);
GUI_Clear();
break;
case WM_Update:
ucBackColor++;
if (ucBackColor == 3)
{
ucBackColor = 0;
}
WM_InvalidateWindow(pMsg->hWin);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id)
{
case GUI_ID_BUTTON0:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_MOVED_OUT:
break;
}
break;
case GUI_ID_BUTTON1:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_MOVED_OUT:
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
WM_HWIN CreateFramewin(void)
{
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate,GUI_COUNTOF(_aDialogCreate),_cbDialog,WM_HBKWIN,0,0);
return hWin;
}
void MainTask(void)
{
/*
GUI_HWIN hDlg;
GUI_Init();
//WM_SetDesktopColor(GUI_BLUE); //刷新背景
//WM_SetCreateFlags(WM_CF_MEMDEV);
//PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
//FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX); //为什么添加该句就可以发送Paint消息
//BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);
//CHECKBOX_SetDefaultSkin(CHECKBOX_SKIN_FLEX);
// hDlg = GUI_ExecDialogBox(_aDialogCreate,GUI_COUNTOF(_aDialogCreate),&_cbCallback,0,0,0);
hDlg = GUI_CreateDialogBox(_aDialogCreate,GUI_COUNTOF(_aDialogCreate),&_cbCallback,0,0,0);
//GUI_Delay(1000);
while (1)
{
WM_SendMessageNoPara(WM_GetClientWindow(hDlg),WM_Update);
GUI_Delay(500);
GUI_Exec();
}*/
WM_HWIN hDlg;
GUI_Init();
hDlg = CreateFramewin();
while (1)
{
WM_SendMessageNoPara(hDlg,WM_Update);
GUI_Delay(500);
}
}
|
|