Advertisement
dllbridge

mode & ProgressBar in WinLego

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