home *** CD-ROM | disk | FTP | other *** search
- // RadiobuttonDlg.cpp : implementation file
- // High Tech BASIC, Copyright (C) TransEra Corp 1999, All Rights Reserved.
- //
- // Author: Sven Henze, Tech Soft GmbH (Germany)
- // Created: 22-Aug-1999
- // Last update: 28-Sep-1999
- //
-
- #include "stdafx.h"
- #include "Radiobutton.h"
- #include "RadiobuttonDlg.h"
- #include "export.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define BUTTONHEIGHT 21
- #define WIDTHADJUST 25
- #define STARTHEIGHT 370
- #define HEIGHTADJUST 30
-
-
- extern short g_BtnCount; // the number of radiobuttons 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 radiobuttons will wrap to two lines if too long
- extern CString g_Text[10]; // radiobutton text
- extern int m_Radio[10]; // radiobutton state
- extern short * g_pPress;
- char tmp[256];
- extern short save_pressed;
- extern CString g_grouptext;
-
- /////////////////////////////////////////////////////////////////////////////
- // RadioButtonDlg dialog
-
-
- RadioButtonDlg::RadioButtonDlg(CWnd* pParent /*=NULL*/)
- : CDialog(RadioButtonDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(RadioButtonDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
-
-
- int i;
-
- for ( i=0; i < g_BtnCount; i++)
- m_Radio[i] = 1; // resets radio buttons
-
-
- if ( (save_pressed <= 1) || (save_pressed > g_BtnCount) )
- {
- m_Radio[0] = 0;
- * g_pPress = 1;
- }
-
- for ( i=1; i < g_BtnCount; i++ )
- if ( save_pressed == i+1 ) m_Radio[i] = 0; // sets appropriate radiobutton
-
- }
-
- void RadioButtonDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(RadioButtonDlg)
- DDX_Control(pDX, IDC_RADIO1, m_btn[0]);
- DDX_Control(pDX, IDC_RADIO2, m_btn[1]);
- DDX_Control(pDX, IDC_RADIO3, m_btn[2]);
- DDX_Control(pDX, IDC_RADIO4, m_btn[3]);
- DDX_Control(pDX, IDC_RADIO5, m_btn[4]);
- DDX_Control(pDX, IDC_RADIO6, m_btn[5]);
- DDX_Control(pDX, IDC_RADIO7, m_btn[6]);
- DDX_Control(pDX, IDC_RADIO8, m_btn[7]);
- DDX_Control(pDX, IDC_RADIO9, m_btn[8]);
- DDX_Control(pDX, IDC_RADIO10, m_btn[9]);
- DDX_Radio(pDX, IDC_RADIO1, m_Radio[0]);
- DDX_Radio(pDX, IDC_RADIO2, m_Radio[1]);
- DDX_Radio(pDX, IDC_RADIO3, m_Radio[2]);
- DDX_Radio(pDX, IDC_RADIO4, m_Radio[3]);
- DDX_Radio(pDX, IDC_RADIO5, m_Radio[4]);
- DDX_Radio(pDX, IDC_RADIO6, m_Radio[5]);
- DDX_Radio(pDX, IDC_RADIO7, m_Radio[6]);
- DDX_Radio(pDX, IDC_RADIO8, m_Radio[7]);
- DDX_Radio(pDX, IDC_RADIO9, m_Radio[8]);
- DDX_Radio(pDX, IDC_RADIO10, m_Radio[9]);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(RadioButtonDlg, CDialog)
- //{{AFX_MSG_MAP(RadioButtonDlg)
- ON_BN_CLICKED(IDC_BUTTON13, OKPressed)
- ON_BN_CLICKED(IDC_BUTTON14, CancelPressed)
- ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
- ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
- ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
- ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
- ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
- ON_BN_CLICKED(IDC_RADIO6, OnRadio6)
- ON_BN_CLICKED(IDC_RADIO7, OnRadio7)
- ON_BN_CLICKED(IDC_RADIO8, OnRadio8)
- ON_BN_CLICKED(IDC_RADIO9, OnRadio9)
- ON_BN_CLICKED(IDC_RADIO10, OnRadio10)
- ON_WM_CLOSE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // RadioButtonDlg message handlers
-
- BOOL RadioButtonDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- SetWindowText(g_Title); // set window title
-
- SetDlgItemText(IDC_TEXT0,g_Description); // set static text control text
- SetDlgItemText(IDC_TEXT1,g_grouptext); // group 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
-
- CWnd* pStaticGText = GetDlgItem(IDC_TEXT1); // get pointer to static text control text
- pStaticGText->SetWindowPos(NULL,0,0,g_Width,24+BUTTONHEIGHT*g_BtnCount,SWP_NOZORDER | SWP_NOMOVE); // set width of static text control
-
- CWnd* pOKButton = GetDlgItem(IDC_BUTTON13); // get pointer to OK button
-
- CWnd* pCancelButton = GetDlgItem(IDC_BUTTON14); // get pointer to OK button
-
- // center the 'OK' and 'Cancel buttons
- pOKButton->SetWindowPos(NULL,(g_Width+WIDTHADJUST)/2-72,74+(BUTTONHEIGHT*g_BtnCount),60,23,SWP_NOZORDER); // set position of OK button
- pCancelButton->SetWindowPos(NULL,(g_Width+WIDTHADJUST)/2+3,74+(BUTTONHEIGHT*g_BtnCount),60,23,SWP_NOZORDER); // set position of Cancel button
-
-
- long i;
-
- // Setup any used radiobuttons
- for (i = 0; i < g_BtnCount; i++)
- {
- m_btn[i].SetWindowText(g_Text[i]); // set radiobutton text
- m_btn[i].SetWindowPos(NULL,0,0,g_Width-18,BUTTONHEIGHT,SWP_NOZORDER | SWP_NOMOVE); // set radiobutton width
- }
-
- // Destroy the remaining radiobuttons if any...
- for (i = g_BtnCount; i < MAXBUTTON; i++)
- {
- m_btn[i].DestroyWindow();
- }
-
-
- // set window size
- SetWindowPos(NULL,0,0,g_Width+WIDTHADJUST,135+(BUTTONHEIGHT*g_BtnCount),SWP_NOZORDER );
-
- SetForegroundWindow();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void RadioButtonDlg::OnRadio1()
- {
- * g_pPress = -1;
- UserAct(1);
- }
-
- void RadioButtonDlg::OnRadio2()
- {
- * g_pPress = -2;
- UserAct(2);
- }
-
- void RadioButtonDlg::OnRadio3()
- {
- * g_pPress = -3;
- UserAct(3);
- }
-
- void RadioButtonDlg::OnRadio4()
- {
- * g_pPress = -4;
- UserAct(4);
- }
-
- void RadioButtonDlg::OnRadio5()
- {
- * g_pPress = -5;
- UserAct(5);
- }
-
- void RadioButtonDlg::OnRadio6()
- {
- * g_pPress = -6;
- UserAct(6);
- }
-
- void RadioButtonDlg::OnRadio7()
- {
- * g_pPress = -7;
- UserAct(7);
- }
-
- void RadioButtonDlg::OnRadio8()
- {
- * g_pPress = -8;
- UserAct(8);
- }
-
- void RadioButtonDlg::OnRadio9()
- {
- * g_pPress = -9;
- UserAct(9);
- }
-
- void RadioButtonDlg::OnRadio10()
- {
- * g_pPress = -10;
- UserAct(10);
- }
-
- void RadioButtonDlg::OnClose()
- {
- CDialog::OnClose();
- }
-
-
-
- void RadioButtonDlg::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(0); // shut down modal dialog
- break;
-
- case signal:
- Signal(select); // set signal for SIGNAL option dialog
- break;
-
- default:
- break;
- }
-
- }
-
-
-
-
- void RadioButtonDlg::OKPressed()
- {
- short i;
-
- if (*g_pPress <0) * g_pPress=(-1)* *g_pPress;
-
- for (i=1; i<=10;i++) if (* g_pPress == i) UserAct(i);
-
- return;
-
- }
-
-
- void RadioButtonDlg::CancelPressed()
- {
-
- // insert some processing here
- * g_pPress = 0;
- EndDialog(0); // shut down dialog
-
- }
-