home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / source / owlbwcc / bwrpoint.cpp < prev    next >
C/C++ Source or Header  |  1992-02-02  |  5KB  |  131 lines

  1. /**********************************************************************/
  2. /*                  BWRPOINT.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 2/2/92                  */
  4. /*          This program shows how to process radio buttons           */
  5. /*               using Pointers to the radio buttons.                 */
  6. /**********************************************************************/
  7. #include <owl.h>
  8. #include <dialog.h>
  9. #include "bwcc.h"                        // needed for BWCC
  10. #include "bradio.h"                      // needed for BWCC radio buttons
  11. #include "bwradely.h"                    // needed for equates
  12.  
  13. class TMyDialog : public TDialog
  14.   {
  15.   public:
  16.     TBRadioButton *pUnit12Test  , *pUnit12Phase1, // pointers to
  17.           *pUnit12Phase2, *pUnit12Phase3, // radio buttons
  18.           *pUnit13Test  , *pUnit13Phase1,
  19.           *pUnit13Phase2, *pUnit13Phase3;
  20.     TMyDialog(LPSTR lpDialogName);            // Constructor
  21.     virtual void Ok(RTMessage Msg);           // redefines the DDVT function
  22.                           // for the OK button #1
  23.                           // as defined in Base class
  24.                           // TDialog
  25.     virtual void DefChildProc(RTMessage Msg); // default button handler
  26.   };
  27.  
  28. void TMyDialog::TMyDialog(LPSTR lpDialogName) // constructor calls
  29.           : TDialog(NULL,lpDialogName)    // base class constructor
  30.   {
  31.   BWCCGetVersion();    // activate Borland Windows Custom Controls
  32.  
  33.   pUnit12Test   = new TBRadioButton(this,IDB_UNIT12_TEST,  NULL); //links up
  34.   pUnit12Phase1 = new TBRadioButton(this,IDB_UNIT12_PHASE1,NULL); //Radio
  35.   pUnit12Phase2 = new TBRadioButton(this,IDB_UNIT12_PHASE2,NULL); //Button
  36.   pUnit12Phase3 = new TBRadioButton(this,IDB_UNIT12_PHASE3,NULL); //Pointers
  37.   pUnit13Test   = new TBRadioButton(this,IDB_UNIT13_TEST,  NULL); //with
  38.   pUnit13Phase1 = new TBRadioButton(this,IDB_UNIT13_PHASE1,NULL); //Radio
  39.   pUnit13Phase2 = new TBRadioButton(this,IDB_UNIT13_PHASE2,NULL); //Buttons
  40.   pUnit13Phase3 = new TBRadioButton(this,IDB_UNIT13_PHASE3,NULL); //defined
  41.                                   //in .RC
  42.   }
  43.  
  44. void TMyDialog::Ok(RTMessage Msg)  // Redefines button handler inherited
  45.   {                                // from TDailog for Button #1 IDOK
  46.   char szMyString[180];
  47.  
  48.   if (pUnit12Test->GetCheck()==BF_CHECKED)           // find out the ON/OFF
  49.     {                                                // status
  50.     lstrcpy(szMyString,"Unit #12 is in Test Mode.\n");
  51.     }
  52.   else if (pUnit12Phase1->GetCheck()==BF_CHECKED)
  53.     {
  54.     lstrcpy(szMyString,"Unit #12 is in Phase 1 of Operation.\n");
  55.     }
  56.   else if (pUnit12Phase2->GetCheck()==BF_CHECKED)
  57.     {
  58.     lstrcpy(szMyString,"Unit #12 is in Phase 2 of Operation.\n");
  59.     }
  60.   else
  61.     {
  62.     lstrcpy(szMyString,"Unit #12 is in Phase 3 of Operation.\n");
  63.     }
  64.  
  65.   if (pUnit13Test->GetCheck()==BF_CHECKED)
  66.     {                                                   // status
  67.     lstrcat(szMyString,"Unit #13 is in Test Mode.\n");
  68.     }
  69.   else if (pUnit13Phase1->GetCheck()==BF_CHECKED)
  70.     {
  71.     lstrcat(szMyString,"Unit #13 is in Phase 1 of Operation.\n");
  72.     }
  73.   else if (pUnit13Phase2->GetCheck()==BF_CHECKED)
  74.     {
  75.     lstrcat(szMyString,"Unit #13 is in Phase 2 of Operation.\n");
  76.     }
  77.   else
  78.     {
  79.     lstrcat(szMyString,"Unit #13 is in Phase 3 of Operation.\n");
  80.     }
  81.  
  82.   BWCCMessageBox(HWindow,szMyString,"Update on Unit #12",MB_OK); //output
  83.                                  //status
  84.   TDialog::Ok(Msg);     //default OK handler to close dialog box
  85.   }
  86.  
  87. void TMyDialog::DefChildProc(RTMessage Msg)   // default button handler
  88.   {
  89.   if ((Msg.WParam >= IDB_UNIT12_TEST)&(Msg.WParam <= IDB_UNIT13_PHASE3))
  90.     {          // If a radio button is pressed then
  91.     TDialog::DefChildProc(Msg);  // pass message along to base class
  92.     }                            // to check the box
  93.   else
  94.     {
  95.     MessageBeep(0);                             // make sound and display
  96.     BWCCMessageBox(HWindow,"Not Implemented",   // a BWCC message box
  97.            "Feature",MB_OK);
  98.     TDialog::DefChildProc(Msg);                 // pass messages along
  99.     }                                           // to base class handler
  100.   }
  101.  
  102. class TDialog1App : public TApplication  // Application Class to contain
  103.   {                                      // the application
  104.   public:
  105.     TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  106.         HANDLE hPrevInstance,            // base class constructor
  107.         LPSTR lpCmdLine, int nCmdShow)
  108.         :TApplication(lpName, hInstance,
  109.                   hPrevInstance,
  110.                   lpCmdLine, nCmdShow) {};
  111.  
  112.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  113.   };
  114.  
  115. void TDialog1App::InitMainWindow() // to initialize a dialog box
  116.   {                                // as the main window
  117.   MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  118.   }
  119.  
  120. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  121.            HANDLE hPrevInstance,          // windows to this program
  122.            LPSTR lpCmdLine , int nCmdShow)
  123.   {
  124.   TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
  125.                hPrevInstance,             // the dialog application
  126.                lpCmdLine,nCmdShow);
  127.   Dialog1.Run();                                  // run it
  128.   return (Dialog1.Status);                        // exit
  129.   }
  130. /**********************************************************************/
  131.