• emwin之在WM_INIT_DIALOG分支下使用带触发功能的函数的程序框架


    @2018-08-29

    【小记】

    为避免在窗口创建时由于使用了带触发功能的函数导致执行一些在初始化过程中不允许的操作,特整理一个流程架构

    --①  定义一个初始化完成的标志

    unsigned char initComplete = 0;

    --②  回调函数

      >在初始化完毕后将完成标志置位,

      >在待触发位置 ‘&&’ 完成标志,以避免初始化过程中执行被触发的动作

      >在‘OK’或‘NO’按下退出时清除完成标志

     1 static void _cbDialog(WM_MESSAGE * pMsg)
     2 {
     3     switch (pMsg->MsgId)
     4     {
     5         case WM_INIT_DIALOG:
     6             hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
     7             DROPDOWN_SetSel(hItem,  1);
     8             ...
     9         
    10             initComplete = 1;
    11             break;
    12 
    13         case WM_NOTIFY_PARENT:
    14             switch(Id) 
    15             {
    16                 case ID_DROPDOWN_0: // Notifications sent by 'Local/Remote/timeTable'
    17                     switch(NCode) 
    18                     {
    19                         case WM_NOTIFICATION_CLICKED:
    20                         // USER START (Optionally insert code for reacting on notification message)
    21                         // USER END
    22                         break;
    23                         case WM_NOTIFICATION_RELEASED:
    24                         // USER START (Optionally insert code for reacting on notification message)
    25                         // USER END
    26                         break;
    27                         case WM_NOTIFICATION_SEL_CHANGED:
    28                         // USER START (Optionally insert code for reacting on notification message)
    29 
    30                         hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
    31 
    32                         if((2 == DROPDOWN_GetSel(hItem)) && initComplete)
    33                         {
    34                         CreatetimeTableFramewin();
    35                         }    
    36                     }
    37                         // USER END
    38                 break;
    39             
    40         case ID_BUTTON_1: // Notifications sent by 'OK'
    41             switch(NCode) 
    42             {
    43                 case WM_NOTIFICATION_CLICKED:
    44                 // USER START (Optionally insert code for reacting on notification message)
    45                 // USER END
    46                 break;
    47                 case WM_NOTIFICATION_RELEASED:
    48                 // USER START (Optionally insert code for reacting on notification message)      
    49                                 
    50                 initComplete = 0;
    51                                 
    52                 // USER END
    53                 break;
    54                 // USER START (Optionally insert additional code for further notification handling)
    55                 // USER END
    56                 }
    57             break;
    58                 
    59         case ID_BUTTON_2: // Notifications sent by 'Cancel'
    60             switch(NCode)
    61             {
    62                 case WM_NOTIFICATION_CLICKED:
    63                 // USER START (Optionally insert code for reacting on notification message)
    64                 // USER END
    65                 break;
    66                 case WM_NOTIFICATION_RELEASED:
    67                 // USER START (Optionally insert code for reacting on notification message)
    68                 
    69                 initComplete = 0;              
    70                 
    71                 // USER END
    72                 break;
    73                 // USER START (Optionally insert additional code for further notification handling)
    74                 // USER END
    75                 }
    76             break;    
    77         break;
    78 }
  • 相关阅读:
    day10 基本数据类型(下)
    day09 作业
    day09 基本数据类型(中)
    day08 作业
    day8 for循环+基本数据类型(上)
    Python正课109 —— 前端 进阶8
    Python正课108 —— 前端 进阶7
    Python正课107 —— 前端 进阶6
    Python正课106 —— 前端 进阶 5
    Python正课105 —— 前端 进阶4
  • 原文地址:https://www.cnblogs.com/skullboyer/p/9553551.html
Copyright © 2020-2023  润新知