home *** CD-ROM | disk | FTP | other *** search
- // ButtonDlg.cpp : implementation file
- // High Tech BASIC, Copyright (C) TransEra Corp 1999, All Rights Reserved.
-
- #include "stdafx.h"
- #include "Button.h"
- #include "ButtonDlg.h"
- #include "export.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define BUTTONHEIGHT 25
- #define WIDTHADJUST 25
- #define STARTHEIGHT 370
- #define HEIGHTADJUST 30
-
-
- extern short g_BtnCount; // the number of buttons desired
- extern long g_Width; // width of the dialog box
- extern OPTION g_Option; // 1 for modal, 2 for threaded variable update, 3 for threaded with signals
- extern CString g_Title; // Window title
- extern CString g_Description; // Text above buttons will wrap to two lines if too long
- extern CString g_Text[10]; // button text
- extern short * g_pPress;
-
- /////////////////////////////////////////////////////////////////////////////
- // ButtonDlg dialog
-
-
- ButtonDlg::ButtonDlg(CWnd* pParent /*=NULL*/)
- : CDialog(ButtonDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(ButtonDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
-
- void ButtonDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(ButtonDlg)
- DDX_Control(pDX, IDC_BUTTON1, m_btn[0]);
- DDX_Control(pDX, IDC_BUTTON2, m_btn[1]);
- DDX_Control(pDX, IDC_BUTTON3, m_btn[2]);
- DDX_Control(pDX, IDC_BUTTON4, m_btn[3]);
- DDX_Control(pDX, IDC_BUTTON5, m_btn[4]);
- DDX_Control(pDX, IDC_BUTTON6, m_btn[5]);
- DDX_Control(pDX, IDC_BUTTON7, m_btn[6]);
- DDX_Control(pDX, IDC_BUTTON8, m_btn[7]);
- DDX_Control(pDX, IDC_BUTTON9, m_btn[8]);
- DDX_Control(pDX, IDC_BUTTON10, m_btn[9]);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(ButtonDlg, CDialog)
- //{{AFX_MSG_MAP(ButtonDlg)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
- ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
- ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
- ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
- ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
- ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
- ON_WM_CLOSE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // ButtonDlg message handlers
-
- BOOL ButtonDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- SetWindowText(g_Title); // set window title
-
- SetDlgItemText(IDC_TEXT0,g_Description); // set static text control text
- CWnd* pStaticText = GetDlgItem(IDC_TEXT0); // get pointer to static text control text
- pStaticText->SetWindowPos(NULL,0,0,g_Width,BUTTONHEIGHT,SWP_NOZORDER | SWP_NOMOVE); // set width of static text control
-
- long i;
-
- // Setup any used buttons
- for (i = 0; i < g_BtnCount; i++)
- {
- m_btn[i].SetWindowText(g_Text[i]); // set button text
- m_btn[i].SetWindowPos(NULL,0,0,g_Width,BUTTONHEIGHT,SWP_NOZORDER | SWP_NOMOVE); // set button width
- }
-
- // Destroy the remaining buttons if any...
- for (i = g_BtnCount; i < MAXBUTTON; i++)
- {
- m_btn[i].DestroyWindow();
- }
-
- // set window size
- SetWindowPos(NULL,0,0,g_Width+WIDTHADJUST,STARTHEIGHT-((MAXBUTTON-g_BtnCount)*HEIGHTADJUST),SWP_NOZORDER );
-
- SetForegroundWindow();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void ButtonDlg::OnButton1()
- { UserAct(1);
- }
-
- void ButtonDlg::OnButton10()
- { UserAct(10);
- }
-
- void ButtonDlg::OnButton2()
- { UserAct(2);
- }
-
- void ButtonDlg::OnButton3()
- { UserAct(3);
- }
-
- void ButtonDlg::OnButton4()
- { UserAct(4);
- }
-
- void ButtonDlg::OnButton5()
- { UserAct(5);
- }
-
- void ButtonDlg::OnButton6()
- { UserAct(6);
- }
-
- void ButtonDlg::OnButton7()
- { UserAct(7);
- }
-
- void ButtonDlg::OnButton8()
- { UserAct(8);
- }
-
- void ButtonDlg::OnButton9()
- { UserAct(9);
- }
-
- void ButtonDlg::OnClose()
- { UserAct(0);
-
- CDialog::OnClose();
- }
-
-
-
- void ButtonDlg::UserAct(short select)
- { *g_pPress = select; // set Basic memory to show input value (option VARIABLE, but it is always done)
-
- switch (g_Option)
- { case modal:
- EndDialog(select); // shut down modal dialog
- break;
-
- case signal:
- Signal(select); // set signal for SIGNAL option dialog
- break;
-
- default:
- break;
- }
-
- }
-