/**********************************************************************/
/*                  BWRADELY.cpp by Bob Bourbonnais                   */
/*              released to the public domain 2/2/92                  */
/*          This program shows how to process radio buttons           */
/*         using the SendDlgItemMsg style of button processing.       */
/**********************************************************************/
#include <owl.h>
#include <dialog.h>
#include "bwcc.h"                        // needed for BWCC
#include "bwradely.h"

class TMyDialog : public TDialog
  {
  public:
    TMyDialog(LPSTR lpDialogName)          // constructor calls
      : TDialog(NULL,lpDialogName)         // base class constructor
      {
      BWCCGetVersion();    // activate Borland Windows Custom Controls
      }
    virtual void Ok(RTMessage Msg);        // redefines the DDVT function
					   // for the OK button #1
					   // as defined in Base class
					   // TDialog
    virtual void DefChildProc(RTMessage Msg); // default button handler
  };

void TMyDialog::Ok(RTMessage Msg)  // Redefines button handler inherited
  {                                // from TDailog for Button #1 IDOK
  char szMyString[180];

  if (SendDlgItemMsg(IDB_UNIT12_TEST,BM_GETCHECK,0,0))  // check on button
    {                                                   // status
    lstrcpy(szMyString,"Unit #12 is in Test Mode.\n");
    }
  else if (SendDlgItemMsg(IDB_UNIT12_PHASE1,BM_GETCHECK,0,0))
    {
    lstrcpy(szMyString,"Unit #12 is in Phase 1 of Operation.\n");
    }
  else if (SendDlgItemMsg(IDB_UNIT12_PHASE2,BM_GETCHECK,0,0))
    {
    lstrcpy(szMyString,"Unit #12 is in Phase 2 of Operation.\n");
    }
  else
    {
    lstrcpy(szMyString,"Unit #12 is in Phase 3 of Operation.\n");
    }

  if (SendDlgItemMsg(IDB_UNIT13_TEST,BM_GETCHECK,0,0))  // check on button
    {                                                   // status
    lstrcat(szMyString,"Unit #13 is in Test Mode.\n");
    }
  else if (SendDlgItemMsg(IDB_UNIT13_PHASE1,BM_GETCHECK,0,0))
    {
    lstrcat(szMyString,"Unit #13 is in Phase 1 of Operation.\n");
    }
  else if (SendDlgItemMsg(IDB_UNIT13_PHASE2,BM_GETCHECK,0,0))
    {
    lstrcat(szMyString,"Unit #13 is in Phase 2 of Operation.\n");
    }
  else
    {
    lstrcat(szMyString,"Unit #13 is in Phase 3 of Operation.\n");
    }

  BWCCMessageBox(HWindow,szMyString,"Update on Unit #12",MB_OK); //output
								 //status
  TDialog::Ok(Msg);     //default OK handler to close dialog box
  }

void TMyDialog::DefChildProc(RTMessage Msg)   // default button handler
  {
  if ((Msg.WParam >= IDB_UNIT12_TEST)&(Msg.WParam <= IDB_UNIT13_PHASE3))
    {          // If a radio button is pressed then
    TDialog::DefChildProc(Msg);  // pass message along to base class
    }                            // to check the box
  else
    {
    MessageBeep(0);                             // make sound and display
    BWCCMessageBox(HWindow,"Not Implemented",   // a BWCC message box
		   "Feature",MB_OK);
    TDialog::DefChildProc(Msg);                 // pass messages along
    }                                           // to base class handler
  }

class TDialog1App : public TApplication  // Application Class to contain
  {                                      // the application
  public:
    TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
		HANDLE hPrevInstance,            // base class constructor
		LPSTR lpCmdLine, int nCmdShow)
		:TApplication(lpName, hInstance,
			      hPrevInstance,
			      lpCmdLine, nCmdShow) {};

    virtual void InitMainWindow(); // overrides base class InitMainWindow
  };

void TDialog1App::InitMainWindow() // to initialize a dialog box
  {                                // as the main window
  MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  }

int PASCAL WinMain(HANDLE hInstance,              // main entry point from
		   HANDLE hPrevInstance,          // windows to this program
		   LPSTR lpCmdLine , int nCmdShow)
  {
  TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
		       hPrevInstance,             // the dialog application
		       lpCmdLine,nCmdShow);
  Dialog1.Run();                                  // run it
  return (Dialog1.Status);                        // exit
  }
/**********************************************************************/
