[ucgui] 对话框3——GUIBuilder生成界面c文件及修改


 

>_<" 其实生成GUI有相应的工具:

>_<" 将对应的控件布置好之后点击保存,会生成一个c文件,这个c文件要做些修改:

  • 将资源列表里的每一个控件的最后一个参数删掉
  • 将最后一个函数中的: hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 0, 0);改为:GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate),&_cbDialog, 0, 0, 0);否则会不出现效果~
  • 再编译出错,就说明少一些文件引入,比如你窗口里有进度条,如果少了#include "..\GUIinc\PROGBAR.h"则会报错!
  生成c文件
>_<" 下面是修改后的c文件,今后采用这种方法就能很快生成想要的界面啦!
复制代码
  1 #include "..\GUIinc\GUI.h" 
  2 #include "..\GUIinc\LCD_ConfDefaults.h"  /* valid LCD configuration */
  3 #include "..\GUIinc\WM.h"
  4 #include "..\GUIinc\DIALOG.h" 
  5 #include "..\GUIinc\EDIT.h"
  6 #include "..\GUIinc\SLIDER.h"
  7 #include "..\GUIinc\FRAMEWIN.h"
  8 #include "..\GUIinc\MULTIEDIT.h"
  9 #include "..\GUIinc\LISTVIEW.h"    
 10 #include "..\GUIinc\PROGBAR.h"
 11 #include "demo.h"
 12 
 13 #include "DIALOG.h"
 14 
 15 #define ID_FRAMEWIN_0   (GUI_ID_USER + 0x0E)
 16 #define ID_TEXT_0   (GUI_ID_USER + 0x10)
 17 #define ID_LISTBOX_0   (GUI_ID_USER + 0x11)
 18 #define ID_LISTVIEW_0   (GUI_ID_USER + 0x12)
 19 #define ID_RADIO_0   (GUI_ID_USER + 0x13)
 20 #define ID_PROGBAR_0   (GUI_ID_USER + 0x14)
 21 #define ID_LISTBOX_1   (GUI_ID_USER + 0x15)
 22 #define ID_CHECKBOX_0   (GUI_ID_USER + 0x17)
 23 #define ID_BUTTON_0   (GUI_ID_USER + 0x18)
 24 #define ID_BUTTON_1   (GUI_ID_USER + 0x19)
 25 #define ID_SLIDER_0   (GUI_ID_USER + 0x1A)
 26 #define ID_EDIT_0   (GUI_ID_USER + 0x1C)
 27 #define ID_CHECKBOX_1   (GUI_ID_USER + 0x1D)
 28 #define ID_CHECKBOX_2   (GUI_ID_USER + 0x1E)
 29 
 30 // USER START (Optionally insert additional defines)
 31 // USER END
 32 
 33 /*********************************************************************
 34 *
 35 *       Static data
 36 *
 37 **********************************************************************
 38 */
 39 
 40 // USER START (Optionally insert additional static data)
 41 // USER END
 42 
 43 /*********************************************************************
 44 *
 45 *       _aDialogCreate
 46 */
 47 static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
 48   { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0},
 49   { TEXT_CreateIndirect, "Text", ID_TEXT_0, 44, 176, 80, 20, 0, 0},
 50   { LISTBOX_CreateIndirect, "Listbox", ID_LISTBOX_0, 283, 10, 146, 150, 0, 0},
 51   { LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_0, 446, 15, 336, 185, 0, 0},
 52   { RADIO_CreateIndirect, "Radio", ID_RADIO_0, 95, 20, 80, 60, 0, 5122},
 53   { PROGBAR_CreateIndirect, "Progbar", ID_PROGBAR_0, 228, 375, 282, 20, 0, 0},
 54   { LISTBOX_CreateIndirect, "Listbox", ID_LISTBOX_1, 632, 215, 144, 179, 0, 0},
 55   { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 8, 29, 80, 19, 0, 0},
 56   { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 77, 332, 80, 20, 0, 0},
 57   { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 76, 306, 80, 20, 0, 0},
 58   { SLIDER_CreateIndirect, "Slider", ID_SLIDER_0, 226, 317, 292, 31, 0, 0},
 59   { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 236, 238, 266, 22, 0, 100},
 60   { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_1, 11, 52, 80, 20, 0, 0},
 61   { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_2, 8, 7, 80, 20, 0, 0},
 62   // USER START (Optionally insert additional widgets)
 63   // USER END
 64 };
 65 
 66 /*********************************************************************
 67 *
 68 *       Static code
 69 *
 70 **********************************************************************
 71 */
 72 
 73 // USER START (Optionally insert additional static code)
 74 // USER END
 75 
 76 /*********************************************************************
 77 *
 78 *       _cbDialog
 79 */
 80 static void _cbDialog(WM_MESSAGE * pMsg) {
 81   WM_HWIN hItem;
 82   int Id, NCode;
 83   // USER START (Optionally insert additional variables)
 84   // USER END
 85 
 86   switch (pMsg->MsgId) {
 87   case WM_INIT_DIALOG:
 88     //
 89     // Initialization of 'Listbox'
 90     //
 91     hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
 92     LISTBOX_AddString(hItem, "Item 0");
 93     LISTBOX_AddString(hItem, "Item 1");
 94     LISTBOX_AddString(hItem, "Item 2");
 95     //
 96     // Initialization of 'Listview'
 97     //
 98     hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
 99     LISTVIEW_AddColumn(hItem, 30, "Col 0", GUI_TA_HCENTER | GUI_TA_VCENTER);
100     LISTVIEW_AddColumn(hItem, 30, "Col 1", GUI_TA_HCENTER | GUI_TA_VCENTER);
101     LISTVIEW_AddColumn(hItem, 30, "Col 2", GUI_TA_HCENTER | GUI_TA_VCENTER);
102     LISTVIEW_AddRow(hItem, NULL);
103     LISTVIEW_SetGridVis(hItem, 1);
104     LISTVIEW_SetItemBkColor(hItem, 0, 0, LISTVIEW_CI_UNSEL, 0x00FFFFFF);
105     //
106     // Initialization of 'Listbox'
107     //
108     hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_1);
109     LISTBOX_AddString(hItem, "Item 0");
110     LISTBOX_AddString(hItem, "Item 1");
111     LISTBOX_AddString(hItem, "Item 2");
112     //
113     // Initialization of 'Checkbox'
114     //
115     hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
116     CHECKBOX_SetText(hItem, "Check");
117     //
118     // Initialization of 'Edit'
119     //
120     hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
121     EDIT_SetText(hItem, "123");
122     //
123     // Initialization of 'Checkbox'
124     //
125     hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1);
126     CHECKBOX_SetText(hItem, "Check");
127     //
128     // Initialization of 'Checkbox'
129     //
130     hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2);
131     CHECKBOX_SetText(hItem, "Check");
132     // USER START (Optionally insert additional code for further widget initialization)
133     // USER END
134     break;
135   case WM_NOTIFY_PARENT:
136     Id    = WM_GetId(pMsg->hWinSrc);
137     NCode = pMsg->Data.v;
138     switch(Id) {
139     case ID_LISTBOX_0: // Notifications sent by 'Listbox'
140       switch(NCode) {
141       case WM_NOTIFICATION_CLICKED:
142         // USER START (Optionally insert code for reacting on notification message)
143         // USER END
144         break;
145       case WM_NOTIFICATION_RELEASED:
146         // USER START (Optionally insert code for reacting on notification message)
147         // USER END
148         break;
149       case WM_NOTIFICATION_SEL_CHANGED:
150         // USER START (Optionally insert code for reacting on notification message)
151         // USER END
152         break;
153       // USER START (Optionally insert additional code for further notification handling)
154       // USER END
155       }
156       break;
157     case ID_LISTVIEW_0: // Notifications sent by 'Listview'
158       switch(NCode) {
159       case WM_NOTIFICATION_CLICKED:
160         // USER START (Optionally insert code for reacting on notification message)
161         // USER END
162         break;
163       case WM_NOTIFICATION_RELEASED:
164         // USER START (Optionally insert code for reacting on notification message)
165         // USER END
166         break;
167       case WM_NOTIFICATION_SEL_CHANGED:
168         // USER START (Optionally insert code for reacting on notification message)
169         // USER END
170         break;
171       // USER START (Optionally insert additional code for further notification handling)
172       // USER END
173       }
174       break;
175     case ID_RADIO_0: // Notifications sent by 'Radio'
176       switch(NCode) {
177       case WM_NOTIFICATION_CLICKED:
178         // USER START (Optionally insert code for reacting on notification message)
179         // USER END
180         break;
181       case WM_NOTIFICATION_RELEASED:
182         // USER START (Optionally insert code for reacting on notification message)
183         // USER END
184         break;
185       case WM_NOTIFICATION_VALUE_CHANGED:
186         // USER START (Optionally insert code for reacting on notification message)
187         // USER END
188         break;
189       // USER START (Optionally insert additional code for further notification handling)
190       // USER END
191       }
192       break;
193     case ID_LISTBOX_1: // Notifications sent by 'Listbox'
194       switch(NCode) {
195       case WM_NOTIFICATION_CLICKED:
196         // USER START (Optionally insert code for reacting on notification message)
197         // USER END
198         break;
199       case WM_NOTIFICATION_RELEASED:
200         // USER START (Optionally insert code for reacting on notification message)
201         // USER END
202         break;
203       case WM_NOTIFICATION_SEL_CHANGED:
204         // USER START (Optionally insert code for reacting on notification message)
205         // USER END
206         break;
207       // USER START (Optionally insert additional code for further notification handling)
208       // USER END
209       }
210       break;
211     case ID_CHECKBOX_0: // Notifications sent by 'Checkbox'
212       switch(NCode) {
213       case WM_NOTIFICATION_CLICKED:
214         // USER START (Optionally insert code for reacting on notification message)
215         // USER END
216         break;
217       case WM_NOTIFICATION_RELEASED:
218         // USER START (Optionally insert code for reacting on notification message)
219         // USER END
220         break;
221       case WM_NOTIFICATION_VALUE_CHANGED:
222         // USER START (Optionally insert code for reacting on notification message)
223         // USER END
224         break;
225       // USER START (Optionally insert additional code for further notification handling)
226       // USER END
227       }
228       break;
229     case ID_BUTTON_0: // Notifications sent by 'Button'
230       switch(NCode) {
231       case WM_NOTIFICATION_CLICKED:
232         // USER START (Optionally insert code for reacting on notification message)
233         // USER END
234         break;
235       case WM_NOTIFICATION_RELEASED:
236         // USER START (Optionally insert code for reacting on notification message)
237         // USER END
238         break;
239       // USER START (Optionally insert additional code for further notification handling)
240       // USER END
241       }
242       break;
243     case ID_BUTTON_1: // Notifications sent by 'Button'
244       switch(NCode) {
245       case WM_NOTIFICATION_CLICKED:
246         // USER START (Optionally insert code for reacting on notification message)
247         // USER END
248         break;
249       case WM_NOTIFICATION_RELEASED:
250         // USER START (Optionally insert code for reacting on notification message)
251         // USER END
252         break;
253       // USER START (Optionally insert additional code for further notification handling)
254       // USER END
255       }
256       break;
257     case ID_SLIDER_0: // Notifications sent by 'Slider'
258       switch(NCode) {
259       case WM_NOTIFICATION_CLICKED:
260         // USER START (Optionally insert code for reacting on notification message)
261         // USER END
262         break;
263       case WM_NOTIFICATION_RELEASED:
264         // USER START (Optionally insert code for reacting on notification message)
265         // USER END
266         break;
267       case WM_NOTIFICATION_VALUE_CHANGED:
268         // USER START (Optionally insert code for reacting on notification message)
269         // USER END
270         break;
271       // USER START (Optionally insert additional code for further notification handling)
272       // USER END
273       }
274       break;
275     case ID_EDIT_0: // Notifications sent by 'Edit'
276       switch(NCode) {
277       case WM_NOTIFICATION_CLICKED:
278         // USER START (Optionally insert code for reacting on notification message)
279         // USER END
280         break;
281       case WM_NOTIFICATION_RELEASED:
282         // USER START (Optionally insert code for reacting on notification message)
283         // USER END
284         break;
285       case WM_NOTIFICATION_VALUE_CHANGED:
286         // USER START (Optionally insert code for reacting on notification message)
287         // USER END
288         break;
289       // USER START (Optionally insert additional code for further notification handling)
290       // USER END
291       }
292       break;
293     case ID_CHECKBOX_1: // Notifications sent by 'Checkbox'
294       switch(NCode) {
295       case WM_NOTIFICATION_CLICKED:
296         // USER START (Optionally insert code for reacting on notification message)
297         // USER END
298         break;
299       case WM_NOTIFICATION_RELEASED:
300         // USER START (Optionally insert code for reacting on notification message)
301         // USER END
302         break;
303       case WM_NOTIFICATION_VALUE_CHANGED:
304         // USER START (Optionally insert code for reacting on notification message)
305         // USER END
306         break;
307       // USER START (Optionally insert additional code for further notification handling)
308       // USER END
309       }
310       break;
311     case ID_CHECKBOX_2: // Notifications sent by 'Checkbox'
312       switch(NCode) {
313       case WM_NOTIFICATION_CLICKED:
314         // USER START (Optionally insert code for reacting on notification message)
315         // USER END
316         break;
317       case WM_NOTIFICATION_RELEASED:
318         // USER START (Optionally insert code for reacting on notification message)
319         // USER END
320         break;
321       case WM_NOTIFICATION_VALUE_CHANGED:
322         // USER START (Optionally insert code for reacting on notification message)
323         // USER END
324         break;
325       // USER START (Optionally insert additional code for further notification handling)
326       // USER END
327       }
328       break;
329     // USER START (Optionally insert additional code for further Ids)
330     // USER END
331     }
332     break;
333   // USER START (Optionally insert additional message handling)
334   // USER END
335   default:
336     WM_DefaultProc(pMsg);
337     break;
338   }
339 }
340 /*************************** End of file ****************************/
341 
342 /*********************************************************************
343 *
344 * MainTask
345 */
346 void Fun(void) {
347   GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate),&_cbDialog, 0, 0, 0);
348 }
349 /*
350 创建对话框后,所有资源表中的小工具都将可见。尽管这些小工具在上面的屏幕截图中可见,但它们
351 是以 “空”的形式出现的。这是因为对话框过程函数尚未包含初始化单个元素的代码。小工具的初始
352 值、由它们所引起的行为以及它们之间的交互作用都需要在对话框过程中进行定义。
353 */
复制代码



