ucgui中如何在窗口里创建一个按钮作为子窗口 10
//桌面窗口的回调函数staticvoid_cbBkWindow(WM_MESSAGE*pMsg){switch(pMsg->MsgId){caseWM_PAINT:GU...
//桌面窗口的回调函数
static void _cbBkWindow(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
//窗口的回调函数
static void cbRightWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_BLUE);
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
//按钮的回调函数
static void cbButton(WM_MESSAGE* pMsg)
{
GUI_RECT Rect;
switch (pMsg->MsgId)
{
case WM_TOUCH:
GUI_GotoXY(160,120);
GUI_DispString("Hello world!");
break;
case WM_PAINT:
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
static void _CreateWin()
{
WM_CALLBACK* _cbOldBk;
WM_HWIN hWnd;
BUTTON_Handle hButton;
int Key=0;
_cbOldBk = WM_SetCallback(WM_HBKWIN, _cbBkWindow);
hWnd=WM_CreateWindow(239,0,80,239,WM_CF_SHOW,cbRightWin,0);
hButton=BUTTON_CreateAsChild(23910,0+5,70,45,hWnd,GUI_ID_OK,WM_CF_SHOW);
BUTTON_SetBkColor(hButton,0,GUI_RED);
BUTTON_SetFont(hButton,&GUI_Font8x16);
BUTTON_SetText(hButton,"OK");
BUTTON_SetTextColor(hButton, 0, GUI_WHITE);
GUI_Delay(500);
Key=GUI_WaitKey();
/*删除按钮对象*/
WM_DeleteWindow(hWnd);
//等待一会,背景会重绘
BUTTON_Delete(hButton);
//删除窗口
GUI_Delay(1000);
//删除窗口的回调函数
//WM_SetCallback(WM_HBKWIN,0);
//删除窗口的回调函数
//WM_SetCallback(WM_HBKWIN,0);
GUI_Exec();
}
void MainTask(void)
{
GUI_Init();
//GUI_HWIN hWnd;
while(1) {
_CreateWin();
GUI_Delay(500);
// GUI_GotoXY(160,120);
//GUI_DispString("Hello world!");
}
}
这是我的程序 运行时根本看不到按钮,不知道为什么? 展开
static void _cbBkWindow(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
//窗口的回调函数
static void cbRightWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_BLUE);
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
//按钮的回调函数
static void cbButton(WM_MESSAGE* pMsg)
{
GUI_RECT Rect;
switch (pMsg->MsgId)
{
case WM_TOUCH:
GUI_GotoXY(160,120);
GUI_DispString("Hello world!");
break;
case WM_PAINT:
GUI_Clear();
break;
default:
WM_DefaultProc(pMsg);
}
}
static void _CreateWin()
{
WM_CALLBACK* _cbOldBk;
WM_HWIN hWnd;
BUTTON_Handle hButton;
int Key=0;
_cbOldBk = WM_SetCallback(WM_HBKWIN, _cbBkWindow);
hWnd=WM_CreateWindow(239,0,80,239,WM_CF_SHOW,cbRightWin,0);
hButton=BUTTON_CreateAsChild(23910,0+5,70,45,hWnd,GUI_ID_OK,WM_CF_SHOW);
BUTTON_SetBkColor(hButton,0,GUI_RED);
BUTTON_SetFont(hButton,&GUI_Font8x16);
BUTTON_SetText(hButton,"OK");
BUTTON_SetTextColor(hButton, 0, GUI_WHITE);
GUI_Delay(500);
Key=GUI_WaitKey();
/*删除按钮对象*/
WM_DeleteWindow(hWnd);
//等待一会,背景会重绘
BUTTON_Delete(hButton);
//删除窗口
GUI_Delay(1000);
//删除窗口的回调函数
//WM_SetCallback(WM_HBKWIN,0);
//删除窗口的回调函数
//WM_SetCallback(WM_HBKWIN,0);
GUI_Exec();
}
void MainTask(void)
{
GUI_Init();
//GUI_HWIN hWnd;
while(1) {
_CreateWin();
GUI_Delay(500);
// GUI_GotoXY(160,120);
//GUI_DispString("Hello world!");
}
}
这是我的程序 运行时根本看不到按钮,不知道为什么? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询