完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
37.2 ToolTips实例
下面通过一个实例跟大家讲解一下ToolTips的使用,这个例子可以直接复制到模拟器或者开发板上面运行。 复制代码 #include #include "stdio.h" #include "GUI.h" #include "DIALOG.h" #include "WM.h" #include "BUTTON.h" #include "CHECKBOX.h" #include "DROPDOWN.h" #include "EDIT.h" #include "FRAMEWIN.h" #include "LISTBOX.h" #include "MULTIEDIT.h" #include "RADIO.h" #include "SLIDER.h" #include "TEXT.h" #include "PROGBAR.h" #include "SCROLLBAR.h" #include "LISTVIEW.h" static int Count; /********************************************************************* * * Dialog resource * * This table conatins the info required to create the dialog. * It has been created by ucGUIbuilder. */ static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { { FRAMEWIN_CreateIndirect, "armfly", 0, 0, 0, 800,480,FRAMEWIN_CF_MOVEABLE,0}, { BUTTON_CreateIndirect, "BUTTON0", GUI_ID_BUTTON0, 82, 122,162,37, 0,0}, { BUTTON_CreateIndirect, "BUTTON1", GUI_ID_BUTTON1, 357,123,152,35, 0,0}, { TEXT_CreateIndirect, "0000", GUI_ID_TEXT0, 278,264,300,48, 0,0} }; /***************************************************************** ** FunctionName:void PaintDialog(WM_MESSAGE * pMsg) ** Function: to initialize the Dialog items ** ** call this function in _cbCallback --> WM_PAINT *****************************************************************/ void PaintDialog(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; } /***************************************************************** ** FunctionName:void InitDialog(WM_MESSAGE * pMsg) ** Function: to initialize the Dialog items ** ** call this function in _cbCallback --> WM_INIT_DIALOG *****************************************************************/ void InitDialog(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; // //FRAMEWIN // FRAMEWIN_SetFont(hWin,&GUI_Font24B_ASCII); FRAMEWIN_SetTextAlign(hWin,GUI_TA_VCENTER|GUI_TA_CENTER); FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); FRAMEWIN_AddMaxButton(hWin, FRAMEWIN_BUTTON_RIGHT, 1); FRAMEWIN_AddMinButton(hWin, FRAMEWIN_BUTTON_RIGHT, 2); FRAMEWIN_SetTitleHeight(hWin,30); // //GUI_ID_TEXT0 // TEXT_SetFont(WM_GetDialogItem(hWin,GUI_ID_TEXT0),&GUI_FontD36x48); } /********************************************************************* * * Dialog callback routine */ static void _cbCallback(WM_MESSAGE * pMsg) { int NCode, Id; char buf[10]; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_TIMER: Count++; sprintf(buf, "%04d", Count); TEXT_SetText(WM_GetDialogItem(hWin,GUI_ID_TEXT0), (const char *)buf); WM_RestartTimer(pMsg->Data.v, 100); break; case WM_PAINT: PaintDialog(pMsg); break; case WM_INIT_DIALOG: InitDialog(pMsg); break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_KEY_ENTER: GUI_EndDialog(hWin, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { case GUI_ID_OK: if(NCode==WM_NOTIFICATION_RELEASED) GUI_EndDialog(hWin, 0); break; case GUI_ID_CANCEL: if(NCode==WM_NOTIFICATION_RELEASED) GUI_EndDialog(hWin, 0); break; case GUI_ID_BUTTON0: switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_MOVED_OUT: break; } break; case GUI_ID_BUTTON1: switch(NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: break; case WM_NOTIFICATION_MOVED_OUT: break; } break; } break; default: WM_DefaultProc(pMsg); } } static const TOOLTIP_INFO _aInfo[] = {(1) { GUI_ID_BUTTON0, "I am Button 0"}, { GUI_ID_BUTTON1, "I am Button 1" }, { GUI_ID_TEXT0, "I am TEXT 0" }, }; /********************************************************************* * * MainTask * ********************************************************************** */ void MainTask(void) { WM_HWIN hDlg; WM_HTIMER hTimer; WM_TOOLTIP_HANDLE hInfo; WM_TOOLTIP_HANDLE hToolTip; Count = 0; /* 使能窗口使用内存设备,这样可以有效避免闪烁 放在GUI_Init前面就包括桌面 窗口,如果放在后面就不包括桌面窗口。 */ WM_SetCreateFlags(WM_CF_MEMDEV); GUI_Init(); WM_SetDesktopColor(GUI_BLUE); /* Automacally update desktop window */ PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX); FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX); PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX); BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX); CHECKBOX_SetDefaultSkin(CHECKBOX_SKIN_FLEX); DROPDOWN_SetDefaultSkin(DROPDOWN_SKIN_FLEX); SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX); SLIDER_SetDefaultSkin(SLIDER_SKIN_FLEX); HEADER_SetDefaultSkin(HEADER_SKIN_FLEX); RADIO_SetDefaultSkin(RADIO_SKIN_FLEX); /* 创建一个对话框 */ hDlg = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0); hTimer = WM_CreateTimer(WM_GetClientWindow(hDlg), 0, 100, 0); hInfo = WM_TOOLTIP_Create(hDlg, _aInfo, GUI_COUNTOF(_aInfo));(2) hToolTip = WM_TOOLTIP_Create(hDlg, NULL, 0);(3) WM_TOOLTIP_AddTool(hToolTip, WM_GetClientWindow(hDlg), "I am a ToolTip");(4) while (1) { GUI_Delay(500); } } |
|
|
|
|
|
1. 创建一个TOOLTIP_INFO类型的数组。用于给两个按钮和一个文本框使用。
2. 创建一个属于hDlg对话框的TOOLTIP。用于给两个按钮和一个文本框提供提示。 3. 再创建一个TOOLTIP。 4. 这句比较的关键,这里是给对话框中的window控件添加TOOLTIP功能。 实际现象效果如下,这个是鼠标放到按钮上面时的提示效果: |
|
|
|
|
|
205 浏览 0 评论
求助一下关于51系列单片机的Timer0的计时问题,TH0、TL0+1的时间是怎么算的?
1253 浏览 1 评论
【RA-Eco-RA4E2-64PIN-V1.0开发板试用】开箱+Keil环境搭建+点灯+点亮OLED
848 浏览 0 评论
【敏矽微ME32G070开发板免费体验】使用coremark测试敏矽微ME32G070 跑分
853 浏览 0 评论
【敏矽微ME32G070开发板免费体验】开箱+点灯+点亮OLED
1073 浏览 2 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
12013 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 04:37 , Processed in 0.630995 second(s), Total 69, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号