>_<"Click the "gray window" button to display a mode message window. Click "OK" to focus on the gray window. Click the "gray window" button to display a non-mode window.
1 static const gui_widget_create_info _ adialogorder [] = {// a large window (a button is displayed at the beginning) 2 {framewin_createindirect, "Order vehicle", 0, 20, 50,480,360, 0}, 3 {button_createindirect, "select vehicle", gui_id_button0, 6,113,100, 20, 0}, 4}; 5 6 static void _ cbdialogorder (wm_message * PMSG) {// message window callback function 7 wm_hwin hdlg, hwin = PMSG-> hwin; 8 gui_pid_state * State; 9 10 switch (PMSG-> msgid) {11 case wm_ini T_dialog: 12 break; 13 case wm_policy_parent: 14 if (PMSG-> data. V = wm_icationication_released) {// This notification message will be sent 15 int id = wm_getid (PMSG-> hwinsrc) when the clicked widget has been released; 16 switch (ID) {17 case gui_id_button0: 18 // call the function to generate MessageBox. You can drag the title bar or window box to move the message box 19 hdlg = messagebox_create ("Computer win !!! "," Failed ", gui_messagebox_cf_moveable); 20 // control the settings of window focus until the end of the window [if removed, the effect of the mode window cannot be achieved 21 wm_makemodal (hdlg ); /* This function enables the window to work in "Modal" mode. This means that the pointer device input will only be sent to the "Modal" window, 22, or if the input position is within the rectangle of the modal window, it will only be sent to its subwindows. */23 wm_setfocus (hdlg); // set the input focus to 24 wm_invalidatewindow (hdlg) in the specified window; // 25 break is invalid for the window; 26} 27} 28 break; 29 case wm_touch: 30 State = (gui_pid_state *) PMSG-> data. p; 31 if (State &&! State-> pressed) 32 {33 {34 hdlg = messagebox_create ("You win !!! "," Win ", gui_messagebox_cf_moveable); 35 // comment out the control mode window, and click Create a non-mode window 36 // wm_makemodal (hdlg) in other regions ); 37 // wm_setfocus (hdlg); 38 // wm_invalidatewindow (hdlg); 39 break; 40} 41} 42 default: 43 wm_defaultproc (PMSG ); 44} 45} 46 47 static void _ cbbkwindow (wm_message * PMSG) {// background window callback function 48 switch (PMSG-> msgid) {49 case wm_paint: 50 gui_setbkcolor (0x008000); 51 gui_setcolor (gui_white); 52 gui_setfont (& gui_font24_ascii ); 53 gui_clear (); 54 gui_dispstringhcenterat ("dialog_nestedmodal-sample", 160, 10); 55 default: 56 wm_defaultproc (PMSG); 57} 58} 59 60 void fun (void) {61 wm_hwin hwin; // handle 62 gui_init (); // initialize 63 gui_cursor_show (); // The mouse pointer shows 64/* 65. The default feature of the window manager is to send a wm_paint to each window to be repainted. This will lead to the flicker effect. To suppress the flickering effect of these 66 windows, storage devices can be automatically used for repainting operations. The method is to set wm_cf_memdev and 67 in the create window. Use the wm_setcreateflags () function to set the default create tag, or use the wm_enablememdev () function (). WM then 68 redirects the wm_paint message output to the storage device and then copies it to the display. If the memory of the entire window is insufficient, the segment is automatically used for 69. The storage device is only for temporary use and will be removed after the painting operation is complete. 70 */71 wm_setcreateflags (wm_cf_memdev); // It is used as the default marker 72 wm_enablememdev (wm_hbkwin) when a new window is created ); // enable the use of storage devices to redraw the window 73 wm_setcallback (wm_hbkwin, & _ cbbkwindow); // set the callback routine of the window, call the wm_paint message to initialize the background 74 // create a non-blocking dialog box 75 hwin = gui_createdialogbox (_ adialogorder, gui_countof (_ adialogorder), & _ cbdialogorder, wm_hbkwin, 0, 0 ); 76 while (1) {77 If (! Gui_exec () {78 gui_x_wait_event ();/* Wait for event (keyboard, mouse or whatever) */79} 80} 81}
[Ucgui] Dialog Box 4-mode message window