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

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

>_<" 将对应的控件布置好之后点击保存,会生成一个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"则会报错!
  1 /*********************************************************************
  2 *                                                                    *
  3 *                SEGGER Microcontroller GmbH & Co. KG                *
  4 *        Solutions for real time microcontroller applications        *
  5 *                                                                    *
  6 **********************************************************************
  7 *                                                                    *
  8 * C-file generated by:                                               *
  9 *                                                                    *
 10 *        GUI_Builder for emWin version 5.12                          *
 11 *        Compiled Jun 29 2011, 15:28:47                              *
 12 *        (c) 2011 Segger Microcontroller GmbH & Co. KG               *
 13 *                                                                    *
 14 **********************************************************************
 15 *                                                                    *
 16 *        Internet: www.segger.com  Support: support@segger.com       *
 17 *                                                                    *
 18 **********************************************************************
 19 */
 20 
 21 // USER START (Optionally insert additional includes)
 22 // USER END
 23 
 24 #include "DIALOG.h"
 25 
 26 /*********************************************************************
 27 *
 28 *       Defines
 29 *
 30 **********************************************************************
 31 */
 32 
 33 #define ID_FRAMEWIN_0   (GUI_ID_USER + 0x0E)
 34 #define ID_TEXT_0   (GUI_ID_USER + 0x10)
 35 #define ID_LISTBOX_0   (GUI_ID_USER + 0x11)
 36 #define ID_LISTVIEW_0   (GUI_ID_USER + 0x12)
 37 #define ID_RADIO_0   (GUI_ID_USER + 0x13)
 38 #define ID_PROGBAR_0   (GUI_ID_USER + 0x14)
 39 #define ID_LISTBOX_1   (GUI_ID_USER + 0x15)
 40 #define ID_CHECKBOX_0   (GUI_ID_USER + 0x17)
 41 #define ID_BUTTON_0   (GUI_ID_USER + 0x18)
 42 #define ID_BUTTON_1   (GUI_ID_USER + 0x19)
 43 #define ID_SLIDER_0   (GUI_ID_USER + 0x1A)
 44 #define ID_EDIT_0   (GUI_ID_USER + 0x1C)
 45 #define ID_CHECKBOX_1   (GUI_ID_USER + 0x1D)
 46 #define ID_CHECKBOX_2   (GUI_ID_USER + 0x1E)
 47 
 48 // USER START (Optionally insert additional defines)
 49 // USER END
 50 
 51 /*********************************************************************
 52 *
 53 *       Static data
 54 *
 55 **********************************************************************
 56 */
 57 
 58 // USER START (Optionally insert additional static data)
 59 // USER END
 60 
 61 /*********************************************************************
 62 *
 63 *       _aDialogCreate
 64 */
 65 static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
 66   { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0, 0 },
 67   { TEXT_CreateIndirect, "Text", ID_TEXT_0, 44, 176, 80, 20, 0, 0, 0 },
 68   { LISTBOX_CreateIndirect, "Listbox", ID_LISTBOX_0, 283, 10, 146, 150, 0, 0, 0 },
 69   { LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_0, 446, 15, 336, 185, 0, 0, 0 },
 70   { RADIO_CreateIndirect, "Radio", ID_RADIO_0, 95, 20, 80, 60, 0, 5122, 0 },
 71   { PROGBAR_CreateIndirect, "Progbar", ID_PROGBAR_0, 228, 375, 282, 20, 0, 0, 0 },
 72   { LISTBOX_CreateIndirect, "Listbox", ID_LISTBOX_1, 632, 215, 144, 179, 0, 0, 0 },
 73   { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 8, 29, 80, 19, 0, 0, 0 },
 74   { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 77, 332, 80, 20, 0, 0, 0 },
 75   { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 76, 306, 80, 20, 0, 0, 0 },
 76   { SLIDER_CreateIndirect, "Slider", ID_SLIDER_0, 226, 317, 292, 31, 0, 0, 0 },
 77   { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 236, 238, 266, 22, 0, 100, 0 },
 78   { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_1, 11, 52, 80, 20, 0, 0, 0 },
 79   { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_2, 8, 7, 80, 20, 0, 0, 0 },
 80   // USER START (Optionally insert additional widgets)
 81   // USER END
 82 };
 83 
 84 /*********************************************************************
 85 *
 86 *       Static code
 87 *
 88 **********************************************************************
 89 */
 90 
 91 // USER START (Optionally insert additional static code)
 92 // USER END
 93 
 94 /*********************************************************************
 95 *
 96 *       _cbDialog
 97 */
 98 static void _cbDialog(WM_MESSAGE * pMsg) {
 99   WM_HWIN hItem;
100   int Id, NCode;
101   // USER START (Optionally insert additional variables)
102   // USER END
103 
104   switch (pMsg->MsgId) {
105   case WM_INIT_DIALOG:
106     //
107     // Initialization of 'Listbox'
108     //
109     hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
110     LISTBOX_AddString(hItem, "Item 0");
111     LISTBOX_AddString(hItem, "Item 1");
112     LISTBOX_AddString(hItem, "Item 2");
113     //
114     // Initialization of 'Listview'
115     //
116     hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
117     LISTVIEW_AddColumn(hItem, 30, "Col 0", GUI_TA_HCENTER | GUI_TA_VCENTER);
118     LISTVIEW_AddColumn(hItem, 30, "Col 1", GUI_TA_HCENTER | GUI_TA_VCENTER);
119     LISTVIEW_AddColumn(hItem, 30, "Col 2", GUI_TA_HCENTER | GUI_TA_VCENTER);
120     LISTVIEW_AddRow(hItem, NULL);
121     LISTVIEW_SetGridVis(hItem, 1);
122     LISTVIEW_SetItemBkColor(hItem, 0, 0, LISTVIEW_CI_UNSEL, 0x00FFFFFF);
123     //
124     // Initialization of 'Listbox'
125     //
126     hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_1);
127     LISTBOX_AddString(hItem, "Item 0");
128     LISTBOX_AddString(hItem, "Item 1");
129     LISTBOX_AddString(hItem, "Item 2");
130     //
131     // Initialization of 'Checkbox'
132     //
133     hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
134     CHECKBOX_SetText(hItem, "Check");
135     //
136     // Initialization of 'Edit'
137     //
138     hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
139     EDIT_SetText(hItem, "123");
140     //
141     // Initialization of 'Checkbox'
142     //
143     hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1);
144     CHECKBOX_SetText(hItem, "Check");
145     //
146     // Initialization of 'Checkbox'
147     //
148     hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2);
149     CHECKBOX_SetText(hItem, "Check");
150     // USER START (Optionally insert additional code for further widget initialization)
151     // USER END
152     break;
153   case WM_NOTIFY_PARENT:
154     Id    = WM_GetId(pMsg->hWinSrc);
155     NCode = pMsg->Data.v;
156     switch(Id) {
157     case ID_LISTBOX_0: // Notifications sent by 'Listbox'
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_LISTVIEW_0: // Notifications sent by 'Listview'
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_SEL_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_RADIO_0: // Notifications sent by 'Radio'
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_VALUE_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_LISTBOX_1: // Notifications sent by 'Listbox'
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_SEL_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_CHECKBOX_0: // Notifications sent by 'Checkbox'
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       case WM_NOTIFICATION_VALUE_CHANGED:
240         // USER START (Optionally insert code for reacting on notification message)
241         // USER END
242         break;
243       // USER START (Optionally insert additional code for further notification handling)
244       // USER END
245       }
246       break;
247     case ID_BUTTON_0: // Notifications sent by 'Button'
248       switch(NCode) {
249       case WM_NOTIFICATION_CLICKED:
250         // USER START (Optionally insert code for reacting on notification message)
251         // USER END
252         break;
253       case WM_NOTIFICATION_RELEASED:
254         // USER START (Optionally insert code for reacting on notification message)
255         // USER END
256         break;
257       // USER START (Optionally insert additional code for further notification handling)
258       // USER END
259       }
260       break;
261     case ID_BUTTON_1: // Notifications sent by 'Button'
262       switch(NCode) {
263       case WM_NOTIFICATION_CLICKED:
264         // USER START (Optionally insert code for reacting on notification message)
265         // USER END
266         break;
267       case WM_NOTIFICATION_RELEASED:
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_SLIDER_0: // Notifications sent by 'Slider'
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_EDIT_0: // Notifications sent by 'Edit'
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_1: // 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     case ID_CHECKBOX_2: // Notifications sent by 'Checkbox'
330       switch(NCode) {
331       case WM_NOTIFICATION_CLICKED:
332         // USER START (Optionally insert code for reacting on notification message)
333         // USER END
334         break;
335       case WM_NOTIFICATION_RELEASED:
336         // USER START (Optionally insert code for reacting on notification message)
337         // USER END
338         break;
339       case WM_NOTIFICATION_VALUE_CHANGED:
340         // USER START (Optionally insert code for reacting on notification message)
341         // USER END
342         break;
343       // USER START (Optionally insert additional code for further notification handling)
344       // USER END
345       }
346       break;
347     // USER START (Optionally insert additional code for further Ids)
348     // USER END
349     }
350     break;
351   // USER START (Optionally insert additional message handling)
352   // USER END
353   default:
354     WM_DefaultProc(pMsg);
355     break;
356   }
357 }
358 
359 /*********************************************************************
360 *
361 *       Public code
362 *
363 **********************************************************************
364 */
365 /*********************************************************************
366 *
367 *       CreateFramewin
368 */
369 WM_HWIN CreateFramewin(void);
370 WM_HWIN CreateFramewin(void) {
371   WM_HWIN hWin;
372 
373   hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 0, 0);
374   return hWin;
375 }
376 
377 // USER START (Optionally insert additional public code)
378 // USER END
379 
380 /*************************** End of file ****************************/
生成c文件

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-02-18
  • 2022-02-22
  • 2021-11-22
  • 2021-10-12
  • 2021-08-10
相关资源
相似解决方案