ucgui 如何在WM视窗里创建按钮
不是在对话框里!用BUTTON_CreateAsChild()函数,以桌面背景为父窗口的能看到效果,以普通的窗口为父窗口的就显示不出来不知道为什么?...
不是在对话框里!
用BUTTON_CreateAsChild()函数,以桌面背景为父窗口的能看到效果,以普通的窗口为父窗口的就显示不出来 不知道为什么? 展开
用BUTTON_CreateAsChild()函数,以桌面背景为父窗口的能看到效果,以普通的窗口为父窗口的就显示不出来 不知道为什么? 展开
1个回答
展开全部
我大体明白你的意思,你要在一个窗口里面创建按钮,而不是在桌面上创建。窗口叫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);
}
创建一个对话框的过程:
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);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询