emwin的WM_PAINT

 1 //界面实现
 2 static void _cbDummy(WM_MESSAGE* pMsg){
 3     int Id, NCode;
 4     int hour, min, second, tim;
 5     WM_HWIN hWin;
 6     char temp[4], temp1[4];
 7     char tim_t[10];
 8     hWin = pMsg->hWin;
 9 //    create_basePage(); 
10     switch (pMsg->MsgId) {
11       case WM_CREATE:
12         WM_CreateTimer(hWin, 0 , 1000 , 0 );
 13 is          BREAK ;
 14        Case the WM_TIMER:
 15          WM_RestartTimer (pMsg-> Data.v, 1000 );
 16          // time format conversion 
. 17          BREAK ;
 18 is        Case the WM_PAINT:
 . 19          create_basePage ();   // every time redraw the background and the title 
20 is          BREAK ;
 21 is  
22 is        Case WM_NOTIFY_PARENT:
 23 is          Id = WM_GetId (pMsg-> hWinSrc);
 24          the NCode = pMsg-> Data.v;
 25          Switch(Id) {
26         case ID_BUTTON_0:  //设置
27             switch(NCode) {
28               case WM_NOTIFICATION_CLICKED:
29                 break;
30               case WM_NOTIFICATION_RELEASED:
31                   if(controlSet==0) {
32                     controlSet = 1;
33                     BUTTON_SetText(setbutton, Font_Back);
34                     //BUTTON_SetText(setbutton, "返回");
35                     hWinSet1 = CreateSetWindow();
36                     BUTTON_SetBitmapEx(setbutton, BUTTON_BI_UNPRESSED, &bmstart1, 32, 2);
37                   }else {
38                     controlSet = 0;
39                     BUTTON_SetText(setbutton, Font_Set);
40                     //BUTTON_SetText(setbutton, "设置");
41                     WM_DeleteWindow(hWinSet1);
42                     BUTTON_SetBitmapEx(setbutton, BUTTON_BI_UNPRESSED, &bmstart, 32, 2);
43                   }
44                 break;
45             }
46             break;
47 
48          case ID_BUTTON_1:  //启动/停止
49             switch(NCode) {
50               case WM_NOTIFICATION_CLICKED:
51                 break;
52               case WM_NOTIFICATION_RELEASED:
53                 if(startOrStop==0){
54                     startOrStop = 1;
55                     printf("start\n");
56                 }else {
57                     startOrStop = 0;
58                     printf("stop\n");
59                 }
60                 invalidStartButton(hWin);
61                 break;
62             }
63             break;
64         }
65         break;
66 
67     default:
68         WM_DefaultProc(pMsg);
69         break;
70     }
71 }
72 
73 
74 WM_HWIN CreateWindow(void ) {
 75      // get_gif (); // display the boot animation 
76      BUTTON_SetDefaultSkinClassic (); // use the classic skin 
77      hWinBase WM_CreateWindow = ( 0 ,   0 , 480 , 320. , WM_CF_SHOW, _cbDummy, 0 );
 78      return hWinBase;
 79 }

emwin create their own window, and all interfaces are placed below WM_PAINT, Timer, always stuck, could not find the reason, last finding may be out of memory, the cause is found

create_basePage (); // redraw every background and title

Every time redraw the entire page and then no clear cause of insufficient memory, constantly try to find create_basePage (); WM_PAINT placed outside, can not draw a rectangle to set the background color, and the button listeners also a problem,

Finally only rewrite, after finished, WM_PAINT only need to place a rectangle, you need to be repainted control function can be achieved, and it will not have enough memory to learn a lesson!

Case the WM_PAINT: 
    GUI_Clear (); 
    GUI_DrawGradientV ( 0 , 0 , LCD_GetXSize (), LCD_GetYSize (), GUI_LIGHTGREEN, 0x71B33C );   // Gradient Hatch 
    GUI_SetPenSize ( . 1 ); // brush pixel. 1 
    GUI_SetColor (GUI_BLACK);   // brush color black 
    GUI_DrawRect ( 1 , 1 , 388 , 52 ); // draw a rectangle 

    // draw border 
    GUI_DrawRect ( 388 , 70 , 478 , 250 ); 

    // alarm bar
    GUI_DrawRect ( 388 , 125 , 478 , 184 ); 

    // frequency display column 
    GUI_DrawRect ( . 1 , 52 is , 388 , 270 ); 

    // data display field 
    GUI_DrawRect ( . 1 , 270 , 388 , 318 ); 

    // data columns 
    GUI_DrawRect ( 126 , 270 , 252 , 318 ); 

    // Videos start block
     // GUI_DrawRect (388, 220, 479, 319); 

    // redraw
    //重绘倒计时
    if(strlen(time_buffer)==0 || !strcmp(time_buffer, "00:00:00")){
        TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_7), "00:00:00");
    }else {
        controlTime = 1;
        TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_7), time_buffer);
    }

 

Guess you like

Origin www.cnblogs.com/ys77/p/11627795.html