/*
*********************************************************************************************************
* 宏定义
*********************************************************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_EDIT_0 (GUI_ID_USER + 0x01)
#define ID_EDIT_1 (GUI_ID_USER + 0x03)
/*
*********************************************************************************************************
* GUI_WIDGET_CREATE_INFO类型数组
*********************************************************************************************************
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
{
{ FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x64, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_0, 88, 27, 159, 29, 0, 0x64, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_1, 87, 73, 159, 30, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, "Button", GUI_ID_OK, 26, 139, 97, 31, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button", GUI_ID_CANCEL, 179, 139, 100, 31, 0, 0x0, 0 },
};
/*
*********************************************************************************************************
* 函 数 名: _cbDialog
* 功能说明: 对话框的回调函数
* 形 参: pMsg 消息指针
* 返 回 值: 无
*********************************************************************************************************
*/
static void _cbDialog(WM_MESSAGE * pMsg)
{
int NCode;
int Id;
WM_HWIN hDlg;
WM_HWIN hItem;
hDlg = pMsg->hWin;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
//
// 初始化框架窗口
//
hItem = pMsg->hWin;
FRAMEWIN_SetFont(hItem, GUI_FONT_24_ASCII);
FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
FRAMEWIN_SetText(hItem, "armfly");
//
// 初始化编辑框控件
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
EDIT_SetText(hItem, "www.armfly.com");
EDIT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
EDIT_SetFont(hItem, GUI_FONT_16_ASCII);
EDIT_SetSel(hItem, 0, -1);
//
// 初始化边框控件
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
EDIT_SetText(hItem, "www.baidu.com");
EDIT_SetFont(hItem, GUI_FONT_16_ASCII);
EDIT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
EDIT_SetSel(hItem, 0, -1);
//
// 初始化按钮控件
//
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_OK);
BUTTON_SetText(hItem, "OK");
BUTTON_SetFont(hItem, GUI_FONT_16_ASCII);
//
// 初始化按钮控件
//
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_CANCEL);
BUTTON_SetText(hItem, "Cancel");
BUTTON_SetFont(hItem, GUI_FONT_16_ASCII);
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
{
case GUI_KEY_ESCAPE:
GUI_EndDialog(hDlg, 1);
break;
case GUI_KEY_ENTER:
GUI_EndDialog(hDlg, 0);
break;
}
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id)
{
/* 点击OK按钮,关闭对话框 */
case GUI_ID_OK:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(hDlg, 0);
break;
}
break;
/* 点击CANCEL按钮,关闭对话框 */
case GUI_ID_CANCEL:
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(hDlg, 1);
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
} |