home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 93win / data1.cab / DLL_Toolkit / Source / HTBButton / ButtonDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-03-02  |  4.4 KB  |  177 lines

  1. // ButtonDlg.cpp : implementation file
  2. //    High Tech BASIC, Copyright (C) TransEra Corp 1999, All Rights Reserved.
  3.  
  4. #include "stdafx.h"
  5. #include "Button.h"
  6. #include "ButtonDlg.h"
  7. #include "export.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. #define BUTTONHEIGHT 25
  16. #define WIDTHADJUST 25
  17. #define STARTHEIGHT 370
  18. #define HEIGHTADJUST 30
  19.  
  20.  
  21. extern short g_BtnCount;                            // the number of buttons desired
  22. extern long g_Width;                                    // width of the dialog box
  23. extern OPTION g_Option;                                // 1 for modal, 2 for threaded variable update, 3 for threaded with signals
  24. extern CString g_Title;                                // Window title
  25. extern CString    g_Description;                        // Text above buttons will wrap to two lines if too long
  26. extern CString    g_Text[10];                            // button text
  27. extern short * g_pPress;                
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // ButtonDlg dialog
  31.  
  32.  
  33. ButtonDlg::ButtonDlg(CWnd* pParent /*=NULL*/)
  34.     : CDialog(ButtonDlg::IDD, pParent)
  35. {
  36.     //{{AFX_DATA_INIT(ButtonDlg)
  37.         // NOTE: the ClassWizard will add member initialization here
  38.     //}}AFX_DATA_INIT
  39. }
  40.  
  41. void ButtonDlg::DoDataExchange(CDataExchange* pDX)
  42. {
  43.     CDialog::DoDataExchange(pDX);
  44.     //{{AFX_DATA_MAP(ButtonDlg)
  45.     DDX_Control(pDX, IDC_BUTTON1, m_btn[0]);
  46.     DDX_Control(pDX, IDC_BUTTON2, m_btn[1]);
  47.     DDX_Control(pDX, IDC_BUTTON3, m_btn[2]);
  48.     DDX_Control(pDX, IDC_BUTTON4, m_btn[3]);
  49.     DDX_Control(pDX, IDC_BUTTON5, m_btn[4]);
  50.     DDX_Control(pDX, IDC_BUTTON6, m_btn[5]);
  51.     DDX_Control(pDX, IDC_BUTTON7, m_btn[6]);
  52.     DDX_Control(pDX, IDC_BUTTON8, m_btn[7]);
  53.     DDX_Control(pDX, IDC_BUTTON9, m_btn[8]);
  54.     DDX_Control(pDX, IDC_BUTTON10, m_btn[9]);
  55.     //}}AFX_DATA_MAP
  56. }
  57.  
  58.  
  59. BEGIN_MESSAGE_MAP(ButtonDlg, CDialog)
  60.     //{{AFX_MSG_MAP(ButtonDlg)
  61.     ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  62.     ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  63.     ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  64.     ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
  65.     ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
  66.     ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
  67.     ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
  68.     ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
  69.     ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
  70.     ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
  71.     ON_WM_CLOSE()
  72.     //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // ButtonDlg message handlers
  77.  
  78. BOOL ButtonDlg::OnInitDialog() 
  79. {
  80.     CDialog::OnInitDialog();
  81.     
  82.     SetWindowText(g_Title);                                    // set window title
  83.  
  84.     SetDlgItemText(IDC_TEXT0,g_Description);                // set static text control text
  85.     CWnd* pStaticText = GetDlgItem(IDC_TEXT0);                    // get pointer to static text control text
  86.     pStaticText->SetWindowPos(NULL,0,0,g_Width,BUTTONHEIGHT,SWP_NOZORDER | SWP_NOMOVE);    // set width of static text control
  87.     
  88.     long i;
  89.  
  90.     // Setup any used buttons
  91.     for (i = 0; i < g_BtnCount; i++)
  92.     {
  93.         m_btn[i].SetWindowText(g_Text[i]);                        // set button text
  94.         m_btn[i].SetWindowPos(NULL,0,0,g_Width,BUTTONHEIGHT,SWP_NOZORDER | SWP_NOMOVE);    // set button width
  95.     }
  96.  
  97.     // Destroy the remaining buttons if any...
  98.     for (i = g_BtnCount; i < MAXBUTTON; i++)
  99.     {
  100.         m_btn[i].DestroyWindow();
  101.     }
  102.  
  103.     // set window size
  104.     SetWindowPos(NULL,0,0,g_Width+WIDTHADJUST,STARTHEIGHT-((MAXBUTTON-g_BtnCount)*HEIGHTADJUST),SWP_NOZORDER );    
  105.  
  106.     SetForegroundWindow();
  107.  
  108.     return TRUE;  // return TRUE unless you set the focus to a control
  109.                   // EXCEPTION: OCX Property Pages should return FALSE
  110. }
  111.  
  112. void ButtonDlg::OnButton1() 
  113. {    UserAct(1);
  114. }
  115.  
  116. void ButtonDlg::OnButton10() 
  117. {    UserAct(10);    
  118. }
  119.  
  120. void ButtonDlg::OnButton2() 
  121. {    UserAct(2);        
  122. }
  123.  
  124. void ButtonDlg::OnButton3() 
  125. {    UserAct(3);        
  126. }
  127.  
  128. void ButtonDlg::OnButton4() 
  129. {    UserAct(4);        
  130. }
  131.  
  132. void ButtonDlg::OnButton5() 
  133. {    UserAct(5);        
  134. }
  135.  
  136. void ButtonDlg::OnButton6() 
  137. {    UserAct(6);        
  138. }
  139.  
  140. void ButtonDlg::OnButton7() 
  141. {    UserAct(7);    
  142. }
  143.  
  144. void ButtonDlg::OnButton8() 
  145. {    UserAct(8);        
  146. }
  147.  
  148. void ButtonDlg::OnButton9() 
  149. {    UserAct(9);
  150. }
  151.  
  152. void ButtonDlg::OnClose() 
  153. {    UserAct(0);    
  154.     
  155.     CDialog::OnClose();
  156. }
  157.  
  158.  
  159.  
  160. void ButtonDlg::UserAct(short select)
  161. {    *g_pPress = select;                            // set Basic memory to show input value (option    VARIABLE, but it is always done)
  162.  
  163.     switch (g_Option)
  164.     {    case modal:
  165.             EndDialog(select);                    // shut down modal dialog
  166.             break;
  167.  
  168.         case signal:
  169.             Signal(select);                        // set signal for SIGNAL option dialog
  170.             break;
  171.  
  172.         default:
  173.             break;
  174.     }    
  175.  
  176. }
  177.