ucgui 如何在WM视窗里创建按钮
发布网友
发布时间:2024-10-19 22:46
我来回答
共1个回答
热心网友
时间:2024-12-04 15:06
我大体明白你的意思,你要在一个窗口里面创建按钮,而不是在桌面上创建。窗口叫Frame,按钮叫Button,而带有其他控件的窗口(Frame)其实叫做对话框(Dialog)。
创建一个对话框的过程:
1.声明对话框资源
2.设定回调函数
3.创建对话框
举例如下:
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
{
{ FRAMEWIN_CreateIndirect, "APE Solar", my_MAIN_FRAME, 0, 0, 240, 320, WM_CF_SHOW, 1},
{ BUTTON_CreateIndirect, "TOOLS", MY_ID_TOOLS, 10, 270, 90, 30},
{ BUTTON_CreateIndirect, "CONFIG", MY_ID_CONFIG, 10, 230, 90, 30},
{ BUTTON_CreateIndirect, "SEND", MY_ID_SEND, 120, 230, 110, 70},
{ TEXT_CreateIndirect, "LText", MY_ID_TEXT1, 20, 60, 48, 15, 0},
{ TEXT_CreateIndirect, "LText", MY_ID_TEXT2, 20, 80, 55, 15, 0},
{ TEXT_CreateIndirect, "LText", MY_ID_TEXT3, 20, 100, 65, 15, 0},
{ TEXT_CreateIndirect, "LText", MY_ID_TEXT4, 20, 120, 48, 15, 0},
{ TEXT_CreateIndirect, "LText", MY_ID_TEXT5, 20, 140, 55, 15, 0},
};
static void cb_ShowMainMenu(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
void ShowMainMenu(void)
{
GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &cb_ShowMainMenu, 0, 0, 0);
GUI_Delay(1000);
}