home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-06 | 63.0 KB | 2,317 lines |
- // Microworks ObjectMate 2.6
- //
- // "Object Viewer"
- //
- // Copyright 1992-94 Microworks Sydney, Australia.
- //
- // SFXVIEW.CPP
-
- #define APPNAME "SFXVIEW"
-
- #include <owl\owlpch.h>
- #include <sfx\sfx200.h>
- #include <sfx\sframe.h>
- #include <sfx\stoolbar.h>
- #include <sfx\sstatic.h>
- #include <sfx\smenu.h>
- #include <owl\opensave.h>
- #include <owl\printdia.h>
- #include <owl\findrepl.h>
- #include <owl\chooseco.h>
- #include <owl\choosefo.h>
- #include <dir.h>
- #include "sfxview.h"
-
- // Global variables
-
- BOOL UseHints;
- char Class[25];
- int Tool;
- UINT Style;
-
- // Custom color array for TChooseColorDialog
-
- static TColor custColors[16] =
- {
- 0x219369L, 0x2F31D5L, 0x28A207L, 0x373399L,
- 0x49F470L, 0x56B500L, 0x6666FFL, 0x737700L,
- 0x824800L, 0x976900L, 0xA19A00L, 0xBBFB00L,
- 0xCD9C00L, 0xD3CD00L, 0xE8FE00L, 0xFA3F00L
- };
-
- // TDefaultDialog
-
- class TDefaultDialog : public TDialog
- {
- public:
- TDefaultDialog(TWindow*, TResId);
- void SetupWindow();
- DECLARE_RESPONSE_TABLE(TDefaultDialog);
- };
-
- DEFINE_RESPONSE_TABLE1(TDefaultDialog, TDialog)
- END_RESPONSE_TABLE;
-
- TDefaultDialog::TDefaultDialog(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- }
-
- void
- TDefaultDialog::SetupWindow()
- {
- TDialog::SetupWindow();
-
- /* CenterWindow centers HWindow over the desktop window if the (first)
- * parent window argument to zero.
- */
- CenterWindow(0, HWindow);
- }
-
- // TChildDialog
-
- class TChildDialog : public TDialog
- {
- public:
- TChildDialog(TWindow*, TResId);
- void SetupWindow();
- void CmOk();
- void CmCancel();
- DECLARE_RESPONSE_TABLE(TChildDialog);
- };
-
- DEFINE_RESPONSE_TABLE1(TChildDialog, TDialog)
- EV_CHILD_NOTIFY(IDOK, BN_CLICKED, CmOk),
- EV_CHILD_NOTIFY(IDCANCEL, BN_CLICKED, CmCancel),
- END_RESPONSE_TABLE;
-
- TChildDialog::TChildDialog(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- }
-
- void
- TChildDialog::SetupWindow()
- {
- TDialog::SetupWindow();
-
- /* Adding 'MWS_SFXCAPTION' to the style flags forces the dialog to display a
- * Chicago-style caption, like the Object Viewer main window. Since this dialog
- * doesn't have a class icon, the main window's class icon appears in the title
- * bar. Both the caption and icon are displayed flush left. You can set the icon
- * displayed on the title bar by sending the dialog a WM_SETBITMAP message.
- */
- SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
- CenterWindow(0, HWindow);
-
- /* To be neat and tidy, when I display a dialog box from within another
- * dialog box I like to hide the parent dialog, show the child dialog,
- * and then redisplay the parent dialog when the child dialog closes.
- */
- Parent->ShowWindow(SW_HIDE);
- }
-
- void
- TChildDialog::CmOk()
- {
- TDialog::CmOk();
- Parent->ShowWindow(SW_NORMAL);
- }
-
- void
- TChildDialog::CmCancel()
- {
- TDialog::CmCancel();
- Parent->ShowWindow(SW_NORMAL);
- }
-
- // TButtonDialog
-
- class TButtonDialog : public TDialog
- {
- public:
- TButtonDialog(TWindow*, TResId);
- void SetupWindow();
- void CmStdBtn();
- void CmBitBtn();
- void CmTextBtn();
- DECLARE_RESPONSE_TABLE(TButtonDialog);
- };
-
- DEFINE_RESPONSE_TABLE1(TButtonDialog, TDialog)
- EV_CHILD_NOTIFY(IDSTDBTN, BN_CLICKED, CmStdBtn),
- EV_CHILD_NOTIFY(IDBITBTN, BN_CLICKED, CmBitBtn),
- EV_CHILD_NOTIFY(IDTEXTBTN, BN_CLICKED, CmTextBtn),
- END_RESPONSE_TABLE;
-
- TButtonDialog::TButtonDialog(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- }
-
- void
- TButtonDialog::SetupWindow()
- {
- TDialog::SetupWindow();
- SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
- CenterWindow(0, HWindow);
- }
-
- void
- TButtonDialog::CmStdBtn()
- {
- TChildDialog(this, "StandardButtonDialog").Execute();
- }
-
- void
- TButtonDialog::CmBitBtn()
- {
- TChildDialog(this, "BitmapButtonDialog").Execute();
- }
-
- void
- TButtonDialog::CmTextBtn()
- {
- TChildDialog(this, "TextButtonDialog").Execute();
- }
-
- // TStaticDialog
-
- class TStaticDialog : public TDialog
- {
- public:
- TStaticDialog(TWindow*, TResId);
- void SetupWindow();
- void CmStatBmp();
- void CmStatText();
- DECLARE_RESPONSE_TABLE(TStaticDialog);
- };
-
- DEFINE_RESPONSE_TABLE1(TStaticDialog, TDialog)
- EV_CHILD_NOTIFY(IDSTATBMP, BN_CLICKED, CmStatBmp),
- EV_CHILD_NOTIFY(IDSTATTEXT, BN_CLICKED, CmStatText),
- END_RESPONSE_TABLE;
-
- TStaticDialog::TStaticDialog(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- }
-
- void
- TStaticDialog::SetupWindow()
- {
- TDialog::SetupWindow();
- SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
- CenterWindow(0, HWindow);
- }
-
- void
- TStaticDialog::CmStatBmp()
- {
- TChildDialog(this, "BitmapAlignmentDialog").Execute();
- }
-
- void
- TStaticDialog::CmStatText()
- {
- TChildDialog(this, "TextAlignmentDialog").Execute();
- }
-
- // TControlDialog
-
- class TControlDialog : public TDialog
- {
- public:
- TControlDialog(TWindow*, TResId);
- ~TControlDialog();
- int i;
- void SetupWindow();
- void EvTimer(UINT /*timerId*/);
- LRESULT EvSFXCtlColor(WPARAM, LPARAM);
- DECLARE_RESPONSE_TABLE(TControlDialog);
- };
-
- DEFINE_RESPONSE_TABLE1(TControlDialog, TDialog)
- EV_WM_TIMER,
- EV_MESSAGE(WM_SFXCTLCOLOR, EvSFXCtlColor),
- END_RESPONSE_TABLE;
-
- TControlDialog::TControlDialog(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- }
-
- TControlDialog::~TControlDialog()
- {
- KillTimer(IDTIMER);
- }
-
- void
- TControlDialog::SetupWindow()
- {
- TDialog::SetupWindow();
- SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
- CenterWindow(0, HWindow);
-
- /* For display purposes, this timer sets the rate at which the percent
- * gauge is updated.
- */
- SetTimer(IDTIMER, 500);
- i = 0;
- }
-
- void
- TControlDialog::EvTimer(UINT /*timerId*/)
- {
- i++;
- if (i <= 100)
- {
- /* WM_DRAWPERCENT is a private messge that you send to a percent gauge
- * when you want to update the percentage displayed. wParam is the percentage
- * to draw and must be a value between 0% and 100%. A value of 100% draws
- * a full percent gauge. lParam is zero. The return value is 1 when the
- * gauge reaches 100%. Otherwise its zero. When you derive an object for a
- * percent gauge from TSFXPercent (defined in SPERCENT.H) you can use its
- *'SetPercent' and 'Reset' member functions instead of sending these messages.
- */
- if (::SendMessage(GetDlgItem(109), WM_DRAWPERCENT, i, 0) == 1)
- {
- // WM_RESETPERCENT resets the percentage displayed to zero
- ::SendMessage(GetDlgItem(109), WM_RESETPERCENT, 0, 0);
- i = 0;
- }
- if (::SendMessage(GetDlgItem(110), WM_DRAWPERCENT, i*2, 0) == 1)
- {
- ::SendMessage(GetDlgItem(110), WM_RESETPERCENT, 0, 0);
- }
- }
- }
-
- LRESULT
- TControlDialog::EvSFXCtlColor(WPARAM hdc, LPARAM lParam)
- {
- /* An SFX control sends this message to its parent when its about to be painted.
- * WM_SFXCTLCOLOR can be used to set the colors in various controls. There
- * are 8 SFXCTLCOLOR_XXX constants defined for this message. You cannot use
- * the return value to pass a brush or pen handle like WM_CTLCOLOR. Instead you
- * must send a private message back to the control - eg WM_SETBRUSH, WM_SETPEN.
- * The message you need to send depends on the control. For this control (SFXPercent)
- * you need to send a WM_SETBRUSH message if you want to change the percent
- * gauge background color. The text colors that look the best have been
- * assigned bit flags. For other colors you will need to use the SetTextColor
- * function to set the percent gauge text color.
- *
- * WM_SFXCTLCOLOR's parameters are the same as WM_CTLCOLOR's. wParam
- * is the display context for the control, LOWORD of lParam is its window handle
- * and HIWORD of lParam is the control identifier. For SFXPercent, this identifier
- * is SFXCTLCOLOR_PERCENT.
- */
- if (HIWORD(lParam) == SFXCTLCOLOR_PERCENT)
- {
- ::SetBkMode((HDC)hdc, TRANSPARENT);
-
- if (::GetDlgCtrlID((HWND)LOWORD(lParam)) == 109)
- ::SetTextColor((HDC)hdc, RGB(0, 0, 255));
- else
- ::SetTextColor((HDC)hdc, RGB(0, 255, 0));
-
- /* GetSFXObject is defined in the SFX200.H. Here its used to retrieve
- * a handle to the 'stock' red brush. Do not delete this handle!
- */
- if (::GetDlgCtrlID((HWND)LOWORD(lParam)) == 110)
- ::SendMessage((HWND)LOWORD(lParam), WM_SETBRUSH, (UINT)GetSFXObject(RED_BRUSH), 0);
- }
- return 0;
- }
-
- // TPopupToolbar
-
- class TPopupToolbar : public TSFXToolbar
- {
- public:
- TPopupToolbar(TWindow*, int, const char far*, int, int, BOOL);
- BOOL EvNCActivate(BOOL);
- virtual LRESULT EvCommand(UINT, HWND, UINT);
- DECLARE_RESPONSE_TABLE(TPopupToolbar);
- };
-
- DEFINE_RESPONSE_TABLE2(TPopupToolbar, TSFXToolbar, TWindow)
- EV_WM_NCACTIVATE,
- END_RESPONSE_TABLE;
-
- TPopupToolbar::TPopupToolbar(TWindow* parent, int id, const char far* title,
- int x, int y, BOOL isChild)
- :TSFXToolbar(parent, id, title, x, y, isChild)
- {
- }
-
- LRESULT
- TPopupToolbar::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
- {
- char szTemp[50];
-
- if (notifyCode == BN_CLICKED)
- {
- wsprintf(szTemp, "You pressed button %u", id);
- SFXMsgBox(HWindow, szTemp, "Information", MB_ICONINFORMATION, 0);
- }
- else
- TSFXToolbar::EvCommand(id, hWndCtl, notifyCode);
-
- return 0;
- }
-
- BOOL
- TPopupToolbar::EvNCActivate(BOOL active)
- {
- /* To have the active state the two popup toolbars match the active state of their
- * parent this event is passed on to the parent's EvNCActivate response and TRUE is
- * returned to prevent any further processing.
- */
- Parent->HandleMessage(WM_NCACTIVATE, active, 0);
- return TRUE;
- }
-
- // TToolbarDialog
-
- class TToolbarDialog : public TDialog
- {
- public:
- TToolbarDialog(TWindow*, TResId);
- TPopupToolbar* TB1;
- TPopupToolbar* TB2;
- TSFXToolbar* TB3;
- void SetupWindow();
- BOOL EvNCActivate(BOOL);
- virtual LRESULT EvCommand(UINT, HWND, UINT);
- DECLARE_RESPONSE_TABLE(TToolbarDialog);
- };
-
- DEFINE_RESPONSE_TABLE1(TToolbarDialog, TDialog)
- EV_WM_NCACTIVATE,
- END_RESPONSE_TABLE;
-
- TToolbarDialog::TToolbarDialog(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- /* Creates a popup toolbar. You only need to specifiy MTB_3DFRAME if you
- * want the toolbar to have a gray 3-dimensional frame. Specifying a WS_XXX
- * frame style with MTB_3DFRAME has no effect. Popup toolbars are created
- * with the WS_POPUPWINDOW style, not WS_OVERLAPPED or WS_OVERLAPPEDWINDOW.
- */
- TB1 = new TPopupToolbar(this, 201, "Popup Toolbar,304,305,306,307,308,309", 10, 30, FALSE);
- TB1->Attr.Style |= MTB_ROW1 | MTB_COLUMN6 | MTB_BITMAPBUTTON;
- TB2 = new TPopupToolbar(this, 202, "?,301,302,303,304,305,306", 10, 100, FALSE);
- TB2->Attr.Style |= MTB_ROW3 | MTB_COLUMN2 | MTB_BITMAPBUTTON | MTB_RADIO;
- TB3 = new TSFXToolbar(this, 102);
- }
-
- void
- TToolbarDialog::SetupWindow()
- {
- TDialog::SetupWindow();
-
- /* Sets the new SFXCaption style - just for show! Since these dialogs don't have
- * an icon they display their parents' class icon.
- */
- SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
-
- /* Sets the toolbar/status bar font to the stock FINE_FONT object
- */
- TB3->SetFont((HFONT)GetSFXObject(FINE_FONT));
-
- /* Sets the text in the toolbar's static control. Floating toolbars don't
- * have a static control.
- */
- TB3->SetText(" This is where text appears in a status bar");
- CenterWindow(0, HWindow);
- }
-
- LRESULT
- TToolbarDialog::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
- {
- char szTemp[50];
-
- if (id > 2 && notifyCode == BN_CLICKED)
- {
- wsprintf(szTemp, "You pressed button %u", id);
- SFXMsgBox(HWindow, szTemp, "Information", MB_ICONINFORMATION, 0);
- }
- else
- TDialog::EvCommand(id, hWndCtl, notifyCode);
-
- return 0;
- }
-
- BOOL
- TToolbarDialog::EvNCActivate(BOOL active)
- {
- TPoint point;
-
- /* This dialog controls the active state of its toolbars so that they all activate
- * and inactivate together.
- */
- GetCursorPos(point);
- if (IsNCActive(HWindow) && (PtInWindow(TB1->HWindow, point) ||
- PtInWindow(TB2->HWindow, point) || PtInWindow(HWindow, point)))
- {
- /* If this dialog's caption is active (IsNCActive = TRUE) and the cursor is
- * in either of the toolbars or this dialog (PtInWindow = TRUE) then all the
- * captions are already active, so return TRUE to prevent any further processing.
- * This prevents unnecessary flicker.
- */
- return TRUE;
- }
-
- /* The WM_NCACTIVATE message can't be returned to the popup toolbar window function
- * because that would create a loop and the program would crash. Fortunately,
- * SFXDefWindowProc can be used to draw the active state since its WM_NCACTIVATE
- * response is the same as SFXToolbar's and both pass the message onto DefWindowProc.
- */
- SFXDefWindowProc(TB1->HWindow, WM_NCACTIVATE, active, 0);
- SFXDefWindowProc(TB2->HWindow, WM_NCACTIVATE, active, 0);
- return TDialog::EvNCActivate(active);
- }
-
- // TMessageDialog
-
- class TMessageDialog : public TDialog
- {
- public:
- TMessageDialog(TWindow*, TResId);
- UINT msgStyle;
- void SetupWindow();
- virtual LRESULT EvCommand(UINT, HWND, UINT);
- DECLARE_RESPONSE_TABLE(TMessageDialog);
- };
-
- DEFINE_RESPONSE_TABLE1(TMessageDialog, TDialog)
- END_RESPONSE_TABLE;
-
- TMessageDialog::TMessageDialog(TWindow* parent, TResId resId)
- :TDialog(parent, resId),
- TWindow(parent)
- {
- }
-
- void
- TMessageDialog::SetupWindow()
- {
- TDialog::SetupWindow();
-
- SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
-
- /* SFX check boxes and radio buttons respond the standard Windows
- * button messages. Here BM_SETCHECK is sent to check the first radiobutton.
- * Since no ObjectWindows object was created for the radio button(s) GetDlgItem
- * has to be used.
- */
- ::SendMessage((HWND)GetDlgItem(IDSFXFRAME), BM_SETCHECK, 1, 0);
-
- /* A NULL value for the parent window handle in a call to CenterWindow
- * will center the specified window (in this case HWindow) over the desktop
- * window.
- */
- CenterWindow(0, HWindow);
- msgStyle = MWS_SFXFRAME;
- }
-
- LRESULT
- TMessageDialog::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
- {
- int reply;
- char Text[144] = "\0";
-
- /* These button respones use the SFXInputBox and SFXMsgBox functions to display
- * the 7 Input/Message box styles and the message box button combinations.
- */
- if (notifyCode == BN_CLICKED)
- {
- switch (id)
- {
- case IDSFXFRAME:
- msgStyle = MWS_SFXFRAME;
- break;
-
- case IDGRAY:
- msgStyle = MWS_GRAY;
- break;
-
- case IDGLAZE:
- msgStyle = MWS_GLAZE;
- break;
-
- case IDSTEEL:
- msgStyle = MWS_STEEL;
- break;
-
- case ID3DGRAY:
- msgStyle = MWS_3DGRAY;
- break;
-
- case ID3DGLAZE:
- msgStyle = MWS_3DGLAZE;
- break;
-
- case ID3DSTEEL:
- msgStyle = MWS_3DSTEEL;
- break;
-
- case IDMBOK:
- reply = SFXInputBox(HWindow, "Password", "Enter password:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "Your password is:",
- MB_OK | MB_ICONASTERISK, msgStyle);
- break;
-
- case IDMBOKCANCEL:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_OKCANCEL | MB_ICONINFORMATION, msgStyle);
- break;
-
- case IDMBABORTRETRYIGNORE:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_ABORTRETRYIGNORE | MB_ICONQUESTION, msgStyle);
- break;
-
- case IDMBRETRYCANCEL:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_RETRYCANCEL | MB_ICONSTOP, msgStyle);
- break;
-
- case IDMBYESNO:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_YESNO | MB_ICONEXCLAMATION, msgStyle);
- break;
-
- case IDMBYESNOCANCEL:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_YESNOCANCEL | MB_ICONQUESTION, msgStyle);
- break;
-
- case IDMBGO:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_GO | MB_ICONASTERISK, msgStyle);
- break;
-
- case IDMBGOSTOP:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_GOSTOP | MB_ICONINFORMATION, msgStyle);
- break;
-
- case IDMBOKCANCELHELP:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_OKCANCELHELP | MB_ICONSTOP, msgStyle);
- break;
-
- case IDMBYESNOHELP:
- reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
- sizeof(Text), msgStyle);
- if (reply == IDOK)
- SFXMsgBox(HWindow, Text, "You entered:",
- MB_YESNOHELP | MB_ICONINFORMATION, msgStyle);
- break;
-
- case IDHELP:
- SFXMsgBox(HWindow, "You clicked the help button", "Message Box",
- MB_ICONINFORMATION, msgStyle);
- break;
-
- default:
- TDialog::EvCommand(id, hWndCtl, notifyCode);
- }
- }
- else
- TDialog::EvCommand(id, hWndCtl, notifyCode);
-
- return 0;
- }
-
- // TToolbar
-
- class TToolbar : public TSFXToolbar
- {
- public:
- TToolbar(TWindow*, int, const char far*, int, int, BOOL);
- virtual LRESULT EvCommand(UINT, HWND, UINT);
- void EvMouseMove(UINT, TPoint&);
- DECLARE_RESPONSE_TABLE(TToolbar);
- };
-
- DEFINE_RESPONSE_TABLE2(TToolbar, TSFXToolbar, TWindow)
- EV_WM_MOUSEMOVE,
- END_RESPONSE_TABLE;
-
- TToolbar::TToolbar(TWindow* parent, int id, const char far* title,
- int x, int y, BOOL isChild)
- :TSFXToolbar(parent, id, title, x, y, isChild)
- {
- }
-
- LRESULT
- TToolbar::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
- {
- /* These are the main toolbar buttons BN_CLICKED messages. A toolbar button's
- * WM_COMMAND message is also sent to the toolbar's parent. If you add a
- * toolbar to a window or dialog and only need to trap the toolbar button
- * clicks you can trap them in the toolbar's parent's WM_COMMAND message
- * reponse. If you do this you must make sure the toolbar button ID's are
- * unique to the parent window or dialog.
- */
- if (notifyCode == BN_CLICKED)
- {
- switch (id)
- {
- case IDT_ONE:
- strcpy(Class, "SFX3DDlg");
- Style = MWS_SFXFRAME;
- Tool = IDT_ONE;
- break;
-
- case IDT_TWO:
- strcpy(Class, "SFXGlazeDlg");
- Style = MWS_3DGLAZE;
- Tool = IDT_TWO;
- break;
-
- case IDT_THREE:
- strcpy(Class, "SFXGrayDlg");
- Style = MWS_3DGRAY;
- Tool = IDT_THREE;
- break;
-
- case IDT_FOUR:
- strcpy(Class, "SFXSteelDlg");
- Style = MWS_3DSTEEL;
- Tool = IDT_FOUR;
- break;
-
- default:
- TSFXToolbar::EvCommand(id, hWndCtl, notifyCode);
- }
- }
- else
- TSFXToolbar::EvCommand(id, hWndCtl, notifyCode);
-
- return 0;
- }
-
- void
- TToolbar::EvMouseMove(UINT, TPoint& point)
- {
- char temp[80], text[80];
-
- /* To set the text in a top toolbar, bottom toolbar or status bar
- * you need to retrieve the window handle of the toolbar's static control
- * by specifying the offset MTB_WNDSTATIC in a call to GetWindowWord. The
- * return value is the window handle of the static control. TSFXToolbar's
- * StatusWindow() member function does this for you.
- */
- if (UseHints && PtInClient(HWindow, point))
- {
- HWND childWnd = ChildWindowFromPoint(point);
- GetText(temp);
- int childId = ::GetDlgCtrlID(childWnd);
- if (childId > -1)
- {
- text[0] = '\0';
- GetModule()->LoadString(childId, text, sizeof(text));
- if (strcmpi(temp, text) != 0)
- SetText(text);
- }
- }
- else
- DefaultProcessing();
- }
-
- // TSplashWindow
-
- class TSplashWindow : public TSFXStatic
- {
- public:
- TSplashWindow(TWindow*, int, const char far*, int, int, int, int, UINT);
- void SetupWindow();
- UINT EvGetDlgCode(MSG far*);
- void EvKeyDown(UINT, UINT, UINT);
- void EvLButtonDown(UINT, TPoint&);
- UINT EvNCHitTest(TPoint&);
- void EvTimer(UINT);
- DECLARE_RESPONSE_TABLE(TSplashWindow);
- };
-
- DEFINE_RESPONSE_TABLE1(TSplashWindow, TSFXStatic)
- EV_WM_GETDLGCODE,
- EV_WM_KEYDOWN,
- EV_WM_LBUTTONDOWN,
- EV_WM_NCHITTEST,
- EV_WM_TIMER,
- END_RESPONSE_TABLE;
-
- TSplashWindow::TSplashWindow(TWindow* parent, int id, const char far* title,
- int x, int y, int w, int h, UINT textLen)
- :TSFXStatic(parent, id, title, x, y, w, h, textLen)
- {
- }
-
- void
- TSplashWindow::SetupWindow()
- {
- TSFXStatic::SetupWindow();
-
- /* Set timer to destroy the splash window after 10 seconds
- */
- SetTimer(IDTIMER, 10000, 0);
- }
-
- UINT
- TSplashWindow::EvGetDlgCode(MSG far*)
- {
- return DLGC_WANTALLKEYS;
- }
-
- void
- TSplashWindow::EvKeyDown(UINT key, UINT, UINT)
- {
- if (key == VK_RETURN)
- KillTimer(IDTIMER);
- CloseWindow();
- }
-
- void
- TSplashWindow::EvLButtonDown(UINT, TPoint&)
- {
- KillTimer(IDTIMER);
- CloseWindow();
- }
-
- UINT
- TSplashWindow::EvNCHitTest(TPoint& point)
- {
- /* SFXStatic controls return HTTRANSPARENT. TSplashWindow overrides this
- * so it can respond to the WM_LBUTTONDOWN message.
- */
- return (UINT)::DefWindowProc(HWindow, WM_NCHITTEST, 0, MAKELPARAM(point.x, point.y));
- }
-
- void
- TSplashWindow::EvTimer(UINT timerId)
- {
- if (timerId == IDTIMER)
- {
- KillTimer(IDTIMER);
- CloseWindow();
- }
- }
-
- // TViewWindow
-
- class TViewWindow : public TSFXFrameWindow
- {
- public:
- TViewWindow(TWindow*, const char*);
- ~TViewWindow();
- UINT OldToolbarPos, ToolbarPos;
- TBrush* Brush;
- TColor Color;
- TFont* Font;
- TToolbar* Toolbar;
- TSplashWindow* Splash;
- TModule* dllModule;
- TFindReplaceDialog* SearchDialog;
- TFindReplaceDialog::TData SearchData;
- TOpenSaveDialog::TData FileData;
- TPrintDialog::TData PrintData;
- TChooseColorDialog::TData Choose;
- TChooseFontDialog::TData FontData;
- TIcon* FindIcon;
- TIcon* ReplaceIcon;
- TIcon* ColorIcon;
- TIcon* FontIcon;
- TIcon* PrintIcon;
- TIcon* DirIcon;
- TIcon* FileIcon;
- char Text[80];
- char far* GetClassName();
- void GetWindowClass(WNDCLASS& wndClass);
- void SetupWindow();
- void Create3DMenus();
- void Paint(TDC&, BOOL, TRect&);
- void SetDefaultData();
- void EvDrawItem(UINT, DRAWITEMSTRUCT far&);
- void EvInitMenuPopup(HMENU, UINT, BOOL);
- void EvMeasureItem(UINT, MEASUREITEMSTRUCT far&);
- LRESULT EvMenuChar(WPARAM, LPARAM);
- void EvMenuSelect(UINT, UINT, HMENU);
- void EvSize(UINT, TSize&);
- LRESULT EvSFXApplyColor(WPARAM, LPARAM);
- LRESULT EvSFXApplyFont(WPARAM, LPARAM);
- LRESULT EvSFXInitDialog(WPARAM, LPARAM);
- LRESULT EvSFXHelp(WPARAM, LPARAM);
- LRESULT EvFindMsg(WPARAM, LPARAM);
- void EvMouseMove(UINT, TPoint&);
- void EvNCMouseMove(UINT, TPoint&);
- void MouseMove(const TPoint&);
- void UpdateClientArea();
- void CmFileOpen();
- void CmFileExOpen();
- void CmFileOpenExtraFlags();
- void CmFileSaveAs();
- void CmOpenDir();
- void CmOpenDirHelp();
- void CmPrint();
- void CmPrintHelp();
- void CmPrintSetup();
- void CmPrintSetupHelp();
- void CmExitWindow();
- void CmSearchFind();
- void CmSearchFindHelp();
- void CmSearchReplace();
- void CmSearchReplaceHelp();
- void CmBasicColor();
- void CmBasicColorHelp();
- void CmExtendedColor();
- void CmExtendedColorHelp();
- void CmBasicFont();
- void CmBasicFontExtraFlags();
- void CmExtendedFont();
- void CmExtendedFontApply();
- void CmExtendedFontHelp();
- void CmButton();
- void CmStatic();
- void CmShade();
- void CmCheck();
- void CmRadio();
- void CmControl();
- void CmToolbar();
- void CmMessage();
- void CmWindows();
- void CmTop();
- void CmFloat();
- void CmBottom();
- void CmStatus();
- void CmHints();
- void CmHelp();
- void CmAbout();
- DECLARE_RESPONSE_TABLE(TViewWindow);
- };
-
- DEFINE_RESPONSE_TABLE2(TViewWindow, TSFXFrameWindow, TFrameWindow)
- EV_WM_DRAWITEM,
- EV_WM_INITMENUPOPUP,
- EV_WM_MEASUREITEM,
- EV_WM_MENUSELECT,
- EV_WM_SIZE,
- EV_WM_MOUSEMOVE,
- EV_WM_NCMOUSEMOVE,
- EV_COMMAND(CM_FILEOPEN, CmFileOpen),
- EV_COMMAND(CM_FILEEXOPEN, CmFileExOpen),
- EV_COMMAND(CM_FILEOPENEXTRAFLAGS, CmFileOpenExtraFlags),
- EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),
- EV_COMMAND(CM_PRINT, CmPrint),
- EV_COMMAND(CM_PRINTHELP, CmPrintHelp),
- EV_COMMAND(CM_PRINTSETUP, CmPrintSetup),
- EV_COMMAND(CM_PRINTSETUPHELP, CmPrintSetupHelp),
- EV_COMMAND(CM_OPENDIR, CmOpenDir),
- EV_COMMAND(CM_OPENDIRHELP, CmOpenDirHelp),
- EV_COMMAND(CM_EXITWINDOW, CmExitWindow),
- EV_COMMAND(CM_SEARCHFIND, CmSearchFind),
- EV_COMMAND(CM_SEARCHFINDHELP, CmSearchFindHelp),
- EV_COMMAND(CM_SEARCHREPLACE, CmSearchReplace),
- EV_COMMAND(CM_SEARCHREPLACEHELP, CmSearchReplaceHelp),
- EV_COMMAND(CM_BASICCOLOR, CmBasicColor),
- EV_COMMAND(CM_BASICCOLORHELP, CmBasicColorHelp),
- EV_COMMAND(CM_EXTENDEDCOLOR, CmExtendedColor),
- EV_COMMAND(CM_EXTENDEDCOLORHELP, CmExtendedColorHelp),
- EV_COMMAND(CM_BASICFONT, CmBasicFont),
- EV_COMMAND(CM_BASICFONTEXTRAFLAGS, CmBasicFontExtraFlags),
- EV_COMMAND(CM_EXTENDEDFONT, CmExtendedFont),
- EV_COMMAND(CM_EXTENDEDFONTAPPLY, CmExtendedFontApply),
- EV_COMMAND(CM_EXTENDEDFONTHELP, CmExtendedFontHelp),
- EV_COMMAND(CM_BUTTON, CmButton),
- EV_COMMAND(CM_STATIC, CmStatic),
- EV_COMMAND(CM_SHADE, CmShade),
- EV_COMMAND(CM_CHECK, CmCheck),
- EV_COMMAND(CM_RADIO, CmRadio),
- EV_COMMAND(CM_CONTROL, CmControl),
- EV_COMMAND(CM_TOOLBAR, CmToolbar),
- EV_COMMAND(CM_MESSAGE, CmMessage),
- EV_COMMAND(CM_WINDOWS, CmWindows),
- EV_COMMAND(CM_TOP, CmTop),
- EV_COMMAND(CM_FLOAT, CmFloat),
- EV_COMMAND(CM_BOTTOM, CmBottom),
- EV_COMMAND(CM_STATUS, CmStatus),
- EV_COMMAND(CM_HINTS, CmHints),
- EV_COMMAND(CM_HELP, CmHelp),
- EV_COMMAND(CM_ABOUT, CmAbout),
- EV_MESSAGE(WM_MENUCHAR, EvMenuChar),
- EV_MESSAGE(WM_SFXAPPLYCOLOR, EvSFXApplyColor),
- EV_MESSAGE(WM_SFXAPPLYFONT, EvSFXApplyFont),
- EV_MESSAGE(WM_SFXINITDIALOG, EvSFXInitDialog),
- EV_MESSAGE(WM_SFXHELP, EvSFXHelp),
- EV_REGISTERED(FINDMSGSTRING, EvFindMsg), // Find/Replace common dialog message
- END_RESPONSE_TABLE;
-
- TViewWindow::TViewWindow(TWindow* parent, const char* title)
- :TSFXFrameWindow(parent, title),
- TFrameWindow(parent, title),
- TWindow(parent, title),
- FileData(0, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|", 0, "", "*")
- {
- Attr.Style |= MWS_SFXCAPTION;
- Attr.X = 0;
- Attr.Y = 0;
- Attr.W = CW_USEDEFAULT;
- Attr.W = CW_USEDEFAULT;
-
- /* Creates the splash window displayed when the main window first appears.
- * An SFXStatic control is used to display the centered bitmap inside a
- * raised border (MSS_BITMAPWINDOW style).
- *
- * MSS_CENTERBITMAP = (MSS_BITMAPWINDOW | MSS_VCENTER | MSS_HCENTER)
- */
- Splash = new TSplashWindow(this, IDSPLASH, "SplashPanel", 0, 0, 318, 153, 0);
- Splash->Attr.Style = WS_CHILD | WS_VISIBLE | MSS_CENTERBITMAP | MSS_RAISED;
-
- // Create a TModule object for SFX200.DLL to use in the common dialog box constructors
- dllModule = new TModule("SFX200.DLL", GetSFXInstance());
-
- /* This frame window has no client window. It uses a brush to paint its client area.
- * This brush is can be changed using the Choose Color dialog box.
- */
- Brush = new TBrush(::GetSysColor(COLOR_WINDOW));
-
- // Set up the menu
- AssignMenu(APPNAME);
-
- // Set initial text color to Blue }
- Color = TColor(0, 0, 255);
-
- // Set default values for common dialog and LogFont data structures
- SetDefaultData();
-
- // Create default font
- Font = new TFont(&FontData.LogFont);
- SearchDialog = 0;
- Toolbar = 0;
- ToolbarPos = 0;
-
- // Load caption icons, depending on height of title bar
- if (GetSystemMetrics(SM_CYSIZE) == 26)
- {
- FindIcon = new TIcon(GetModule()->GetInstance(), "Find2");
- ReplaceIcon = new TIcon(GetModule()->GetInstance(), "Replace2");
- ColorIcon = new TIcon(GetModule()->GetInstance(), "Color2");
- FontIcon = new TIcon(GetModule()->GetInstance(), "Font2");
- PrintIcon = new TIcon(GetModule()->GetInstance(), "Print2");
- DirIcon = new TIcon(GetModule()->GetInstance(), "Dir2");
- FileIcon = new TIcon(GetModule()->GetInstance(), "File2");
- }
- else
- {
- FindIcon = new TIcon(GetModule()->GetInstance(), "Find1");
- ReplaceIcon = new TIcon(GetModule()->GetInstance(), "Replace1");
- ColorIcon = new TIcon(GetModule()->GetInstance(), "Color1");
- FontIcon = new TIcon(GetModule()->GetInstance(), "Font1");
- PrintIcon = new TIcon(GetModule()->GetInstance(), "Print1");
- DirIcon = new TIcon(GetModule()->GetInstance(), "Dir1");
- FileIcon = new TIcon(GetModule()->GetInstance(), "File1");
- }
- // Use Flyover Hints
- UseHints = TRUE;
- }
-
- TViewWindow::~TViewWindow()
- {
- delete dllModule;
- delete Brush;
- delete Font;
- delete FindIcon;
- delete ReplaceIcon;
- delete ColorIcon;
- delete FontIcon;
- delete PrintIcon;
- delete DirIcon;
- delete FileIcon;
- }
-
- char far* TViewWindow::GetClassName()
- {
- return APPNAME;
- }
-
- void
- TViewWindow::GetWindowClass(WNDCLASS& wndClass)
- {
- TSFXFrameWindow::GetWindowClass(wndClass);
- wndClass.hbrBackground = 0;
- }
-
- void
- TViewWindow::SetupWindow()
- {
- TSFXFrameWindow::SetupWindow();
-
- /* Set up 3D ownerdraw menu items
- */
- Create3DMenus();
-
- /* Use CmStatus() menu item to set up a status bar
- */
- Tool = IDT_ONE;
- CmStatus();
-
- /* Set the initial dialog class displayed to SFX3DDlg. This information
- * is changed when the user presses a toolbar button.
- */
- strcpy(Class, "SFX3DDlg");
- Style = MWS_SFXFRAME;
-
- /* The CenterWindow function is defined in the SFX200.H. Here it's used to center
- * the Splash window over HWindow. If HWindow was zero the Splash window would
- * be centered over the desktop window.
- */
- CenterWindow(HWindow, Splash->HWindow);
- Splash->SetFocus();
- }
-
- void
- TViewWindow::Create3DMenus()
- {
- HMENU menu;
- char* text;
-
- /* Since the system menu rarely gets modified, Set3DSystemMenu can be used to
- * automatically set up a basic ownerdraw system menu.
- */
- Set3DSystemMenu(HWindow, "Object Viewer");
-
- /* You cannot specify ownerdraw menu items in a resource file. You can only
- * specify (modify) them from within your program.
- */
- menu = GetSubMenu(GetMenu(), 0);
- text = "&Open...";
- ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_FILEOPEN, text);
- text = "Open with E&xtended Select...";
- ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_FILEEXOPEN, text);
- text = "Open with Extra &Flags...";
- ModifyMenu(menu, 2, MF_BYPOSITION | MF_OWNERDRAW, CM_FILEOPENEXTRAFLAGS, text);
- text = "&Save As...";
- ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_FILESAVEAS, text);
- text = "&Directory...";
- ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_OPENDIR, text);
- text = "Di&rectory with Help...";
- ModifyMenu(menu, 6, MF_BYPOSITION | MF_OWNERDRAW, CM_OPENDIRHELP, text);
- text = "&Print...";
- ModifyMenu(menu, 8, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINT, text);
- text = "Pr&int with Help...";
- ModifyMenu(menu, 9, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINTHELP, text);
- text = "Pri&nter Setup...";
- ModifyMenu(menu, 10, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINTSETUP, text);
- text = "Prin&ter Setup with Help...";
- ModifyMenu(menu, 11, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINTSETUPHELP, text);
- text = "&Exit";
- ModifyMenu(menu, 13, MF_BYPOSITION | MF_OWNERDRAW, CM_EXITWINDOW, text);
-
- menu = GetSubMenu(GetMenu(), 1);
- text = "&Find...";
- ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHFIND, text);
- text = "F&ind with Help...";
- ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHFINDHELP, text);
- text = "&Replace...";
- ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHREPLACE, text);
- text = "R&eplace with Help...";
- ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHREPLACEHELP, text);
-
- menu = GetSubMenu(GetMenu(), 2);
- text = "&Basic Color...";
- ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICCOLOR, text);
- text = "Basic &Color with Help...";
- ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICCOLORHELP, text);
- text = "&Extended Color...";
- ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDCOLOR, text);
- text = "E&xtended Color with Help...";
- ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDCOLORHELP, text);
-
- menu = GetSubMenu(GetMenu(), 3);
- text = "&Basic Font...";
- ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICFONT, text);
- text = "Basic &Font with Extra Flags...";
- ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICFONTEXTRAFLAGS, text);
- text = "&Extended Font...";
- ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDFONT, text);
- text = "E&xtended Font with Apply...";
- ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDFONTAPPLY, text);
- text = "Ex&tended Font with Help...";
- ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDFONTHELP, text);
-
- menu = GetSubMenu(GetMenu(), 4);
- text = "&Buttons...";
- ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_BUTTON, text);
- text = "&Static Controls...";
- ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_STATIC, text);
- text = "S&hade Controls...";
- ModifyMenu(menu, 2, MF_BYPOSITION | MF_OWNERDRAW, CM_SHADE, text);
- text = "Chec&k Boxes...";
- ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_CHECK, text);
- text = "&Radio Buttons...";
- ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_RADIO, text);
- text = "&Controls...";
- ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_CONTROL, text);
- text = "&Toolbars...";
- ModifyMenu(menu, 7, MF_BYPOSITION | MF_OWNERDRAW, CM_TOOLBAR, text);
- text = "&Message && Input Boxes...";
- ModifyMenu(menu, 8, MF_BYPOSITION | MF_OWNERDRAW, CM_MESSAGE, text);
- text = "&Windows...";
- ModifyMenu(menu, 10, MF_BYPOSITION | MF_OWNERDRAW, CM_WINDOWS, text);
-
- menu = GetSubMenu(GetMenu(), 5);
- text = "&Top";
- ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_TOP, text);
- text = "&Floating";
- ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_FLOAT, text);
- text = "&Bottom";
- ModifyMenu(menu, 2, MF_BYPOSITION | MF_OWNERDRAW, CM_BOTTOM, text);
- text = "&Status Bar";
- ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_STATUS, text);
- text = "Flyover &Hints";
- ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_HINTS, text);
-
- menu = GetSubMenu(GetMenu(), 6);
- text = "&ObjectMate Reference...";
- ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_HELP, text);
- text = "&About ObjectMate...";
- ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_ABOUT, text);
- }
-
- void
- TViewWindow::SetDefaultData()
- {
- // Default LogFont data
- FontData.LogFont.lfHeight = 36;
- FontData.LogFont.lfWidth = 0;
- FontData.LogFont.lfEscapement = 0;
- FontData.LogFont.lfOrientation = 0;
- FontData.LogFont.lfWeight = FW_BOLD;
- FontData.LogFont.lfItalic = FALSE;
- FontData.LogFont.lfUnderline = TRUE;
- FontData.LogFont.lfStrikeOut = FALSE;
- FontData.LogFont.lfCharSet = 1;
- FontData.LogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
- FontData.LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- FontData.LogFont.lfQuality = DEFAULT_QUALITY;
- FontData.LogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- strcpy(FontData.LogFont.lfFaceName, "Times New Roman");
-
- // Default font data
- FontData.DC = 0;
- FontData.Color = Color; // Color and font dialogs use the same color
- FontData.Style = 0;
- FontData.FontType = SCREEN_FONTTYPE;
- FontData.SizeMin = 0;
- FontData.SizeMax = 0;
-
- // Default color data
- Choose.Color = Color;
- Choose.CustColors = custColors;
-
- // Set default print data
- PrintData.FromPage = 1;
- PrintData.ToPage = 25;
- PrintData.MinPage = 1;
- PrintData.MaxPage = 25;
- PrintData.Copies = 1;
- }
-
- void
- TViewWindow::Paint(TDC& paintDC, BOOL, TRect&)
- {
- paintDC.SetTextColor(Color);
- paintDC.SetBkMode(TRANSPARENT);
- TRect rc = GetClientRect();
- if (ToolbarPos == CM_TOP)
- rc.top = 27;
- else
- if (ToolbarPos == CM_BOTTOM || ToolbarPos == CM_STATUS)
- rc.bottom -= 27;
- paintDC.FillRect(rc, *Brush);
- if (Font)
- paintDC.SelectObject(*Font);
- paintDC.TextOut(10, 30, "Microworks ObjectMate 2.6", 25);
- if (Font)
- paintDC.RestoreFont();
- }
-
- void
- TViewWindow::EvDrawItem(UINT /*ctlId*/, DRAWITEMSTRUCT far& drawinfo)
- {
- /* Pass EvDrawItem onto DrawMenuItem using the default values
- * for hFont, color and textColor. DrawMenuItem is defined in
- * SMENU.H
- */
- if (drawinfo.CtlType == ODT_MENU)
- DrawMenuItem(drawinfo);
- }
-
- void
- TViewWindow::EvInitMenuPopup(HMENU hPopupMenu, UINT index, BOOL sysMenu)
- {
- if (!sysMenu && index == 5)
- {
- if (ToolbarPos != OldToolbarPos)
- {
- CheckMenuItem(hPopupMenu, ToolbarPos, MF_CHECKED);
- CheckMenuItem(hPopupMenu, OldToolbarPos, MF_UNCHECKED);
- }
- if (UseHints)
- CheckMenuItem(hPopupMenu, CM_HINTS, MF_CHECKED);
- else
- CheckMenuItem(hPopupMenu, CM_HINTS, MF_UNCHECKED);
- }
- else
- TSFXFrameWindow::EvInitMenuPopup(hPopupMenu, index, sysMenu);
- }
-
- void
- TViewWindow::EvMeasureItem(UINT /*ctlId*/, MEASUREITEMSTRUCT far& measureinfo)
- {
- /* MeasureMenuItem is defined in SMENU.H
- */
- if (measureinfo.CtlType == ODT_MENU)
- MeasureMenuItem(HWindow, measureinfo);
- }
-
- LRESULT
- TViewWindow::EvMenuChar(WPARAM nChar, LPARAM lParam)
- {
- /* OWL's EvMenuChar function doesn't seem to work properly so EvMenuChar
- * has been redefined using the EV_MESSAGE macro. ProcessSystemChar
- * automatically handles ownerdraw system menu mnemonics. Your application
- * must handle all other ownerdraw menu mnemonics.
- */
- if (LOWORD(lParam) & MF_SYSMENU)
- return ProcessSystemChar(nChar);
- else
- if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 0))
- {
- switch (nChar)
- {
- case 79:
- case 111:
- return MAKELONG(0, 2);
-
- case 88:
- case 120:
- return MAKELONG(1, 2);
-
- case 70:
- case 102:
- return MAKELONG(2, 2);
-
- case 83:
- case 115:
- return MAKELONG(3, 2);
-
- case 68:
- case 100:
- return MAKELONG(5, 2);
-
- case 82:
- case 114:
- return MAKELONG(6, 2);
-
- case 80:
- case 112:
- return MAKELONG(8, 2);
-
- case 73:
- case 105:
- return MAKELONG(9, 2);
-
- case 78:
- case 110:
- return MAKELONG(10, 2);
-
- case 84:
- case 116:
- return MAKELONG(11, 2);
-
- case 69:
- case 101:
- return MAKELONG(13, 2);
- }
- }
- else
- if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 1))
- {
- switch (nChar)
- {
- case 70:
- case 102:
- return MAKELONG(0, 2);
-
- case 73:
- case 105:
- return MAKELONG(1, 2);
-
- case 82:
- case 114:
- return MAKELONG(3, 2);
-
- case 69:
- case 101:
- return MAKELONG(4, 2);
- }
- }
- else
- if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 2))
- {
- switch (nChar)
- {
- case 66:
- case 98:
- return MAKELONG(0, 2);
-
- case 67:
- case 99:
- return MAKELONG(1, 2);
-
- case 69:
- case 101:
- return MAKELONG(3, 2);
-
- case 88:
- case 120:
- return MAKELONG(4, 2);
- }
- }
- else
- if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 3))
- {
- switch (nChar)
- {
- case 66:
- case 98:
- return MAKELONG(0, 2);
-
- case 70:
- case 102:
- return MAKELONG(1, 2);
-
- case 69:
- case 101:
- return MAKELONG(3, 2);
-
- case 88:
- case 120:
- return MAKELONG(4, 2);
-
- case 84:
- case 116:
- return MAKELONG(5, 2);
- }
- }
- else
- if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 4))
- {
- switch (nChar)
- {
- case 66:
- case 98:
- return MAKELONG(0, 2);
-
- case 83:
- case 115:
- return MAKELONG(1, 2);
-
- case 72:
- case 104:
- return MAKELONG(2, 2);
-
- case 75:
- case 107:
- return MAKELONG(3, 2);
-
- case 82:
- case 114:
- return MAKELONG(4, 2);
-
- case 67:
- case 99:
- return MAKELONG(5, 2);
-
- case 84:
- case 116:
- return MAKELONG(7, 2);
-
- case 77:
- case 109:
- return MAKELONG(8, 2);
-
- case 87:
- case 119:
- return MAKELONG(10, 2);
- }
- }
- else
- if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 5))
- {
- switch (nChar)
- {
- case 84:
- case 116:
- return MAKELONG(0, 2);
-
- case 70:
- case 102:
- return MAKELONG(1, 2);
-
- case 66:
- case 98:
- return MAKELONG(2, 2);
-
- case 83:
- case 115:
- return MAKELONG(3, 2);
-
- case 72:
- case 104:
- return MAKELONG(5, 2);
- }
- }
- else
- if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 6))
- {
- switch (nChar)
- {
- case 79:
- case 111:
- return MAKELONG(0, 2);
-
- case 65:
- case 97:
- return MAKELONG(1, 2);
- }
- }
- return 0L;
- }
-
- void
- TViewWindow::EvMenuSelect(UINT menuItemId, UINT /*flags*/, HMENU /*hMenu*/)
- {
- if (UseHints)
- {
- Text[0] = '\0';
- GetModule()->LoadString(menuItemId, Text, sizeof(Text));
- Toolbar->SetText(Text);
- }
- }
-
- void
- TViewWindow::EvSize(UINT sizeType, TSize& size)
- {
- /* AlignToolbar is a TSFXToolbar member function defined in STOOLBAR.H. It sends
- * a WM_ALIGNTOOLBAR message to itself to realign a Top, Left, Right or Bottom aligned
- * toolbar or status bar. It should be added to the WM_SIZE message response so that
- * an aligned toolbar gets realigned properly when its parent is resized.
- */
- Toolbar->AlignToolbar();
-
- /* The main window was not created with the CS_HREDRAW and CS_VREDRAW style
- * so the toolbar could be excluded from the main window's update region. The
- * left and top toolbar styles automatically redraw that area of the toolbar
- * window that has changed.
- */
- UpdateClientArea();
- TWindow::EvSize(sizeType, size);
- }
-
- void
- TViewWindow::EvMouseMove(UINT, TPoint& point)
- {
- MouseMove(point);
- }
-
- void
- TViewWindow::EvNCMouseMove(UINT, TPoint& point)
- {
- MouseMove(point);
- }
-
- void
- TViewWindow::MouseMove(const TPoint& point)
- {
- /* UseHints is a BOOL value thats switches on/off Flyover hints. This code
- * clears the toolbar/status bar text if the cursor is inside the main window
- * but out side the toolbar. The code that sets the text is in the TToolbar
- * EvMouseMove response.
- */
- if (UseHints)
- {
- TRect rc = *ChildToParentRect(Toolbar->HWindow);
- if (!PtInRect(&rc, point))
- {
- Toolbar->GetText(Text);
- if (strcmpi(Text, "\0") != 0)
- Toolbar->SetText("\0");
- }
- }
- }
-
- LRESULT
- TViewWindow::EvSFXApplyColor(WPARAM, LPARAM color)
- {
- /* This private message is sent when the user presses the Apply button in
- * a Color common dialog box. WPARAM is zero and color is the new RGB color
- * value selected by the user. This value is used to change the window's
- * background brush.
- */
- delete Brush;
- Brush = new TBrush(color);
- UpdateClientArea();
- return 0;
- }
-
- LRESULT
- TViewWindow::EvSFXApplyFont(WPARAM font, LPARAM color)
- {
- /* This private message is sent when the user presses the Apply button in a
- * Font common dialog box. font is the handle of the newly created font
- * and color is the new RGB color value. If the color option is not used
- * by the font dialog box color is 'RGB(0, 0, 0)'. SFX200.DLL does not delete
- * this font, that's your responsiblilty! When you close the font dialog box
- * the LogFont structure is automatcially updated.
- */
- if (font)
- {
- delete Font;
- Color = TColor(color);
- Font = new TFont((HFONT)font, AutoDelete);
- UpdateClientArea();
- }
- return 0;
- }
-
- LRESULT
- TViewWindow::EvSFXInitDialog(WPARAM wParam, LPARAM lParam)
- {
- /* WM_SFXINITDIALOG is sent from an SFX common dialog box's WM_INITDIALOG message
- * response in SFX200.DLL. wParam is a handle to the common dialog box and lParam
- * is the DLG_XXX constant identifying the type of common dialog box template.
- * This message gives you a chance to do something extra initialization - like
- * setting the MWS_SFXCAPTION flag and specifying a custom icon for each template.
- */
- ::SetWindowLong((HWND)wParam, GWL_STYLE, ::GetWindowLong((HWND)wParam, GWL_STYLE) |
- MWS_SFXCAPTION);
-
- /* A WM_SETBITMAP message is sent to specify the custom icon to display on the
- * title bar. The icon image has been drawn to fit exactly, depending on the
- * height of the title bar, so lParam is 1 to prevent the icon shrinking, as
- * occurs in the Object Viewer main window.
- */
- switch (HIWORD(lParam))
- {
- case DLG_FIND:
- ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*FindIcon), 1);
- break;
-
- case DLG_REPLACE:
- ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*ReplaceIcon), 1);
- break;
-
- case DLG_COLOR:
- case DLG_EXCOLOR:
- ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*ColorIcon), 1);
- break;
-
- case DLG_FONT:
- case DLG_EXFONT:
- ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*FontIcon), 1);
- break;
-
- case DLG_PRINT:
- case DLG_PRINTSETUP:
- ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*PrintIcon), 1);
- break;
-
- case DLG_OPENDIR:
- ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*DirIcon), 1);
- break;
-
- case DLG_OPENSAVE:
- case DLG_EXOPENSAVE:
- ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*FileIcon), 1);
- break;
- }
- return 0;
- }
-
- LRESULT
- TViewWindow::EvSFXHelp(WPARAM, LPARAM lParam)
- {
- /* This private message is sent when the user presses the help button in a
- * one of the common dialog boxes. WPARAM is zero, LOWORD of lParam is the
- * window handle of the common dialog box sending the message and the HIWORD of
- * lParam identifies the type of common dialog box template sending the message.
- * It is one of the common dialog template constants defined in the SFX200.H.
- */
- Text[0] = '\0';
- GetModule()->LoadString(HIWORD(lParam), Text, sizeof(Text));
- SFXMsgBox(HWindow, Text, "Information", MB_ICONINFORMATION, Style);
- return 0;
- }
-
- LRESULT
- TViewWindow::EvFindMsg(WPARAM, LPARAM lParam)
- {
- char szFindMsg[256];
-
- // Find/Replace message sent to this window
- if (SearchDialog)
- {
- SearchDialog->UpdateData(lParam);
- if (SearchData.Flags & FR_DIALOGTERM)
- {
- SearchDialog = 0;
- }
- else
- {
- strcpy(szFindMsg, "Button:\t\t");
- if (FR_FINDNEXT & SearchData.Flags) strcat(szFindMsg, "Find Next\n");
- if (FR_REPLACE & SearchData.Flags) strcat(szFindMsg, "Replace\n");
- if (FR_REPLACEALL & SearchData.Flags) strcat(szFindMsg, "Replace All\n");
- strcat(szFindMsg, "Direction:\t");
- strcat(szFindMsg, (SearchData.Flags & FR_DOWN) ? "Forward\n" : "Backward\n");
- strcat(szFindMsg, "Whole Word:\t");
- strcat(szFindMsg, (SearchData.Flags & FR_WHOLEWORD) ? "On\n" : "Off\n");
- strcat(szFindMsg, "Match Case:\t");
- strcat(szFindMsg, (SearchData.Flags & FR_MATCHCASE) ? "On\n" : "Off\n");
- SFXMsgBox(HWindow, szFindMsg, "Find/Replace Message", MB_ICONINFORMATION, Style);
- }
- }
- return 0;
- }
-
- void
- TViewWindow::UpdateClientArea()
- {
- // Calculates the client update region (minus the toolbar) and invalidates it.
- TRect rc = GetClientRect();
- if (ToolbarPos == CM_TOP)
- rc.top = 27;
- else
- if (ToolbarPos == CM_BOTTOM || ToolbarPos == CM_STATUS)
- rc.bottom -= 27;
- InvalidateRect(rc, TRUE);
- }
-
- // File menu items
-
- void
- TViewWindow::CmFileOpen()
- {
- *FileData.FileName = 0;
- FileData.Flags |= OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
- int OPENTEMPLATE = GetSFXTemplateId(Class, DLG_OPENSAVE);
-
- if (TFileOpenDialog(this, FileData, OPENTEMPLATE, "File Open",
- dllModule).Execute() == IDOK)
- {
- SFXMsgBox(HWindow, FileData.FileName, "You Selected", MB_ICONINFORMATION, Style);
- }
- }
-
- void
- TViewWindow::CmFileExOpen()
- {
- /* Uses the new SFXOpenFile function to display a 'Open File' common dialog box.
- */
- char str[256];
- char filters[] = "All Files (*.*)\0*.*\0Source Code (*.cpp)\0*.cpp\0";
- int id = GetSFXTemplateId(Class, DLG_EXOPENSAVE);
- DWORD flags = 0;
- //DWORD index = 2;
-
- str[0] = 0;
- if (SFXOpenFile(HWindow, str, filters, flags, id/*, FALSE, "Open", (DWORD far*)&index*/))
- {
- SFXMsgBox(HWindow, str, "You Selected", MB_ICONINFORMATION, Style);
- }
- }
-
- void
- TViewWindow::CmFileOpenExtraFlags()
- {
- *FileData.FileName = 0;
- FileData.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_SHOWHELP;
- int OPENTEMPLATE = GetSFXTemplateId(Class, DLG_OPENSAVE);
-
- if (TFileOpenDialog(this, FileData, OPENTEMPLATE, "File Open",
- dllModule).Execute() == IDOK)
- {
- /* MB_OK is the default button and doesn't need to be specified. You can give
- * the message box an SFXCaption by combining the SFXMsgBox Style argument with
- * the MWS_SFXCAPTION flag.
- */
- SFXMsgBox(HWindow, FileData.FileName, "You Selected",
- MB_ICONINFORMATION, Style | MWS_SFXCAPTION);
- }
- }
-
- void
- TViewWindow::CmFileSaveAs()
- {
- /* Uses the new SFXSaveFile function to display a 'Save File As' common dialog box
- */
- char str[256];
- char filters[] = "All Files (*.*)\0*.*\0Source Code (*.cpp)\0*.cpp\0";
- int id = GetSFXTemplateId(Class, DLG_OPENSAVE);
- DWORD flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
-
- str[0] = 0;
- if (SFXSaveFile(HWindow, str, filters, flags, id, TRUE))
- {
- SFXMsgBox(HWindow, str, "You Selected", MB_ICONINFORMATION, Style);
- }
-
- }
-
- void
- TViewWindow::CmPrint()
- {
- PrintData.Flags = PD_COLLATE | PD_DISABLEPRINTTOFILE;
- char far* PRINTTEMPLATE = GetSFXTemplate(Class, DLG_PRINT);
- char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
-
- if (TPrintDialog(this, PrintData, PRINTTEMPLATE, PRINTSETUPTEMPLATE,
- "Print", dllModule).Execute() == IDOK)
- {
- SFXMsgBox(HWindow, "Nothing to print", "Print Information",
- MB_ICONINFORMATION, Style);
- }
- }
-
- void
- TViewWindow::CmPrintHelp()
- {
- PrintData.Flags = PD_COLLATE | PD_DISABLEPRINTTOFILE | PD_SHOWHELP;
- char far* PRINTTEMPLATE = GetSFXTemplate(Class, DLG_PRINT);
- char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
-
- if (TPrintDialog(this, PrintData, PRINTTEMPLATE, PRINTSETUPTEMPLATE,
- "Print", dllModule).Execute() == IDOK)
- {
- SFXMsgBox(HWindow, "Nothing to print", "Print Information",
- MB_ICONINFORMATION, Style);
- }
- }
-
- void
- TViewWindow::CmPrintSetup()
- {
- PrintData.Flags = PD_PRINTSETUP;
- char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
-
- if (TPrintDialog(this, PrintData, 0, PRINTSETUPTEMPLATE, 0,
- dllModule).Execute() == IDOK)
- {
- SFXMsgBox(HWindow, "Nothing to print", "Print Information", MB_ICONINFORMATION, Style);
- }
- }
-
- void
- TViewWindow::CmPrintSetupHelp()
- {
- PrintData.Flags = PD_PRINTSETUP;
- char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
-
- if (TPrintDialog(this, PrintData, 0, PRINTSETUPTEMPLATE, 0,
- dllModule).DoExecute() == IDOK)
- {
- SFXMsgBox(HWindow, "Nothing to print", "Print Information",
- MB_ICONINFORMATION, Style);
- }
- }
-
- void
- TViewWindow::CmOpenDir()
- {
- /* Uses the SFXDirBox function to display a 'Open File' style directory dialog box
- */
- char szDir[MAXDIR];
-
- if (SFXDirBox(HWindow, "Select Directory", szDir, (UINT)OFN_NOCHANGEDIR, Style) == IDOK)
- {
- SFXMsgBox(HWindow, szDir, "You Selected", MB_ICONEXCLAMATION, Style);
- }
- }
-
- void
- TViewWindow::CmOpenDirHelp()
- {
- /* Uses the new SFXOpenDir function to display a 'Open File' style directory dialog box
- */
- char szDir[MAXDIR];
- int id = GetSFXTemplateId(Class, DLG_OPENDIR);
- DWORD flags = OFN_SHOWHELP;
-
- if (SFXOpenDir(HWindow, szDir, "Change Directory", flags, id))
- {
- SFXMsgBox(HWindow, szDir, "You Selected", MB_ICONINFORMATION, Style);
- }
- }
-
- void
- TViewWindow::CmExitWindow()
- {
- CloseWindow();
- }
-
- // Search menu items
-
- void
- TViewWindow::CmSearchFind()
- {
- if (!SearchDialog)
- {
- SearchData.FindWhat = "SearchString";
- SearchData.Flags |= FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD;
- int FINDTEMPLATE = GetSFXTemplateId(Class, DLG_FIND);
- SearchDialog = new TFindDialog(this, SearchData, FINDTEMPLATE, "Find Text", dllModule);
- SearchDialog->Create();
- }
- }
-
- void
- TViewWindow::CmSearchFindHelp()
- {
- if (!SearchDialog)
- {
- SearchData.FindWhat = "SearchString";
- SearchData.Flags |= FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_SHOWHELP;
- int FINDTEMPLATE = GetSFXTemplateId(Class, DLG_FIND);
- SearchDialog = new TFindDialog(this, SearchData, FINDTEMPLATE, "Find Text", dllModule);
- SearchDialog->Create();
- }
- }
-
- void
- TViewWindow::CmSearchReplace()
- {
- if (!SearchDialog)
- {
- SearchData.FindWhat = "SearchString";
- SearchData.ReplaceWith = "ReplaceString";
- SearchData.Flags |= FR_WHOLEWORD;
- int REPLACETEMPLATE = GetSFXTemplateId(Class, DLG_REPLACE);
- SearchDialog = new TReplaceDialog(this, SearchData, REPLACETEMPLATE,
- "Replace Text", dllModule);
- SearchDialog->Create();
- }
- }
-
- void
- TViewWindow::CmSearchReplaceHelp()
- {
- if (!SearchDialog)
- {
- SearchData.FindWhat = "SearchString";
- SearchData.ReplaceWith = "ReplaceString";
- SearchData.Flags |= FR_WHOLEWORD | FR_SHOWHELP;
- int REPLACETEMPLATE = GetSFXTemplateId(Class, DLG_REPLACE);
- SearchDialog = new TReplaceDialog(this, SearchData, REPLACETEMPLATE,
- "Replace Text", dllModule);
- SearchDialog->Create();
- }
- }
-
- // Color menu items
-
- void
- TViewWindow::CmBasicColor()
- {
- /* Uses the new SFXChooseColor function to display a "ChooseColor" common dialog box
- */
- COLORREF rgbColor = RGB(0, 128, 0);
- DWORD flags = CC_RGBINIT;
- int id = GetSFXTemplateId(Class, DLG_COLOR);
-
- if (SFXChooseColor(HWindow, (COLORREF far*)&rgbColor, flags, id,
- FALSE/*, (COLORREF far*)custColors*/))
- {
- delete Brush;
- Brush = new TBrush(rgbColor);
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmBasicColorHelp()
- {
- Choose.Flags = CC_RGBINIT | CC_SHOWHELP;
- int COLORTEMPLATE = GetSFXTemplateId(Class, DLG_COLOR);
-
- if (TChooseColorDialog(this, Choose, COLORTEMPLATE, "Choose Color",
- dllModule).Execute() == IDOK)
- {
- delete Brush;
- Brush = new TBrush(Choose.Color);
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmExtendedColor()
- {
- /* Uses the new SFXChooseColor function to display an "extended color" common dialog box
- */
- COLORREF rgbColor = RGB(0, 128, 0);
- DWORD flags = CC_RGBINIT | CC_FULLOPEN;
- int id = GetSFXTemplateId(Class, DLG_EXCOLOR);
-
- if (SFXChooseColor(HWindow, (COLORREF far*)&rgbColor, flags, id, TRUE))
- {
- delete Brush;
- Brush = new TBrush(rgbColor);
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmExtendedColorHelp()
- {
- Choose.Flags = CC_RGBINIT | CC_FULLOPEN | CC_SHOWHELP;
- int COLORTEMPLATE = GetSFXTemplateId(Class, DLG_EXCOLOR);
-
- if (TChooseColorDialog(this, Choose, COLORTEMPLATE, "Choose Color",
- dllModule).Execute() == IDOK)
- {
- delete Brush;
- Brush = new TBrush(Choose.Color);
- UpdateClientArea();
- }
- }
-
- // Font menu items
-
- void
- TViewWindow::CmBasicFont()
- {
- FontData.Color = TColor::Black;
- FontData.Flags = CF_FORCEFONTEXIST | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
- int FONTTEMPLATE = GetSFXTemplateId(Class, DLG_FONT);
-
- if (TChooseFontDialog(this, FontData, FONTTEMPLATE, "Choose Font",
- dllModule).Execute() == IDOK)
- {
- delete Font;
- Color = FontData.Color;
- Font = new TFont(&FontData.LogFont);
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmBasicFontExtraFlags()
- {
- /* Uses the new SFXChooseFont function to display a "ChooseFont" common dialog box
- */
- DWORD flags = CF_EFFECTS | CF_BOTH | CF_APPLY | CF_SHOWHELP;
- int id = GetSFXTemplateId(Class, DLG_FONT);
-
- if (SFXChooseFont(HWindow, (LOGFONT far*)&FontData.LogFont, flags, id,
- FALSE, (COLORREF far*)&Color))
- {
- delete Font;
- Font = new TFont(&FontData.LogFont);
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmExtendedFont()
- {
- FontData.Color = TColor::Black;
- FontData.Flags = CF_FORCEFONTEXIST | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
- int FONTTEMPLATE = GetSFXTemplateId(Class, DLG_EXFONT);
-
- if (TChooseFontDialog(this, FontData, FONTTEMPLATE, "Choose Font",
- dllModule).Execute() == IDOK)
- {
- delete Font;
- Color = FontData.Color;
- Font = new TFont(&FontData.LogFont);
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmExtendedFontApply()
- {
- /* Uses the new SFXChooseFont function to display an "extended font" common dialog box
- */
- DWORD flags = CF_APPLY | CF_SCREENFONTS | CF_FORCEFONTEXIST;
- int id = GetSFXTemplateId(Class, DLG_EXFONT);
-
- if (SFXChooseFont(HWindow, (LOGFONT far*)&FontData.LogFont, flags, id, TRUE))
- {
- delete Font;
- Color = TColor::Black;
- Font = new TFont(&FontData.LogFont);
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmExtendedFontHelp()
- {
- FontData.Color = TColor::Black;
- FontData.Flags = CF_FORCEFONTEXIST | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_SHOWHELP;
- int FONTTEMPLATE = GetSFXTemplateId(Class, DLG_EXFONT);
-
- if (TChooseFontDialog(this, FontData, FONTTEMPLATE, "Choose Font",
- dllModule).Execute() == IDOK)
- {
- delete Font;
- Color = FontData.Color;
- Font = new TFont(&FontData.LogFont);
- UpdateClientArea();
- }
- }
-
- // Objects menu items
-
- void
- TViewWindow::CmButton()
- {
- TButtonDialog(this, "ButtonDialog").Execute();
- }
-
- void
- TViewWindow::CmStatic()
- {
- TStaticDialog(this, "StaticDialog").Execute();
- }
-
- void
- TViewWindow::CmShade()
- {
- TDefaultDialog(this, "ShadeDialog").Execute();
- }
-
- void
- TViewWindow::CmCheck()
- {
- TDefaultDialog(this, "CheckDialog").Execute();
- }
-
- void
- TViewWindow::CmRadio()
- {
- TDefaultDialog(this, "RadioDialog").Execute();
- }
-
- void
- TViewWindow::CmControl()
- {
- TControlDialog(this, "ControlDialog").Execute();
- }
-
- void
- TViewWindow::CmToolbar()
- {
- TToolbarDialog(this, "ToolbarDialog").Execute();
- }
-
- void
- TViewWindow::CmMessage()
- {
- TMessageDialog(this, "MessageInputDialog").Execute();
- }
-
- void
- TViewWindow::CmWindows()
- {
- SFXMsgBox(HWindow, "To view the various SpecialFX window, frame window "
- "and MDI frame objects compile the sample applications "
- "in your examples directory.", "Information",
- MB_OK | MB_ICONINFORMATION, Style);
- }
-
- void
- TViewWindow::CmTop()
- {
- OldToolbarPos = ToolbarPos;
- if (ToolbarPos != CM_TOP)
- {
- /* An SFX Toolbar sizes itself according to the specified flags and the size
- * of the first button's bitmap, so cx and cy can be zero. x and y have
- * no effect on an aligned toolbar (here its top aligned as defined by MTB_TOP)
- * and are set to zero. To re position a toolbar you have to destroy the old
- * one and create a new one. When you do, you will have to make the MTB_ROWXX and
- * MTB_COLOUMNXX flags values appropriate for the new positon and change the
- * toolbar style flags. The style flags are MTB_TOP, MTB_LEFT, MTB_RIGHT,
- * MTB_BOTTOM, MTB_FLOAT and MTB_STATUS.
- */
- ToolbarPos = CM_TOP;
- if (Toolbar && Toolbar->HWindow)
- DestroyWindow(Toolbar->HWindow);
- Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804", 0, 0, TRUE);
- Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_TOP | MTB_BITMAPBUTTON | MTB_RADIO;
- Toolbar->Create();
-
- /* hToolWnd is created with the MTB_RADIO flag so its buttons behave as
- * a set of mutually exclusive radio buttons. WM_SETCHECK is a private message
- * that checks/unchecks a toolbar button. wParam is the button ID and lParam
- * is the check flag. 1 checks the button and 0 unchecks it. TSFXToolbar's
- * CheckTool and UncheckTool member functions send this message for you.
- */
- Toolbar->CheckTool(Tool);
-
- /* GetSFXObject retrieves the handle of the specified stock object. Do not delete
- * these handles as they are created, used and deleted by SFX200.DLL.
- * Here it sets the font for the toolbar's static control to the stock FINE_FONT
- * object (= MS San Serif 8).
- */
- Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmFloat()
- {
- OldToolbarPos = ToolbarPos;
- if (ToolbarPos != CM_FLOAT)
- {
- ToolbarPos = CM_FLOAT;
- if (Toolbar && Toolbar->HWindow)
- DestroyWindow(Toolbar->HWindow);
- UpdateClientArea();
- Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804",
- GetSystemMetrics(SM_CXSCREEN), 0, TRUE);
- Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_FLOAT | MTB_BITMAPBUTTON |
- MTB_RADIO | MTB_3DFRAME | WS_CAPTION;
- Toolbar->Create();
- Toolbar->CheckTool(Tool);
- Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
- }
- }
-
- void
- TViewWindow::CmBottom()
- {
- OldToolbarPos = ToolbarPos;
- if (ToolbarPos != CM_BOTTOM)
- {
- ToolbarPos = CM_BOTTOM;
- if (Toolbar != 0 && Toolbar->HWindow != 0)
- DestroyWindow(Toolbar->HWindow);
- Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804", 0, 0, TRUE);
- Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_BOTTOM | MTB_BITMAPBUTTON | MTB_RADIO;
- Toolbar->Create();
- Toolbar->CheckTool(Tool);
- Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmStatus()
- {
- OldToolbarPos = ToolbarPos;
- if (ToolbarPos != CM_STATUS)
- {
- ToolbarPos = CM_STATUS;
- if (Toolbar && Toolbar->HWindow)
- DestroyWindow(Toolbar->HWindow);
- Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804", 0, 0, TRUE);
- Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_STATUS | MTB_BITMAPBUTTON | MTB_RADIO;
- Toolbar->Create();
- Toolbar->CheckTool(Tool);
- Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
- UpdateClientArea();
- }
- }
-
- void
- TViewWindow::CmHints()
- {
- /* UseHints is a switches on and off Flyover hints. This code clears the
- * toolbar/status bar text if the cursor is inside the main window but out
- * side the toolbar. The code that sets the text is in the TToolbar
- * EvMouseMove method.
- */
- if (!UseHints)
- Toolbar->SetText("");
- UseHints = !UseHints;
- }
-
- void
- TViewWindow::CmHelp()
- {
- WinHelp("SFX200.HLP", HELP_INDEX, 0);
- }
-
- void
- TViewWindow::CmAbout()
- {
- TDefaultDialog(this, "AboutDialog").Execute();
- }
-
- // TViewApp class
-
- class TViewApp : public TApplication
- {
- public:
- TViewApp() : TApplication() {}
- void InitMainWindow();
- };
-
- void
- TViewApp::InitMainWindow()
- {
- MainWindow = new TViewWindow(0, "Object Viewer");
- MainWindow->SetIcon(this, APPNAME);
- nCmdShow = SW_SHOWMAXIMIZED;
- }
-
- int
- OwlMain(int /*argc*/, char* /*argv*/ [])
- {
- GetSFXVersion();
- return TViewApp().Run();
- }
-
-
-