【emwin】CHECKBOX控件的通知代码的响应规则
@2018-08-28
【小记】
在 case WM_INIT_DIALOG: 中使用 CHECKBOX_SetState()函数改变了复选框状态,就会产生 WM_NOTIFICATION_VALUE_CHANGED 通知代码,则在 case WM_NOTIFY_PARENT: 中就会进入该分支
【调试记录】
下段代码的执行顺序 ①——⑤——②——⑥——③——⑦——④,这都是因使用了函数 CHECKBOX_SetState() 引起的
1 case WM_INIT_DIALOG: 2 // 3 // Initialization of 'opt1-Checkbox' 4 // 5 hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0); 6 CHECKBOX_SetText(hItem, ttEnable[ttEnableOpt1]); 7 CHECKBOX_SetFont(hItem, GUI_FONT_16B_1); 8 CHECKBOX_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FF0000)); 9 CHECKBOX_SetState(hItem, ttEnableOpt1); // --① 10 // 11 // Initialization of 'opt2-Checkbox' 12 // 13 hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1); 14 CHECKBOX_SetText(hItem, ttEnable[ttEnableOpt2]); 15 CHECKBOX_SetFont(hItem, GUI_FONT_16B_1); 16 CHECKBOX_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FF0000)); 17 CHECKBOX_SetState(hItem, ttEnableOpt2); // --② 18 // 19 // Initialization of 'opt3-Checkbox' 20 // 21 hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2); 22 CHECKBOX_SetText(hItem, ttEnable[ttEnableOpt3]); 23 CHECKBOX_SetFont(hItem, GUI_FONT_16B_1); 24 CHECKBOX_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FF0000)); 25 CHECKBOX_SetState(hItem, ttEnableOpt3); // --③ 26 // USER START (Optionally insert additional code for further widget initialization) 27 // --④ 28 WM_MakeModal(pMsg->hWin); 29 initFlag = 1; 30 31 // USER END 32 break; 33 34 case WM_NOTIFY_PARENT: 35 Id = WM_GetId(pMsg->hWinSrc); 36 NCode = pMsg->Data.v; 37 switch(Id) { 38 case ID_CHECKBOX_0: // Notifications sent by 'opt1-Checkbox' 39 switch(NCode) { 40 case WM_NOTIFICATION_CLICKED: 41 // USER START (Optionally insert code for reacting on notification message) 42 // USER END 43 break; 44 case WM_NOTIFICATION_RELEASED: 45 // USER START (Optionally insert code for reacting on notification message) 46 // USER END 47 break; 48 case WM_NOTIFICATION_VALUE_CHANGED: 49 // USER START (Optionally insert code for reacting on notification message) 50 // --⑤ 51 if(1 == initFlag) 52 { 53 ttEnableOpt1 = !ttEnableOpt1; 54 hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0); 55 CHECKBOX_SetText(hItem, ttEnable[ttEnableOpt1]); 56 } 57 58 // USER END 59 break; 60 // USER START (Optionally insert additional code for further notification handling) 61 // USER END 62 } 63 break; 64 case ID_CHECKBOX_1: // Notifications sent by 'opt2-Checkbox' 65 switch(NCode) { 66 case WM_NOTIFICATION_CLICKED: 67 // USER START (Optionally insert code for reacting on notification message) 68 // USER END 69 break; 70 case WM_NOTIFICATION_RELEASED: 71 // USER START (Optionally insert code for reacting on notification message) 72 // USER END 73 break; 74 case WM_NOTIFICATION_VALUE_CHANGED: 75 // USER START (Optionally insert code for reacting on notification message) 76 // --⑥ 77 if(1 == initFlag) 78 { 79 ttEnableOpt2 = !ttEnableOpt2; 80 hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1); 81 CHECKBOX_SetText(hItem, ttEnable[ttEnableOpt2]); 82 } 83 84 // USER END 85 break; 86 // USER START (Optionally insert additional code for further notification handling) 87 // USER END 88 } 89 break; 90 case ID_CHECKBOX_2: // Notifications sent by 'opt3-Checkbox' 91 switch(NCode) { 92 case WM_NOTIFICATION_CLICKED: 93 // USER START (Optionally insert code for reacting on notification message) 94 // USER END 95 break; 96 case WM_NOTIFICATION_RELEASED: 97 // USER START (Optionally insert code for reacting on notification message) 98 // USER END 99 break; 100 case WM_NOTIFICATION_VALUE_CHANGED: 101 // USER START (Optionally insert code for reacting on notification message) 102 // --⑦ 103 if(1 == initFlag) 104 { 105 ttEnableOpt3 = !ttEnableOpt3; 106 hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2); 107 CHECKBOX_SetText(hItem, ttEnable[ttEnableOpt3]); 108 } 109 110 // USER END 111 break; 112 // USER START (Optionally insert additional code for further notification handling) 113 // USER END 114 } 115 break; 116 // USER START (Optionally insert additional code for further Ids) 117 // USER END 118 } 119 break;
再牛逼的梦想也架不住傻逼似的坚持