#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_1 (GUI_ID_USER + 0x02)
#define A (WM_USER +0)
#define B (WM_USER +1)
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
{
{ FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, "Button1", ID_BUTTON_0, 100, 30, 150, 50, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button2", ID_BUTTON_1, 100, 130, 150, 50, 0, 0x0, 0 },
};
//???°?ò???÷????
static void _cbDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
FRAMEWIN_SetText(hItem, "EDIT USER");
FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
FRAMEWIN_SetFont(hItem, GUI_FONT_16B_ASCII);
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT0);
EDIT_EnableBlink(hItem, 500, 1);
EDIT_SetText(hItem, "Hello Word!");
EDIT_SetFont(hItem, &GUI_Font20_ASCII);
EDIT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
break;
case A:
GPIO_SetBits(GPIOB,GPIO_Pin_8);
break;
case B:
GPIO_ResetBits(GPIOB,GPIO_Pin_8);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
void ButtonUse_Demo(void)
{
WM_HWIN hWin;
hWin= GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
while(1)
{
WM_MESSAGE Msg;
GUI_Delay(1000);
Msg.MsgId=A;
WM_SendMessage(hWin,&Msg);
GUI_Delay(1000);
Msg.MsgId=B;
WM_SendMessage(hWin,&Msg);
}
}
|