EMWin对话框Diolog学习
来源:互联网 发布:淘宝主图怎么设计 编辑:程序博客网 时间:2024/05/29 10:12
1:实例DIALOG_Count.c
效果
#include "DIALOG.h"
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect,"Counting...", 0, 30, 90, 260, 140, FRAMEWIN_CF_MOVEABLE },
{TEXT_CreateIndirect, "00", GUI_ID_TEXT0, 10, 10, 120, 80 },
{RADIO_CreateIndirect, "", GUI_ID_RADIO0, 150, 10,100, 80, 0, 4 },
{BUTTON_CreateIndirect, "OK", GUI_ID_OK, 10, 100, 60, 18 },
{BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 180,100, 60, 18 },
};
static const char * _apLabel[] = {
"GUI_FontFD32",
"GUI_FontFD48",
"GUI_FontFD64",
"GUI_FontFD80",
};
static const GUI_FONT * _apFont[] = {
&GUI_FontD32,
&GUI_FontD48,
&GUI_FontD64,
&GUI_FontD80
};
static const char * _asExplain[] = {
"Please use the RADIO buttons to select",
"the big digit font used for counting."
};
static void _SetFont(WM_HWIN hDlg) {
WM_HWIN hItem;
int Index;
hItem = WM_GetDialogItem(hDlg,GUI_ID_RADIO0);
Index = RADIO_GetValue(hItem);
hItem = WM_GetDialogItem(hDlg,GUI_ID_TEXT0);
TEXT_SetFont(hItem, _apFont[Index]);
}
static void _cbBkWindow(WM_MESSAGE * pMsg) {
unsigned i;
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_SetBkColor(GUI_BLUE);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_DispStringHCenterAt("Counting Sample", 160, 5);
GUI_SetFont(&GUI_Font8x16);
for (i = 0;i < GUI_COUNTOF(_asExplain); i++) {
GUI_DispStringAt(_asExplain[i], 5, 40 + i * 16);
}
default:
WM_DefaultProc(pMsg);
}
}
static void _cbCallback(WM_MESSAGE * pMsg) {
unsigned i;
int NCode, Id;
WM_HWIN hDlg, hItem;
hDlg = pMsg->hWin;
switch (pMsg->MsgId) {
caseWM_INIT_DIALOG: //初始化对话框
hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0);
for (i = 0; i < GUI_COUNTOF(_apLabel); i++) {
RADIO_SetText(hItem, _apLabel[i], i);
}
_SetFont(hDlg);
break;
caseWM_NOTIFY_PARENT: //事件类型为通知父窗口
Id =WM_GetId(pMsg->hWinSrc);
NCode =pMsg->Data.v;
switch (NCode) {
case WM_NOTIFICATION_VALUE_CHANGED:
_SetFont(hDlg);
break;
caseWM_NOTIFICATION_RELEASED:
if (Id == GUI_ID_OK){
GUI_EndDialog(hDlg, 0);
效果
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
};
static const char * _apLabel[] = {
};
static const GUI_FONT * _apFont[] = {
};
static const char * _asExplain[] = {
};
static void _SetFont(WM_HWIN hDlg) {
}
static void _cbBkWindow(WM_MESSAGE * pMsg) {
}
static void _cbCallback(WM_MESSAGE * pMsg) {