dllbridge

ProgressBar + WinLego

Jun 20th, 2022 (edited)
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.35 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. #include    "C:\\dllBridge\\WinLego\\Lego\\Lego.h"
  6. using namespace Lego;
  7.  
  8.  
  9. Button               btn[7];               //  На всякий случай, сразу 7 элементов (кнопок).  
  10. EditBox              edt[7];               //  EditBox тоже может пригодиться в будущем.
  11. ListBox              lbx[2];               //  ListBox  тоже на будущее...
  12. ProgressBar          prg[2];               //  ProgressBar  
  13.  
  14. char                sz[123];
  15.  
  16.  
  17. void       switching_to_mode__0();
  18. void       switching_to_mode__5();
  19. void       switching_to_minus_1();
  20. void                    mode__0();
  21. void                    mode__5();
  22. void                    minus_1();
  23.  
  24. /////////////////////////////////////////////   Эта функция инициализации. Она вызывается с помощью таймера №1
  25. void INIT()                                //   1 (единственный) раз, когда Timer_CLK == 1.
  26. {
  27.      
  28.      btn[1].Create("Press start", 500, 200, 100, 20);   //ProgressBar"
  29.      prg[1].Create(25, 200, 240, 20);
  30.      prg[1].Hide();    
  31. }
  32.  
  33.  
  34.  
  35.  
  36. ///////////////////////////////////////////////     Эта функция вызывается (с помощью таймера №2) 5 раз
  37. void START()                                 //     в секунду, когда Timer_CLK >= 2.                                                      
  38. {
  39.  
  40.  
  41.      switch(mode)
  42.      {
  43.  
  44.          case  -1:  minus_1(); break;        // -1 Режим меню 
  45.          case   0:  mode__0(); break;  
  46.          case   5:  mode__5(); break;                      
  47.            
  48.      }
  49. }
  50.  
  51.  
  52.  
  53.  
  54. /////////////////////////////////////////////////////////////////////////
  55. void    switching_to_mode__0()                                         //
  56. {
  57.    
  58.         out_of_previos(-1);     mode = 0;
  59.        
  60.         btn[1].Show();  
  61.    
  62. }
  63.  
  64.  
  65. /////////////////////////////////////////////////////////////////////////
  66. void    switching_to_mode__5()                                         //
  67. {
  68.    
  69.         out_of_previos(-1);     mode = 5;
  70.        
  71.         Print_2(30, 170, "A separate thread is running:");
  72.    
  73.         prg[1].Show();
  74. }
  75.  
  76.  
  77.  
  78.  
  79. /////////////////////////////////////////////////////////////////////////
  80. void    mode__0()                                                      //
  81. {
  82.    
  83.         if(btn[1].Press())  switching_to_mode__5();
  84.    
  85. }
  86.  
  87. /////////////////////////////////////////////////////////////////////////
  88. void    mode__5()                                                      //  
  89. {
  90.            
  91.         int res = prg[1].Step(1);
  92.  
  93.         if(res < 100)
  94.         {  
  95.            
  96.            wsprintf(sz, "%d %%", res);
  97.            Print_1(275, 202, sz);
  98.         }      
  99.         else   
  100.         {  
  101.            prg[1].Step(0);                  //  Position reset
  102.            switching_to_mode__0();                     
  103.         }      
  104. }
  105.  
  106.  
  107.  
  108. /////////////////////////////////////////////////////////////////////////// DestroyWindow(hProgBar);
  109. void  out_of_previos(int newMode)                                      //
  110. {
  111.    
  112.    
  113.       switch(mode)                                                     // oldMode
  114.       {
  115.  
  116.          case   0: btn[1].Hide();                              
  117.                    break;
  118.            
  119.          case   5: prg[1].Hide();
  120.                    Print_2( 30, 170,"                              ");  
  121.                    Print_1(275, 202,"                              ");                 
  122.                    break;
  123.       }
  124. }
  125.  
  126.  
Add Comment
Please, Sign In to add comment