home *** CD-ROM | disk | FTP | other *** search
- // Microworks ObjectMate 2.6
- //
- // MultiDlg - Multiple Dialog Demonstration
- //
- // Copyright 1992-94 Microworks Sydney, Australia.
- //
- // MULTIDLG.CPP
-
- /* MultiDlg creates a notebook style multiple dialog using child dialogs and
- * a radio button style SFX toolbar. It's an easy and more stylish alternative
- * to tabbed multiple dialogs. In the resource file multidlg.res there are two
- * dialog templates: MULTIDLG and MULTIDLGC. MULTDLG is the Pascal template and
- * MULTIDLGC is the C++ 4.0 template. This demonstration sets up the multiple
- * dialog as a dialog window.
- */
-
- #define ID_DLG1 1
- #define ID_DLG2 2
- #define ID_DLG3 3
- #define ID_DLG4 4
- #define ID_DLG5 5
- #define ID_SHADE 101
- #define ID_TOOLBAR 102
- #define ID_BUT1 301
- #define ID_BUT2 302
- #define ID_BUT3 303
- #define ID_BUT4 304
- #define ID_BUT5 305
- #define ID_ABOUT 306
- #define APPNAME "MULTIDLG"
-
- #include <owl\owlpch.h>
- #include <sfx\sfx200.h>
- #include <sfx\sframe.h>
- #include <sfx\stoolbar.h>
- #include <sfx\sshade.h>
- #include <sfx\smenu.h>
-
- // TChildDlg class
-
- class TChildDlg : public TDialog
- {
- public:
- TChildDlg(TWindow*, TResId);
- void CmOk();
- void CmCancel();
- DECLARE_RESPONSE_TABLE(TChildDlg);
- };
-
- DEFINE_RESPONSE_TABLE1(TChildDlg, TDialog)
- EV_CHILD_NOTIFY(IDOK, BN_CLICKED, CmOk),
- EV_CHILD_NOTIFY(IDCANCEL, BN_CLICKED, CmCancel),
- END_RESPONSE_TABLE;
-
- TChildDlg::TChildDlg(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- }
-
- void
- TChildDlg::CmOk()
- {
- ForwardMessage(Parent->HWindow);
- }
-
- void
- TChildDlg::CmCancel()
- {
- ForwardMessage(Parent->HWindow);
- }
-
- // TMultiDlg class
-
- class TMultiDlg : public TDialog {
- public:
- TChildDlg* NextDlg;
- TChildDlg* PrevDlg;
- TSFXShade* Shade;
- TSFXToolbar* Toolbar;
- TMultiDlg();
- virtual char far* GetClassName();
- void SetupWindow();
- void CreateChildDialog(int dialogId, const char* title);
- void CmOk();
- void CmCancel();
- void IdBut1();
- void IdBut2();
- void IdBut3();
- void IdBut4();
- void IdBut5();
- DECLARE_RESPONSE_TABLE(TMultiDlg);
- };
-
- DEFINE_RESPONSE_TABLE1(TMultiDlg, TDialog)
- EV_COMMAND(ID_BUT1, IdBut1),
- EV_COMMAND(ID_BUT2, IdBut2),
- EV_COMMAND(ID_BUT3, IdBut3),
- EV_COMMAND(ID_BUT4, IdBut4),
- EV_COMMAND(ID_BUT5, IdBut5),
- EV_CHILD_NOTIFY(IDOK, BN_CLICKED, CmOk),
- EV_CHILD_NOTIFY(IDCANCEL, BN_CLICKED, CmCancel),
- END_RESPONSE_TABLE;
-
- TMultiDlg::TMultiDlg()
- : TWindow((TWindow*)0),
- TDialog(0, "MULTIDLGC")
- {
- Shade = new TSFXShade(this, ID_SHADE);
- Toolbar = new TSFXToolbar(this, ID_TOOLBAR);
- NextDlg = 0;
- PrevDlg = 0;
- }
-
- char far*
- TMultiDlg::GetClassName()
- {
- return "SFXDLG";
- }
-
- void
- TMultiDlg::SetupWindow()
- {
- TDialog::SetupWindow();
- IdBut1();
- Toolbar->CheckTool(ID_BUT1);
- if (GetSystemMetrics(SM_CYSIZE) == 26)
- {
- TRect rect;
- GetWindowRect(rect);
- rect.right -= 22;
- SetWindowPos(0, rect, SWP_NOZORDER | SWP_NOMOVE);
- ::ShowWindow(GetDlgItem(IDCANCEL), SW_SHOW);
- }
- }
-
- void
- TMultiDlg::CreateChildDialog(int dialogId, const char* title)
- {
- PrevDlg = NextDlg;
- NextDlg = new TChildDlg(this, MAKEINTRESOURCE(dialogId));
- NextDlg->Create();
- NextDlg->SetWindowPos(HWND_TOP, 33, 50, 0, 0, SWP_NOSIZE);
- Shade->SetWindowText(title);
- NextDlg->Show(SW_NORMAL);
- if (PrevDlg != 0 && PrevDlg->HWindow != 0)
- DestroyWindow(PrevDlg->HWindow);
- }
-
- void
- TMultiDlg::CmOk()
- {
- Parent->CloseWindow();
- }
-
- void
- TMultiDlg::CmCancel()
- {
- Parent->CloseWindow();
- }
-
- void
- TMultiDlg::IdBut1()
- {
- CreateChildDialog(ID_DLG1, " Edit Controls...");
- }
-
- void
- TMultiDlg::IdBut2()
- {
- CreateChildDialog(ID_DLG2, " List Boxes...");
- }
-
- void
- TMultiDlg::IdBut3()
- {
- CreateChildDialog(ID_DLG3, " Combo Boxes...");
- }
-
- void
- TMultiDlg::IdBut4()
- {
- CreateChildDialog(ID_DLG4, " Check Boxes...");
- }
-
- void
- TMultiDlg::IdBut5()
- {
- CreateChildDialog(ID_DLG5, " Radio Buttons...");
- }
-
- // TDialogFrame class
-
- class TDialogFrame : public TSFXFrameWindow {
- public:
- TDialogFrame(TWindow*, const char*, TWindow*);
- virtual char far* GetClassName();
- void SetupWindow();
- void EvDrawItem(UINT, DRAWITEMSTRUCT far&);
- void EvMeasureItem(UINT, MEASUREITEMSTRUCT far&);
- LRESULT EvMenuChar(WPARAM, LPARAM);
- DECLARE_RESPONSE_TABLE(TDialogFrame);
- };
-
- DEFINE_RESPONSE_TABLE2(TDialogFrame, TSFXFrameWindow, TFrameWindow)
- EV_WM_DRAWITEM,
- EV_WM_MEASUREITEM,
- EV_MESSAGE(WM_MENUCHAR, EvMenuChar),
- END_RESPONSE_TABLE;
-
- TDialogFrame::TDialogFrame(TWindow* parent, const char* title, TWindow* dialog)
- :TSFXFrameWindow(parent, title, dialog, TRUE),
- TFrameWindow(parent, title, dialog, TRUE),
- TWindow(parent, title)
- {
- Attr.Style |= MWS_SFXFRAME | MWS_SFXCAPTION;
- }
-
- char far*
- TDialogFrame::GetClassName()
- {
- return APPNAME;
- }
-
- void
- TDialogFrame::SetupWindow()
- {
- TFrameWindow::SetupWindow();
- Set3DSystemMenu(HWindow, "MultiDlg");
- CenterWindow(0, HWindow);
- }
-
- void
- TDialogFrame::EvDrawItem(UINT /*ctlId*/, DRAWITEMSTRUCT far& drawinfo)
- {
- if (drawinfo.CtlType == ODT_MENU)
- DrawMenuItem(drawinfo);
- }
-
- void
- TDialogFrame::EvMeasureItem(UINT /*ctlId*/, MEASUREITEMSTRUCT far& measureinfo)
- {
- if (measureinfo.CtlType == ODT_MENU)
- MeasureMenuItem(HWindow, measureinfo);
- }
-
- LRESULT
- TDialogFrame::EvMenuChar(WPARAM wParam, LPARAM lParam)
- {
- if (LOWORD(lParam) & MF_SYSMENU)
- return ProcessSystemChar(wParam);
- else
- return 0L;
- }
-
- // TDialogApp
-
- class TDialogApp : public TApplication {
- public:
- TDialogApp(const char far* name) : TApplication(name) {}
- void InitMainWindow();
- };
-
- void
- TDialogApp::InitMainWindow()
- {
- TWindow* client = new TMultiDlg();
- MainWindow = new TDialogFrame(0, "MultiDlg - Multiple Dialog Demonstration", client);
- MainWindow->SetIcon(this, APPNAME);
- MainWindow->Attr.Style &= ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX);
- }
-
- // OwlMain
-
- int
- OwlMain(int /*argc*/, char* /*argv*/ [])
- {
- return TDialogApp("MultiDlg - Multiple Dilaog Demonstration").Run();
- }
-