version :4.0 1、将生成的代码和事件用两个文件实现。 2、修改了部分Bug; 3、颜色设置做了部分改进; 4、内部集成了VC的编译器,和模拟器,生成C文件后可以直接在uCGUIBuilder中编译,运行模拟器了 5、添加代码自动完成功能; 6、添加画线功能。 version : 3.1.0.0 1、修改了选择不同窗体属性窗口不更新的BUG; 2、修改了只能打开一个ucGUIBuilder的功能,现在可以同时启动多个; 3、修复了拖放非ucfrm引起软件错误的Bug; 4、添加了控件ID自动增加功能; 5、添加了控件ID检查功能,控件ID有重复时会有警告; 6、添加了用户自定义字体功能; 7、支持中英文切换(但功能不够完善); 8、支持自动检查更新; 9、修改了不能保存用户自定义ID的BUG; version : 3.0.0.0 重写了部分内核,运行更稳定; 支持窗体设计器的复制、粘贴、剪切、删除、撤销、等基本操作; 支持多控件,对齐、公共属性修改等基本操作; 支持将.ucfrm文件ucGUIBuilder关联功能; 支持控件自定义ID; 添加了窗体预览功能; 添加了对控件事件的支持; 添加了在线检查更新功能; 等…… version : 2.1.0.5 优化了控件库; 修复了一些Bug; 代码生成窗口中添加了C语言语法高亮显示功能; C文件模板做了部分修改(C文件模板大家可以随意修改为自己喜欢的格式(..\Template\Template.c文件) 但是要保证$$$GUI_WIDGET_CREATE_INFO$$$ $$$Defination$$$ $$$InitDialog$$$ 三个字符串位置不变) 支持设计的窗体保存为文件,并可以打开; 对所有控件属性添加了Description(在属性窗口最下面显示); 窗体布局可以保存,可以自定义为自己喜欢的窗体布局; 修改了部分功能; version : 2.0.0.5 优化了控件库; 修复了一些Bug; 可以生成完整的C文件(包括 资源表,初始化代码等); 修改了部分功能; version : 1.0.0.0 功能很不完善; 还有好多BUG; 目前只能生成资源表; 暂时不能生成其他代码; 大家有什么好的建议可以发送Email 到: ucguibuilder@163.com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值