home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / windows / c / mobjm260 / sfxview.cp_ / sfxview.cp
Encoding:
Text File  |  1994-09-06  |  63.0 KB  |  2,317 lines

  1. //    Microworks ObjectMate 2.6
  2. //
  3. //  "Object Viewer"
  4. //
  5. //    Copyright 1992-94 Microworks Sydney, Australia.
  6. //                                                        
  7. //  SFXVIEW.CPP
  8.  
  9. #define  APPNAME "SFXVIEW"
  10.  
  11. #include <owl\owlpch.h>
  12. #include <sfx\sfx200.h>
  13. #include <sfx\sframe.h>
  14. #include <sfx\stoolbar.h>
  15. #include <sfx\sstatic.h>
  16. #include <sfx\smenu.h>
  17. #include <owl\opensave.h>
  18. #include <owl\printdia.h>
  19. #include <owl\findrepl.h>
  20. #include <owl\chooseco.h>
  21. #include <owl\choosefo.h>
  22. #include <dir.h>
  23. #include "sfxview.h"
  24.  
  25. //    Global variables
  26.  
  27. BOOL UseHints;
  28. char Class[25];
  29. int  Tool;
  30. UINT Style;
  31.  
  32. //    Custom color array for TChooseColorDialog
  33.  
  34. static TColor custColors[16] =
  35. {
  36.     0x219369L, 0x2F31D5L, 0x28A207L, 0x373399L,
  37.     0x49F470L, 0x56B500L, 0x6666FFL, 0x737700L,
  38.     0x824800L, 0x976900L, 0xA19A00L, 0xBBFB00L,
  39.     0xCD9C00L, 0xD3CD00L, 0xE8FE00L, 0xFA3F00L
  40. };
  41.  
  42. //    TDefaultDialog
  43.  
  44. class TDefaultDialog : public TDialog
  45. {
  46.   public:
  47.     TDefaultDialog(TWindow*, TResId);
  48.     void SetupWindow();
  49.   DECLARE_RESPONSE_TABLE(TDefaultDialog);
  50. };
  51.  
  52. DEFINE_RESPONSE_TABLE1(TDefaultDialog, TDialog)
  53. END_RESPONSE_TABLE;
  54.  
  55. TDefaultDialog::TDefaultDialog(TWindow* parent, TResId resId)
  56.     :TDialog(parent, resId),
  57.      TWindow(parent)
  58. {
  59. }
  60.  
  61. void
  62. TDefaultDialog::SetupWindow()
  63. {
  64.     TDialog::SetupWindow();
  65.  
  66.     /* CenterWindow centers HWindow over the desktop window if the (first)
  67.      * parent window argument to zero.
  68.      */
  69.     CenterWindow(0, HWindow);
  70. }
  71.  
  72. //    TChildDialog
  73.  
  74. class TChildDialog : public TDialog
  75. {
  76.   public:
  77.     TChildDialog(TWindow*, TResId);
  78.     void SetupWindow();
  79.     void CmOk();
  80.     void CmCancel();
  81.   DECLARE_RESPONSE_TABLE(TChildDialog);
  82. };
  83.  
  84. DEFINE_RESPONSE_TABLE1(TChildDialog, TDialog)
  85.   EV_CHILD_NOTIFY(IDOK, BN_CLICKED, CmOk),
  86.   EV_CHILD_NOTIFY(IDCANCEL, BN_CLICKED, CmCancel),
  87. END_RESPONSE_TABLE;
  88.  
  89. TChildDialog::TChildDialog(TWindow* parent, TResId resId)
  90.     :TDialog(parent, resId),
  91.      TWindow(parent)
  92. {
  93. }
  94.  
  95. void
  96. TChildDialog::SetupWindow()
  97. {
  98.     TDialog::SetupWindow();
  99.  
  100.     /* Adding 'MWS_SFXCAPTION' to the style flags forces the dialog to display a
  101.      * Chicago-style caption, like the Object Viewer main window. Since this dialog
  102.      * doesn't have a class icon, the main window's class icon appears in the title
  103.      * bar. Both the caption and icon are displayed flush left. You can set the icon
  104.      * displayed on the title bar by sending the dialog a WM_SETBITMAP message.
  105.      */
  106.     SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
  107.     CenterWindow(0, HWindow);
  108.  
  109.     /* To be neat and tidy, when I display a dialog box from within another
  110.      * dialog box I like to hide the parent dialog, show the child dialog,
  111.      * and then redisplay the parent dialog when the child dialog closes.
  112.      */
  113.     Parent->ShowWindow(SW_HIDE);
  114. }
  115.  
  116. void
  117. TChildDialog::CmOk()
  118. {
  119.     TDialog::CmOk();
  120.     Parent->ShowWindow(SW_NORMAL);
  121. }
  122.  
  123. void
  124. TChildDialog::CmCancel()
  125. {
  126.     TDialog::CmCancel();
  127.     Parent->ShowWindow(SW_NORMAL);
  128. }
  129.  
  130. //    TButtonDialog
  131.  
  132. class TButtonDialog : public TDialog
  133. {
  134.   public:
  135.     TButtonDialog(TWindow*, TResId);
  136.     void SetupWindow();
  137.     void CmStdBtn();
  138.     void CmBitBtn();
  139.     void CmTextBtn();
  140.   DECLARE_RESPONSE_TABLE(TButtonDialog);
  141. };
  142.  
  143. DEFINE_RESPONSE_TABLE1(TButtonDialog, TDialog)
  144.   EV_CHILD_NOTIFY(IDSTDBTN, BN_CLICKED, CmStdBtn),
  145.   EV_CHILD_NOTIFY(IDBITBTN, BN_CLICKED, CmBitBtn),
  146.   EV_CHILD_NOTIFY(IDTEXTBTN, BN_CLICKED, CmTextBtn),
  147. END_RESPONSE_TABLE;
  148.  
  149. TButtonDialog::TButtonDialog(TWindow* parent, TResId resId)
  150.     :TDialog(parent, resId),
  151.      TWindow(parent)
  152. {
  153. }
  154.  
  155. void
  156. TButtonDialog::SetupWindow()
  157. {
  158.     TDialog::SetupWindow();
  159.     SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
  160.     CenterWindow(0, HWindow);
  161. }
  162.  
  163. void
  164. TButtonDialog::CmStdBtn()
  165. {
  166.     TChildDialog(this, "StandardButtonDialog").Execute();
  167. }
  168.  
  169. void
  170. TButtonDialog::CmBitBtn()
  171. {
  172.     TChildDialog(this, "BitmapButtonDialog").Execute();
  173. }
  174.  
  175. void
  176. TButtonDialog::CmTextBtn()
  177. {
  178.     TChildDialog(this, "TextButtonDialog").Execute();
  179. }
  180.  
  181. //    TStaticDialog
  182.  
  183. class TStaticDialog : public TDialog
  184. {
  185.   public:
  186.     TStaticDialog(TWindow*, TResId);
  187.     void SetupWindow();
  188.     void CmStatBmp();
  189.     void CmStatText();
  190.   DECLARE_RESPONSE_TABLE(TStaticDialog);
  191. };
  192.  
  193. DEFINE_RESPONSE_TABLE1(TStaticDialog, TDialog)
  194.   EV_CHILD_NOTIFY(IDSTATBMP, BN_CLICKED, CmStatBmp),
  195.   EV_CHILD_NOTIFY(IDSTATTEXT, BN_CLICKED, CmStatText),
  196. END_RESPONSE_TABLE;
  197.  
  198. TStaticDialog::TStaticDialog(TWindow* parent, TResId resId)
  199.     :TDialog(parent, resId),
  200.      TWindow(parent)
  201. {
  202. }
  203.  
  204. void
  205. TStaticDialog::SetupWindow()
  206. {
  207.     TDialog::SetupWindow();
  208.     SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
  209.     CenterWindow(0, HWindow);
  210. }
  211.  
  212. void
  213. TStaticDialog::CmStatBmp()
  214. {
  215.     TChildDialog(this, "BitmapAlignmentDialog").Execute();
  216. }
  217.  
  218. void
  219. TStaticDialog::CmStatText()
  220. {
  221.     TChildDialog(this, "TextAlignmentDialog").Execute();
  222. }
  223.  
  224. //    TControlDialog
  225.  
  226. class TControlDialog : public TDialog
  227. {
  228.   public:
  229.     TControlDialog(TWindow*, TResId);
  230.     ~TControlDialog();
  231.     int     i;
  232.     void    SetupWindow();
  233.     void    EvTimer(UINT /*timerId*/);
  234.     LRESULT EvSFXCtlColor(WPARAM, LPARAM);
  235.   DECLARE_RESPONSE_TABLE(TControlDialog);
  236. };
  237.  
  238. DEFINE_RESPONSE_TABLE1(TControlDialog, TDialog)
  239.   EV_WM_TIMER,
  240.   EV_MESSAGE(WM_SFXCTLCOLOR, EvSFXCtlColor),
  241. END_RESPONSE_TABLE;
  242.  
  243. TControlDialog::TControlDialog(TWindow* parent, TResId resId)
  244.     :TDialog(parent, resId),
  245.      TWindow(parent)
  246. {
  247. }
  248.  
  249. TControlDialog::~TControlDialog()
  250. {
  251.     KillTimer(IDTIMER);
  252. }
  253.  
  254. void
  255. TControlDialog::SetupWindow()
  256. {
  257.     TDialog::SetupWindow();
  258.     SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
  259.     CenterWindow(0, HWindow);
  260.  
  261.     /* For display purposes, this timer sets the rate at which the percent
  262.      * gauge is updated.
  263.      */
  264.     SetTimer(IDTIMER, 500);
  265.     i = 0;
  266. }
  267.  
  268. void
  269. TControlDialog::EvTimer(UINT /*timerId*/)
  270. {
  271.     i++;
  272.     if (i <= 100)
  273.     {
  274.         /* WM_DRAWPERCENT is a private messge that you send to a percent gauge
  275.          * when you want to update the percentage displayed. wParam is the percentage
  276.          * to draw and must be a value between 0% and 100%. A value of 100% draws
  277.          * a full percent gauge. lParam is zero. The return value is 1 when the
  278.          * gauge reaches 100%. Otherwise its zero.    When you derive an object for a
  279.          * percent gauge from TSFXPercent (defined in SPERCENT.H) you can use its
  280.          *'SetPercent' and 'Reset' member functions instead of sending these messages.
  281.          */
  282.         if (::SendMessage(GetDlgItem(109), WM_DRAWPERCENT, i, 0) == 1)
  283.         {
  284.             //     WM_RESETPERCENT resets the percentage displayed to zero
  285.             ::SendMessage(GetDlgItem(109), WM_RESETPERCENT, 0, 0);
  286.             i = 0;
  287.         }
  288.         if (::SendMessage(GetDlgItem(110), WM_DRAWPERCENT, i*2, 0) == 1)
  289.         {
  290.             ::SendMessage(GetDlgItem(110), WM_RESETPERCENT, 0, 0);
  291.         }
  292.     }
  293. }
  294.  
  295. LRESULT
  296. TControlDialog::EvSFXCtlColor(WPARAM hdc, LPARAM lParam)
  297. {
  298.     /* An SFX control sends this message to its parent when its about to be painted.
  299.      * WM_SFXCTLCOLOR can be used to set the colors in various controls. There
  300.      * are 8 SFXCTLCOLOR_XXX constants defined for this message. You cannot use
  301.      * the return value to pass a brush or pen handle like WM_CTLCOLOR. Instead you
  302.      * must send a private message back to the control - eg WM_SETBRUSH, WM_SETPEN.
  303.      * The message you need to send depends on the control. For this control (SFXPercent)
  304.      * you need to send a WM_SETBRUSH message if you want to change the percent
  305.      * gauge background color. The text colors that look the best have been
  306.      * assigned bit flags. For other colors you will need to use the SetTextColor
  307.      * function to set the percent gauge text color.
  308.      *
  309.      * WM_SFXCTLCOLOR's parameters are the same as WM_CTLCOLOR's. wParam
  310.      * is the display context for the control, LOWORD of lParam is its window handle
  311.      * and HIWORD of lParam is the control identifier. For SFXPercent, this identifier
  312.      * is SFXCTLCOLOR_PERCENT.
  313.      */
  314.     if (HIWORD(lParam) == SFXCTLCOLOR_PERCENT)
  315.     {
  316.         ::SetBkMode((HDC)hdc, TRANSPARENT);
  317.  
  318.         if (::GetDlgCtrlID((HWND)LOWORD(lParam)) == 109)
  319.             ::SetTextColor((HDC)hdc, RGB(0, 0, 255));
  320.         else
  321.             ::SetTextColor((HDC)hdc, RGB(0, 255, 0));
  322.  
  323.         /* GetSFXObject is defined in the SFX200.H. Here its used to retrieve
  324.          * a handle to the 'stock' red brush. Do not delete this handle!
  325.          */
  326.         if (::GetDlgCtrlID((HWND)LOWORD(lParam)) == 110)
  327.             ::SendMessage((HWND)LOWORD(lParam), WM_SETBRUSH, (UINT)GetSFXObject(RED_BRUSH), 0);
  328.     }
  329.     return 0;
  330. }
  331.  
  332. //    TPopupToolbar
  333.  
  334. class TPopupToolbar : public TSFXToolbar
  335. {
  336.   public:
  337.     TPopupToolbar(TWindow*, int, const char far*, int, int, BOOL);
  338.     BOOL            EvNCActivate(BOOL);
  339.     virtual LRESULT EvCommand(UINT, HWND, UINT);
  340.   DECLARE_RESPONSE_TABLE(TPopupToolbar);
  341. };
  342.  
  343. DEFINE_RESPONSE_TABLE2(TPopupToolbar, TSFXToolbar, TWindow)
  344.   EV_WM_NCACTIVATE,
  345. END_RESPONSE_TABLE;
  346.  
  347. TPopupToolbar::TPopupToolbar(TWindow* parent, int id, const char far* title,
  348.                              int x, int y, BOOL isChild)
  349.     :TSFXToolbar(parent, id, title, x, y, isChild)
  350. {
  351. }
  352.  
  353. LRESULT
  354. TPopupToolbar::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
  355. {
  356.     char szTemp[50];
  357.  
  358.     if (notifyCode == BN_CLICKED)
  359.     {
  360.         wsprintf(szTemp, "You pressed button %u", id);
  361.         SFXMsgBox(HWindow, szTemp, "Information", MB_ICONINFORMATION, 0);
  362.     }
  363.     else
  364.         TSFXToolbar::EvCommand(id, hWndCtl, notifyCode);
  365.  
  366.     return 0;
  367. }
  368.  
  369. BOOL
  370. TPopupToolbar::EvNCActivate(BOOL active)
  371. {
  372.     /* To have the active state the two popup toolbars match the active state of their
  373.      * parent this event is passed on to the parent's EvNCActivate response and TRUE is
  374.      * returned to prevent any further processing.
  375.      */
  376.     Parent->HandleMessage(WM_NCACTIVATE, active, 0);
  377.     return TRUE;
  378. }
  379.  
  380. //    TToolbarDialog
  381.  
  382. class TToolbarDialog : public TDialog
  383. {
  384.   public:
  385.     TToolbarDialog(TWindow*, TResId);
  386.     TPopupToolbar* TB1;
  387.     TPopupToolbar* TB2;
  388.     TSFXToolbar* TB3;
  389.     void            SetupWindow();
  390.     BOOL            EvNCActivate(BOOL);
  391.     virtual LRESULT EvCommand(UINT, HWND, UINT);
  392.   DECLARE_RESPONSE_TABLE(TToolbarDialog);
  393. };
  394.  
  395. DEFINE_RESPONSE_TABLE1(TToolbarDialog, TDialog)
  396.   EV_WM_NCACTIVATE,
  397. END_RESPONSE_TABLE;
  398.  
  399. TToolbarDialog::TToolbarDialog(TWindow* parent, TResId resId)
  400.     :TDialog(parent, resId),
  401.      TWindow(parent)
  402. {
  403.     /* Creates a popup toolbar. You only need to specifiy MTB_3DFRAME if you
  404.      * want the toolbar to have a gray 3-dimensional frame. Specifying a WS_XXX
  405.      * frame style with MTB_3DFRAME has no effect. Popup toolbars are created
  406.      * with the WS_POPUPWINDOW style, not WS_OVERLAPPED or WS_OVERLAPPEDWINDOW.
  407.      */
  408.     TB1 = new TPopupToolbar(this, 201, "Popup Toolbar,304,305,306,307,308,309", 10, 30, FALSE);
  409.     TB1->Attr.Style |= MTB_ROW1 | MTB_COLUMN6 | MTB_BITMAPBUTTON;
  410.     TB2 = new TPopupToolbar(this, 202, "?,301,302,303,304,305,306", 10, 100, FALSE);
  411.     TB2->Attr.Style |=  MTB_ROW3 | MTB_COLUMN2 | MTB_BITMAPBUTTON | MTB_RADIO;
  412.     TB3 = new TSFXToolbar(this, 102);
  413. }
  414.  
  415. void
  416. TToolbarDialog::SetupWindow()
  417. {
  418.     TDialog::SetupWindow();
  419.  
  420.     /* Sets the new SFXCaption style - just for show! Since these dialogs don't have
  421.      * an icon they display their parents' class icon.
  422.      */
  423.     SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
  424.  
  425.     /*    Sets the toolbar/status bar font to the stock FINE_FONT object
  426.      */
  427.     TB3->SetFont((HFONT)GetSFXObject(FINE_FONT));
  428.  
  429.     /* Sets the text in the toolbar's static control. Floating toolbars don't
  430.      * have a static control.
  431.      */
  432.     TB3->SetText(" This is where text appears in a status bar");
  433.     CenterWindow(0, HWindow);
  434. }
  435.  
  436. LRESULT
  437. TToolbarDialog::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
  438. {
  439.     char szTemp[50];
  440.  
  441.     if (id > 2 && notifyCode == BN_CLICKED)
  442.     {
  443.         wsprintf(szTemp, "You pressed button %u", id);
  444.         SFXMsgBox(HWindow, szTemp, "Information", MB_ICONINFORMATION, 0);
  445.     }
  446.     else
  447.         TDialog::EvCommand(id, hWndCtl, notifyCode);
  448.  
  449.     return 0;
  450. }
  451.  
  452. BOOL
  453. TToolbarDialog::EvNCActivate(BOOL active)
  454. {
  455.     TPoint point;
  456.  
  457.     /* This dialog controls the active state of its toolbars so that they all activate
  458.      * and inactivate together.
  459.      */
  460.     GetCursorPos(point);
  461.     if (IsNCActive(HWindow) && (PtInWindow(TB1->HWindow, point) ||
  462.         PtInWindow(TB2->HWindow, point) || PtInWindow(HWindow, point)))
  463.     {
  464.         /* If this dialog's caption is active (IsNCActive = TRUE) and the cursor is
  465.          * in either of the toolbars or this dialog (PtInWindow = TRUE) then all the
  466.          * captions are already active, so return TRUE to prevent any further processing.
  467.          * This prevents unnecessary flicker.
  468.          */
  469.         return TRUE;
  470.     }
  471.  
  472.     /* The WM_NCACTIVATE message can't be returned to the popup toolbar window function
  473.      * because that would create a loop and the program would crash. Fortunately,
  474.      * SFXDefWindowProc can be used to draw the active state since its WM_NCACTIVATE
  475.      * response is the same as SFXToolbar's and both pass the message onto DefWindowProc.
  476.      */
  477.     SFXDefWindowProc(TB1->HWindow, WM_NCACTIVATE, active, 0);
  478.     SFXDefWindowProc(TB2->HWindow, WM_NCACTIVATE, active, 0);
  479.     return TDialog::EvNCActivate(active);
  480. }
  481.  
  482. //    TMessageDialog
  483.  
  484. class TMessageDialog : public TDialog
  485. {
  486.   public:
  487.     TMessageDialog(TWindow*, TResId);
  488.     UINT            msgStyle;
  489.     void            SetupWindow();
  490.     virtual LRESULT EvCommand(UINT, HWND, UINT);
  491.   DECLARE_RESPONSE_TABLE(TMessageDialog);
  492. };
  493.  
  494. DEFINE_RESPONSE_TABLE1(TMessageDialog, TDialog)
  495. END_RESPONSE_TABLE;
  496.  
  497. TMessageDialog::TMessageDialog(TWindow* parent, TResId resId)
  498.     :TDialog(parent, resId),
  499.      TWindow(parent)
  500. {
  501. }
  502.  
  503. void
  504. TMessageDialog::SetupWindow()
  505. {
  506.     TDialog::SetupWindow();
  507.  
  508.     SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | MWS_SFXCAPTION);
  509.  
  510.     /* SFX check boxes and radio buttons respond the standard Windows
  511.      * button messages. Here BM_SETCHECK is sent to check the first radiobutton.
  512.      * Since no ObjectWindows object was created for the radio button(s) GetDlgItem
  513.      * has to be used.
  514.      */
  515.     ::SendMessage((HWND)GetDlgItem(IDSFXFRAME), BM_SETCHECK, 1, 0);
  516.  
  517.     /* A NULL value for the parent window handle in a call to CenterWindow
  518.      * will center the specified window (in this case HWindow) over the desktop
  519.      * window.
  520.      */
  521.     CenterWindow(0, HWindow);
  522.     msgStyle = MWS_SFXFRAME;
  523. }
  524.  
  525. LRESULT
  526. TMessageDialog::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
  527. {
  528.     int  reply;
  529.     char Text[144] = "\0";
  530.  
  531.     /* These button respones use the SFXInputBox and SFXMsgBox functions to display
  532.      * the 7 Input/Message box styles and the message box button combinations.
  533.      */
  534.     if (notifyCode == BN_CLICKED)
  535.     {
  536.         switch (id)
  537.         {
  538.             case IDSFXFRAME:
  539.                 msgStyle = MWS_SFXFRAME;
  540.                 break;
  541.  
  542.             case IDGRAY:
  543.                 msgStyle = MWS_GRAY;
  544.                 break;
  545.  
  546.             case IDGLAZE:
  547.                 msgStyle = MWS_GLAZE;
  548.                 break;
  549.  
  550.             case IDSTEEL:
  551.                 msgStyle = MWS_STEEL;
  552.                 break;
  553.  
  554.             case ID3DGRAY:
  555.                 msgStyle = MWS_3DGRAY;
  556.                 break;
  557.  
  558.             case ID3DGLAZE:
  559.                 msgStyle = MWS_3DGLAZE;
  560.                 break;
  561.  
  562.             case ID3DSTEEL:
  563.                 msgStyle = MWS_3DSTEEL;
  564.                 break;
  565.  
  566.             case IDMBOK:
  567.                 reply = SFXInputBox(HWindow, "Password", "Enter password:", Text,
  568.                                     sizeof(Text), msgStyle);
  569.                 if (reply == IDOK)
  570.                     SFXMsgBox(HWindow, Text, "Your password is:",
  571.                               MB_OK | MB_ICONASTERISK, msgStyle);
  572.                 break;
  573.  
  574.             case IDMBOKCANCEL:
  575.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  576.                                     sizeof(Text), msgStyle);
  577.                 if (reply == IDOK)
  578.                     SFXMsgBox(HWindow, Text, "You entered:",
  579.                               MB_OKCANCEL | MB_ICONINFORMATION, msgStyle);
  580.                 break;
  581.  
  582.             case IDMBABORTRETRYIGNORE:
  583.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  584.                                     sizeof(Text), msgStyle);
  585.                 if (reply == IDOK)
  586.                     SFXMsgBox(HWindow, Text, "You entered:",
  587.                               MB_ABORTRETRYIGNORE | MB_ICONQUESTION, msgStyle);
  588.                 break;
  589.  
  590.             case IDMBRETRYCANCEL:
  591.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  592.                                     sizeof(Text), msgStyle);
  593.                 if (reply == IDOK)
  594.                     SFXMsgBox(HWindow, Text, "You entered:",
  595.                               MB_RETRYCANCEL | MB_ICONSTOP, msgStyle);
  596.                 break;
  597.  
  598.             case IDMBYESNO:
  599.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  600.                                     sizeof(Text), msgStyle);
  601.                 if (reply == IDOK)
  602.                     SFXMsgBox(HWindow, Text, "You entered:",
  603.                               MB_YESNO | MB_ICONEXCLAMATION, msgStyle);
  604.                 break;
  605.  
  606.             case IDMBYESNOCANCEL:
  607.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  608.                                     sizeof(Text), msgStyle);
  609.                 if (reply == IDOK)
  610.                     SFXMsgBox(HWindow, Text, "You entered:",
  611.                               MB_YESNOCANCEL | MB_ICONQUESTION, msgStyle);
  612.                 break;
  613.  
  614.             case IDMBGO:
  615.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  616.                                     sizeof(Text), msgStyle);
  617.                 if (reply == IDOK)
  618.                     SFXMsgBox(HWindow, Text, "You entered:",
  619.                               MB_GO | MB_ICONASTERISK, msgStyle);
  620.                 break;
  621.  
  622.             case IDMBGOSTOP:
  623.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  624.                                     sizeof(Text), msgStyle);
  625.                 if (reply == IDOK)
  626.                     SFXMsgBox(HWindow, Text, "You entered:",
  627.                               MB_GOSTOP | MB_ICONINFORMATION, msgStyle);
  628.                 break;
  629.  
  630.             case IDMBOKCANCELHELP:
  631.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  632.                                     sizeof(Text), msgStyle);
  633.                 if (reply == IDOK)
  634.                     SFXMsgBox(HWindow, Text, "You entered:",
  635.                               MB_OKCANCELHELP | MB_ICONSTOP, msgStyle);
  636.                 break;
  637.  
  638.             case IDMBYESNOHELP:
  639.                 reply = SFXInputBox(HWindow, "Input Box", "Enter something:", Text,
  640.                                     sizeof(Text), msgStyle);
  641.                 if (reply == IDOK)
  642.                     SFXMsgBox(HWindow, Text, "You entered:",
  643.                               MB_YESNOHELP | MB_ICONINFORMATION, msgStyle);
  644.                 break;
  645.  
  646.             case IDHELP:
  647.                 SFXMsgBox(HWindow, "You clicked the help button", "Message Box",
  648.                           MB_ICONINFORMATION, msgStyle);
  649.                 break;
  650.  
  651.             default:
  652.                 TDialog::EvCommand(id, hWndCtl, notifyCode);
  653.         }
  654.     }
  655.     else
  656.         TDialog::EvCommand(id, hWndCtl, notifyCode);
  657.  
  658.     return 0;
  659. }
  660.  
  661. //    TToolbar
  662.  
  663. class TToolbar : public TSFXToolbar
  664. {
  665.   public:
  666.     TToolbar(TWindow*, int, const char far*, int, int, BOOL);
  667.     virtual LRESULT EvCommand(UINT, HWND, UINT);
  668.     void            EvMouseMove(UINT, TPoint&);
  669.   DECLARE_RESPONSE_TABLE(TToolbar);
  670. };
  671.  
  672. DEFINE_RESPONSE_TABLE2(TToolbar, TSFXToolbar, TWindow)
  673.   EV_WM_MOUSEMOVE,
  674. END_RESPONSE_TABLE;
  675.  
  676. TToolbar::TToolbar(TWindow* parent, int id, const char far* title,
  677.                              int x, int y, BOOL isChild)
  678.     :TSFXToolbar(parent, id, title, x, y, isChild)
  679. {
  680. }
  681.  
  682. LRESULT
  683. TToolbar::EvCommand(UINT id, HWND hWndCtl, UINT notifyCode)
  684. {
  685.     /* These are the main toolbar buttons BN_CLICKED messages. A toolbar button's
  686.      * WM_COMMAND message is also sent to the toolbar's parent. If you add a
  687.      * toolbar to a window or dialog and only need to trap the toolbar button
  688.      * clicks you can trap them in the toolbar's parent's WM_COMMAND message
  689.      * reponse. If you do this you must make sure the toolbar button ID's are
  690.      * unique to the parent window or dialog.
  691.      */
  692.     if (notifyCode == BN_CLICKED)
  693.     {
  694.         switch (id)
  695.         {
  696.             case IDT_ONE:
  697.                 strcpy(Class, "SFX3DDlg");
  698.                 Style = MWS_SFXFRAME;
  699.                 Tool = IDT_ONE;
  700.                 break;
  701.  
  702.             case IDT_TWO:
  703.                 strcpy(Class, "SFXGlazeDlg");
  704.                 Style = MWS_3DGLAZE;
  705.                 Tool = IDT_TWO;
  706.                 break;
  707.  
  708.             case IDT_THREE:
  709.                 strcpy(Class, "SFXGrayDlg");
  710.                 Style = MWS_3DGRAY;
  711.                 Tool = IDT_THREE;
  712.                 break;
  713.  
  714.             case IDT_FOUR:
  715.                 strcpy(Class, "SFXSteelDlg");
  716.                 Style = MWS_3DSTEEL;
  717.                 Tool = IDT_FOUR;
  718.                 break;
  719.  
  720.             default:
  721.                 TSFXToolbar::EvCommand(id, hWndCtl, notifyCode);
  722.         }
  723.     }
  724.     else
  725.         TSFXToolbar::EvCommand(id, hWndCtl, notifyCode);
  726.  
  727.     return 0;
  728. }
  729.  
  730. void
  731. TToolbar::EvMouseMove(UINT, TPoint& point)
  732. {
  733.     char temp[80], text[80];
  734.  
  735.     /* To set the text in a top toolbar, bottom toolbar or status bar
  736.      * you need to retrieve the window handle of the toolbar's static control
  737.      * by specifying the offset MTB_WNDSTATIC in a call to GetWindowWord. The
  738.      * return value is the window handle of the static control. TSFXToolbar's
  739.      * StatusWindow() member function does this for you.
  740.      */
  741.     if (UseHints && PtInClient(HWindow, point))
  742.     {
  743.         HWND childWnd = ChildWindowFromPoint(point);
  744.         GetText(temp);
  745.         int childId = ::GetDlgCtrlID(childWnd);
  746.         if (childId > -1)
  747.         {
  748.             text[0] = '\0';
  749.             GetModule()->LoadString(childId, text, sizeof(text));
  750.             if (strcmpi(temp, text) != 0)
  751.                 SetText(text);
  752.         }
  753.     }
  754.     else
  755.         DefaultProcessing();
  756. }
  757.  
  758. //    TSplashWindow
  759.  
  760. class TSplashWindow : public TSFXStatic
  761. {
  762.   public:
  763.     TSplashWindow(TWindow*, int, const char far*, int, int, int, int, UINT);
  764.     void SetupWindow();
  765.     UINT EvGetDlgCode(MSG far*);
  766.     void EvKeyDown(UINT, UINT, UINT);
  767.     void EvLButtonDown(UINT, TPoint&);
  768.     UINT EvNCHitTest(TPoint&);
  769.     void EvTimer(UINT);
  770.   DECLARE_RESPONSE_TABLE(TSplashWindow);
  771. };
  772.  
  773. DEFINE_RESPONSE_TABLE1(TSplashWindow, TSFXStatic)
  774.   EV_WM_GETDLGCODE,
  775.   EV_WM_KEYDOWN,
  776.   EV_WM_LBUTTONDOWN,
  777.   EV_WM_NCHITTEST,
  778.   EV_WM_TIMER,
  779. END_RESPONSE_TABLE;
  780.  
  781. TSplashWindow::TSplashWindow(TWindow* parent, int id, const char far* title,
  782.                              int x, int y, int w, int h, UINT textLen)
  783.     :TSFXStatic(parent, id, title, x, y, w, h, textLen)
  784. {
  785. }
  786.  
  787. void
  788. TSplashWindow::SetupWindow()
  789. {
  790.     TSFXStatic::SetupWindow();
  791.  
  792.     /* Set timer to destroy the splash window after 10 seconds
  793.      */
  794.     SetTimer(IDTIMER, 10000, 0);
  795. }
  796.  
  797. UINT
  798. TSplashWindow::EvGetDlgCode(MSG far*)
  799. {
  800.     return DLGC_WANTALLKEYS;
  801. }
  802.  
  803. void
  804. TSplashWindow::EvKeyDown(UINT key, UINT, UINT)
  805. {
  806.     if (key == VK_RETURN)
  807.         KillTimer(IDTIMER);
  808.     CloseWindow();
  809. }
  810.  
  811. void
  812. TSplashWindow::EvLButtonDown(UINT, TPoint&)
  813. {
  814.     KillTimer(IDTIMER);
  815.     CloseWindow();
  816. }
  817.  
  818. UINT
  819. TSplashWindow::EvNCHitTest(TPoint& point)
  820. {
  821.     /* SFXStatic controls return HTTRANSPARENT. TSplashWindow overrides this
  822.      * so it can respond to the WM_LBUTTONDOWN message.
  823.      */
  824.     return (UINT)::DefWindowProc(HWindow, WM_NCHITTEST, 0, MAKELPARAM(point.x, point.y));
  825. }
  826.  
  827. void
  828. TSplashWindow::EvTimer(UINT timerId)
  829. {
  830.     if (timerId == IDTIMER)
  831.     {
  832.         KillTimer(IDTIMER);
  833.         CloseWindow();
  834.     }
  835. }
  836.  
  837. //    TViewWindow
  838.  
  839. class TViewWindow : public TSFXFrameWindow
  840. {
  841.   public:
  842.     TViewWindow(TWindow*, const char*);
  843.     ~TViewWindow();
  844.     UINT                      OldToolbarPos, ToolbarPos;
  845.     TBrush*                   Brush;
  846.     TColor                    Color;
  847.     TFont*                    Font;
  848.     TToolbar*                 Toolbar;
  849.     TSplashWindow*            Splash;
  850.     TModule*                  dllModule;
  851.     TFindReplaceDialog*       SearchDialog;
  852.     TFindReplaceDialog::TData SearchData;
  853.     TOpenSaveDialog::TData    FileData;
  854.     TPrintDialog::TData       PrintData;
  855.     TChooseColorDialog::TData Choose;
  856.     TChooseFontDialog::TData  FontData;
  857.     TIcon*                    FindIcon;
  858.     TIcon*                    ReplaceIcon;
  859.     TIcon*                    ColorIcon;
  860.     TIcon*                    FontIcon;
  861.     TIcon*                    PrintIcon;
  862.     TIcon*                    DirIcon;
  863.     TIcon*                    FileIcon;
  864.     char                      Text[80];
  865.     char far*                 GetClassName();
  866.     void                      GetWindowClass(WNDCLASS& wndClass);
  867.     void                      SetupWindow();
  868.     void                      Create3DMenus();
  869.     void                      Paint(TDC&, BOOL, TRect&);
  870.     void                      SetDefaultData();
  871.     void                      EvDrawItem(UINT, DRAWITEMSTRUCT far&);
  872.     void                      EvInitMenuPopup(HMENU, UINT, BOOL);
  873.     void                      EvMeasureItem(UINT, MEASUREITEMSTRUCT far&);
  874.     LRESULT                   EvMenuChar(WPARAM, LPARAM);
  875.     void                      EvMenuSelect(UINT, UINT, HMENU);
  876.     void                      EvSize(UINT, TSize&);
  877.     LRESULT                   EvSFXApplyColor(WPARAM, LPARAM);
  878.     LRESULT                   EvSFXApplyFont(WPARAM, LPARAM);
  879.     LRESULT                   EvSFXInitDialog(WPARAM, LPARAM);
  880.     LRESULT                   EvSFXHelp(WPARAM, LPARAM);
  881.     LRESULT                   EvFindMsg(WPARAM, LPARAM);
  882.     void                      EvMouseMove(UINT, TPoint&);
  883.     void                      EvNCMouseMove(UINT, TPoint&);
  884.     void                      MouseMove(const TPoint&);
  885.     void                      UpdateClientArea();
  886.     void                      CmFileOpen();
  887.     void                      CmFileExOpen();
  888.     void                      CmFileOpenExtraFlags();
  889.     void                      CmFileSaveAs();
  890.     void                      CmOpenDir();
  891.     void                      CmOpenDirHelp();
  892.     void                      CmPrint();
  893.     void                      CmPrintHelp();
  894.     void                      CmPrintSetup();
  895.     void                      CmPrintSetupHelp();
  896.     void                      CmExitWindow();
  897.     void                      CmSearchFind();
  898.     void                      CmSearchFindHelp();
  899.     void                      CmSearchReplace();
  900.     void                      CmSearchReplaceHelp();
  901.     void                      CmBasicColor();
  902.     void                      CmBasicColorHelp();
  903.     void                      CmExtendedColor();
  904.     void                      CmExtendedColorHelp();
  905.     void                      CmBasicFont();
  906.     void                      CmBasicFontExtraFlags();
  907.     void                      CmExtendedFont();
  908.     void                      CmExtendedFontApply();
  909.     void                      CmExtendedFontHelp();
  910.     void                      CmButton();
  911.     void                      CmStatic();
  912.     void                      CmShade();
  913.     void                      CmCheck();
  914.     void                      CmRadio();
  915.     void                      CmControl();
  916.     void                      CmToolbar();
  917.     void                      CmMessage();
  918.     void                      CmWindows();
  919.     void                      CmTop();
  920.     void                      CmFloat();
  921.     void                      CmBottom();
  922.     void                      CmStatus();
  923.     void                      CmHints();
  924.     void                      CmHelp();
  925.     void                      CmAbout();
  926.   DECLARE_RESPONSE_TABLE(TViewWindow);
  927. };
  928.  
  929. DEFINE_RESPONSE_TABLE2(TViewWindow, TSFXFrameWindow, TFrameWindow)
  930.   EV_WM_DRAWITEM,
  931.   EV_WM_INITMENUPOPUP,
  932.   EV_WM_MEASUREITEM,
  933.   EV_WM_MENUSELECT,
  934.   EV_WM_SIZE,
  935.   EV_WM_MOUSEMOVE,
  936.   EV_WM_NCMOUSEMOVE,
  937.   EV_COMMAND(CM_FILEOPEN, CmFileOpen),
  938.   EV_COMMAND(CM_FILEEXOPEN, CmFileExOpen),
  939.   EV_COMMAND(CM_FILEOPENEXTRAFLAGS, CmFileOpenExtraFlags),
  940.   EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),
  941.   EV_COMMAND(CM_PRINT, CmPrint),
  942.   EV_COMMAND(CM_PRINTHELP, CmPrintHelp),
  943.   EV_COMMAND(CM_PRINTSETUP, CmPrintSetup),
  944.   EV_COMMAND(CM_PRINTSETUPHELP, CmPrintSetupHelp),
  945.   EV_COMMAND(CM_OPENDIR, CmOpenDir),
  946.   EV_COMMAND(CM_OPENDIRHELP, CmOpenDirHelp),
  947.   EV_COMMAND(CM_EXITWINDOW, CmExitWindow),
  948.   EV_COMMAND(CM_SEARCHFIND, CmSearchFind),
  949.   EV_COMMAND(CM_SEARCHFINDHELP, CmSearchFindHelp),
  950.   EV_COMMAND(CM_SEARCHREPLACE, CmSearchReplace),
  951.   EV_COMMAND(CM_SEARCHREPLACEHELP, CmSearchReplaceHelp),
  952.   EV_COMMAND(CM_BASICCOLOR, CmBasicColor),
  953.   EV_COMMAND(CM_BASICCOLORHELP, CmBasicColorHelp),
  954.   EV_COMMAND(CM_EXTENDEDCOLOR, CmExtendedColor),
  955.   EV_COMMAND(CM_EXTENDEDCOLORHELP, CmExtendedColorHelp),
  956.   EV_COMMAND(CM_BASICFONT, CmBasicFont),
  957.   EV_COMMAND(CM_BASICFONTEXTRAFLAGS, CmBasicFontExtraFlags),
  958.   EV_COMMAND(CM_EXTENDEDFONT, CmExtendedFont),
  959.   EV_COMMAND(CM_EXTENDEDFONTAPPLY, CmExtendedFontApply),
  960.   EV_COMMAND(CM_EXTENDEDFONTHELP, CmExtendedFontHelp),
  961.   EV_COMMAND(CM_BUTTON, CmButton),
  962.   EV_COMMAND(CM_STATIC, CmStatic),
  963.   EV_COMMAND(CM_SHADE, CmShade),
  964.   EV_COMMAND(CM_CHECK, CmCheck),
  965.   EV_COMMAND(CM_RADIO, CmRadio),
  966.   EV_COMMAND(CM_CONTROL, CmControl),
  967.   EV_COMMAND(CM_TOOLBAR, CmToolbar),
  968.   EV_COMMAND(CM_MESSAGE, CmMessage),
  969.   EV_COMMAND(CM_WINDOWS, CmWindows),
  970.   EV_COMMAND(CM_TOP, CmTop),
  971.   EV_COMMAND(CM_FLOAT, CmFloat),
  972.   EV_COMMAND(CM_BOTTOM, CmBottom),
  973.   EV_COMMAND(CM_STATUS, CmStatus),
  974.   EV_COMMAND(CM_HINTS, CmHints),
  975.   EV_COMMAND(CM_HELP, CmHelp),
  976.   EV_COMMAND(CM_ABOUT, CmAbout),
  977.   EV_MESSAGE(WM_MENUCHAR, EvMenuChar),
  978.   EV_MESSAGE(WM_SFXAPPLYCOLOR, EvSFXApplyColor),
  979.   EV_MESSAGE(WM_SFXAPPLYFONT, EvSFXApplyFont),
  980.   EV_MESSAGE(WM_SFXINITDIALOG, EvSFXInitDialog),
  981.   EV_MESSAGE(WM_SFXHELP, EvSFXHelp),
  982.   EV_REGISTERED(FINDMSGSTRING, EvFindMsg), //  Find/Replace common dialog message
  983. END_RESPONSE_TABLE;
  984.  
  985. TViewWindow::TViewWindow(TWindow* parent, const char* title)
  986.    :TSFXFrameWindow(parent, title),
  987.     TFrameWindow(parent, title),
  988.     TWindow(parent, title),
  989.     FileData(0, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|", 0, "", "*")
  990. {
  991.     Attr.Style |= MWS_SFXCAPTION;
  992.     Attr.X = 0;
  993.     Attr.Y = 0;
  994.     Attr.W = CW_USEDEFAULT;
  995.     Attr.W = CW_USEDEFAULT;
  996.  
  997.     /* Creates the splash window displayed when the main window first appears.
  998.      * An SFXStatic control is used to display the centered bitmap inside a
  999.      * raised border (MSS_BITMAPWINDOW style).
  1000.      *
  1001.      * MSS_CENTERBITMAP = (MSS_BITMAPWINDOW | MSS_VCENTER | MSS_HCENTER)
  1002.      */
  1003.     Splash = new TSplashWindow(this, IDSPLASH, "SplashPanel", 0, 0, 318, 153, 0);
  1004.     Splash->Attr.Style = WS_CHILD | WS_VISIBLE | MSS_CENTERBITMAP | MSS_RAISED;
  1005.  
  1006.     //    Create a TModule object for SFX200.DLL to use in the common dialog box constructors
  1007.     dllModule = new TModule("SFX200.DLL", GetSFXInstance());
  1008.  
  1009.     /* This frame window has no client window. It uses a brush to paint its client area.
  1010.      * This brush is can be changed using the Choose Color dialog box.
  1011.      */
  1012.     Brush = new TBrush(::GetSysColor(COLOR_WINDOW));
  1013.  
  1014.     //    Set up the menu
  1015.     AssignMenu(APPNAME);
  1016.  
  1017.        //    Set initial text color to Blue }
  1018.     Color = TColor(0, 0, 255);
  1019.  
  1020.     //    Set default values for common dialog and LogFont data structures
  1021.     SetDefaultData();
  1022.  
  1023.     //    Create default font
  1024.     Font = new TFont(&FontData.LogFont);
  1025.     SearchDialog = 0;
  1026.     Toolbar = 0;
  1027.     ToolbarPos = 0;
  1028.  
  1029.     //    Load caption icons, depending on height of title bar
  1030.     if (GetSystemMetrics(SM_CYSIZE) == 26)
  1031.     {
  1032.         FindIcon = new TIcon(GetModule()->GetInstance(), "Find2");
  1033.         ReplaceIcon = new TIcon(GetModule()->GetInstance(), "Replace2");
  1034.         ColorIcon = new TIcon(GetModule()->GetInstance(), "Color2");
  1035.         FontIcon = new TIcon(GetModule()->GetInstance(), "Font2");
  1036.         PrintIcon = new TIcon(GetModule()->GetInstance(), "Print2");
  1037.         DirIcon = new TIcon(GetModule()->GetInstance(), "Dir2");
  1038.         FileIcon = new TIcon(GetModule()->GetInstance(), "File2");
  1039.     }
  1040.     else
  1041.     {
  1042.         FindIcon = new TIcon(GetModule()->GetInstance(), "Find1");
  1043.         ReplaceIcon = new TIcon(GetModule()->GetInstance(), "Replace1");
  1044.         ColorIcon = new TIcon(GetModule()->GetInstance(), "Color1");
  1045.         FontIcon = new TIcon(GetModule()->GetInstance(), "Font1");
  1046.         PrintIcon = new TIcon(GetModule()->GetInstance(), "Print1");
  1047.         DirIcon = new TIcon(GetModule()->GetInstance(), "Dir1");
  1048.         FileIcon = new TIcon(GetModule()->GetInstance(), "File1");
  1049.     }
  1050.     //    Use Flyover Hints
  1051.     UseHints = TRUE;
  1052. }
  1053.  
  1054. TViewWindow::~TViewWindow()
  1055. {
  1056.     delete dllModule;
  1057.     delete Brush;
  1058.     delete Font;
  1059.     delete FindIcon;
  1060.     delete ReplaceIcon;
  1061.     delete ColorIcon;
  1062.     delete FontIcon;
  1063.     delete PrintIcon;
  1064.     delete DirIcon;
  1065.     delete FileIcon;
  1066. }
  1067.  
  1068. char far* TViewWindow::GetClassName()
  1069. {
  1070.     return APPNAME;
  1071. }
  1072.  
  1073. void
  1074. TViewWindow::GetWindowClass(WNDCLASS& wndClass)
  1075. {
  1076.     TSFXFrameWindow::GetWindowClass(wndClass);
  1077.     wndClass.hbrBackground = 0;
  1078. }
  1079.  
  1080. void
  1081. TViewWindow::SetupWindow()
  1082. {
  1083.     TSFXFrameWindow::SetupWindow();
  1084.  
  1085.     /* Set up 3D ownerdraw menu items
  1086.      */
  1087.     Create3DMenus();
  1088.  
  1089.     /* Use CmStatus() menu item to set up a status bar
  1090.      */
  1091.     Tool = IDT_ONE;
  1092.     CmStatus();
  1093.  
  1094.     /* Set the initial dialog class displayed to SFX3DDlg. This information
  1095.      * is changed when the user presses a toolbar button.
  1096.      */
  1097.     strcpy(Class, "SFX3DDlg");
  1098.     Style = MWS_SFXFRAME;
  1099.  
  1100.     /* The CenterWindow function is defined in the SFX200.H. Here it's used to center
  1101.      * the Splash window over HWindow. If HWindow was zero the Splash window would
  1102.      * be centered over the desktop window.
  1103.      */
  1104.     CenterWindow(HWindow, Splash->HWindow);
  1105.     Splash->SetFocus();
  1106. }
  1107.  
  1108. void
  1109. TViewWindow::Create3DMenus()
  1110. {
  1111.     HMENU menu;
  1112.     char* text;
  1113.  
  1114.     /* Since the system menu rarely gets modified, Set3DSystemMenu can be used to
  1115.      * automatically set up a basic ownerdraw system menu.
  1116.      */
  1117.     Set3DSystemMenu(HWindow, "Object Viewer");
  1118.  
  1119.     /* You cannot specify ownerdraw menu items in a resource file. You can only
  1120.      * specify (modify) them from within your program.
  1121.      */
  1122.     menu = GetSubMenu(GetMenu(), 0);
  1123.     text = "&Open...";
  1124.     ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_FILEOPEN, text);
  1125.     text = "Open with E&xtended Select...";
  1126.     ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_FILEEXOPEN, text);
  1127.     text = "Open with Extra &Flags...";
  1128.     ModifyMenu(menu, 2, MF_BYPOSITION | MF_OWNERDRAW, CM_FILEOPENEXTRAFLAGS, text);
  1129.     text = "&Save As...";
  1130.     ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_FILESAVEAS, text);
  1131.     text = "&Directory...";
  1132.     ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_OPENDIR, text);
  1133.     text = "Di&rectory with Help...";
  1134.     ModifyMenu(menu, 6, MF_BYPOSITION | MF_OWNERDRAW, CM_OPENDIRHELP, text);
  1135.     text = "&Print...";
  1136.     ModifyMenu(menu, 8, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINT, text);
  1137.     text = "Pr&int with Help...";
  1138.     ModifyMenu(menu, 9, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINTHELP, text);
  1139.     text = "Pri&nter Setup...";
  1140.     ModifyMenu(menu, 10, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINTSETUP, text);
  1141.     text = "Prin&ter Setup with Help...";
  1142.     ModifyMenu(menu, 11, MF_BYPOSITION | MF_OWNERDRAW, CM_PRINTSETUPHELP, text);
  1143.     text = "&Exit";
  1144.     ModifyMenu(menu, 13, MF_BYPOSITION | MF_OWNERDRAW, CM_EXITWINDOW, text);
  1145.  
  1146.     menu = GetSubMenu(GetMenu(), 1);
  1147.     text = "&Find...";
  1148.     ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHFIND, text);
  1149.     text = "F&ind with Help...";
  1150.     ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHFINDHELP, text);
  1151.     text = "&Replace...";
  1152.     ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHREPLACE, text);
  1153.     text = "R&eplace with Help...";
  1154.     ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_SEARCHREPLACEHELP, text);
  1155.  
  1156.     menu = GetSubMenu(GetMenu(), 2);
  1157.     text = "&Basic Color...";
  1158.     ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICCOLOR, text);
  1159.     text = "Basic &Color with Help...";
  1160.     ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICCOLORHELP, text);
  1161.     text = "&Extended Color...";
  1162.     ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDCOLOR, text);
  1163.     text = "E&xtended Color with Help...";
  1164.     ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDCOLORHELP, text);
  1165.  
  1166.     menu = GetSubMenu(GetMenu(), 3);
  1167.     text = "&Basic Font...";
  1168.     ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICFONT, text);
  1169.     text = "Basic &Font with Extra Flags...";
  1170.     ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_BASICFONTEXTRAFLAGS, text);
  1171.     text = "&Extended Font...";
  1172.     ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDFONT, text);
  1173.     text = "E&xtended Font with Apply...";
  1174.     ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDFONTAPPLY, text);
  1175.     text = "Ex&tended Font with Help...";
  1176.     ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_EXTENDEDFONTHELP, text);
  1177.  
  1178.     menu = GetSubMenu(GetMenu(), 4);
  1179.     text = "&Buttons...";
  1180.     ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_BUTTON, text);
  1181.     text = "&Static Controls...";
  1182.     ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_STATIC, text);
  1183.     text = "S&hade Controls...";
  1184.     ModifyMenu(menu, 2, MF_BYPOSITION | MF_OWNERDRAW, CM_SHADE, text);
  1185.     text = "Chec&k Boxes...";
  1186.     ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_CHECK, text);
  1187.     text = "&Radio Buttons...";
  1188.     ModifyMenu(menu, 4, MF_BYPOSITION | MF_OWNERDRAW, CM_RADIO, text);
  1189.     text = "&Controls...";
  1190.     ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_CONTROL, text);
  1191.     text = "&Toolbars...";
  1192.     ModifyMenu(menu, 7, MF_BYPOSITION | MF_OWNERDRAW, CM_TOOLBAR, text);
  1193.     text = "&Message && Input Boxes...";
  1194.     ModifyMenu(menu, 8, MF_BYPOSITION | MF_OWNERDRAW, CM_MESSAGE, text);
  1195.     text = "&Windows...";
  1196.     ModifyMenu(menu, 10, MF_BYPOSITION | MF_OWNERDRAW, CM_WINDOWS, text);
  1197.  
  1198.     menu = GetSubMenu(GetMenu(), 5);
  1199.     text = "&Top";
  1200.     ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_TOP, text);
  1201.     text = "&Floating";
  1202.     ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_FLOAT, text);
  1203.     text = "&Bottom";
  1204.     ModifyMenu(menu, 2, MF_BYPOSITION | MF_OWNERDRAW, CM_BOTTOM, text);
  1205.     text = "&Status Bar";
  1206.     ModifyMenu(menu, 3, MF_BYPOSITION | MF_OWNERDRAW, CM_STATUS, text);
  1207.     text = "Flyover &Hints";
  1208.     ModifyMenu(menu, 5, MF_BYPOSITION | MF_OWNERDRAW, CM_HINTS, text);
  1209.  
  1210.     menu = GetSubMenu(GetMenu(), 6);
  1211.     text = "&ObjectMate Reference...";
  1212.     ModifyMenu(menu, 0, MF_BYPOSITION | MF_OWNERDRAW, CM_HELP, text);
  1213.     text = "&About ObjectMate...";
  1214.     ModifyMenu(menu, 1, MF_BYPOSITION | MF_OWNERDRAW, CM_ABOUT, text);
  1215. }
  1216.  
  1217. void
  1218. TViewWindow::SetDefaultData()
  1219. {
  1220.     //    Default LogFont data
  1221.     FontData.LogFont.lfHeight = 36;
  1222.     FontData.LogFont.lfWidth = 0;
  1223.     FontData.LogFont.lfEscapement = 0;
  1224.     FontData.LogFont.lfOrientation = 0;
  1225.     FontData.LogFont.lfWeight = FW_BOLD;
  1226.     FontData.LogFont.lfItalic = FALSE;
  1227.     FontData.LogFont.lfUnderline = TRUE;
  1228.     FontData.LogFont.lfStrikeOut = FALSE;
  1229.     FontData.LogFont.lfCharSet = 1;
  1230.     FontData.LogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
  1231.     FontData.LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  1232.     FontData.LogFont.lfQuality = DEFAULT_QUALITY;
  1233.     FontData.LogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
  1234.     strcpy(FontData.LogFont.lfFaceName, "Times New Roman");
  1235.  
  1236.     //    Default font data
  1237.     FontData.DC = 0;
  1238.     FontData.Color = Color;    // Color and font dialogs use the same color
  1239.     FontData.Style = 0;
  1240.     FontData.FontType = SCREEN_FONTTYPE;
  1241.     FontData.SizeMin = 0;
  1242.     FontData.SizeMax = 0;
  1243.  
  1244.     //    Default color data
  1245.     Choose.Color = Color;
  1246.     Choose.CustColors = custColors;
  1247.  
  1248.     //    Set default print data
  1249.     PrintData.FromPage = 1;
  1250.     PrintData.ToPage = 25;
  1251.     PrintData.MinPage = 1;
  1252.     PrintData.MaxPage = 25;
  1253.     PrintData.Copies = 1;
  1254. }
  1255.  
  1256. void
  1257. TViewWindow::Paint(TDC& paintDC, BOOL, TRect&)
  1258. {
  1259.     paintDC.SetTextColor(Color);
  1260.     paintDC.SetBkMode(TRANSPARENT);
  1261.     TRect rc = GetClientRect();
  1262.     if (ToolbarPos == CM_TOP)
  1263.         rc.top = 27;
  1264.     else
  1265.     if (ToolbarPos == CM_BOTTOM || ToolbarPos == CM_STATUS)
  1266.         rc.bottom -= 27;
  1267.     paintDC.FillRect(rc, *Brush);
  1268.     if (Font)
  1269.         paintDC.SelectObject(*Font);
  1270.     paintDC.TextOut(10, 30, "Microworks ObjectMate 2.6", 25);
  1271.     if (Font)
  1272.         paintDC.RestoreFont();
  1273. }
  1274.  
  1275. void
  1276. TViewWindow::EvDrawItem(UINT /*ctlId*/, DRAWITEMSTRUCT far& drawinfo)
  1277. {
  1278.     /* Pass EvDrawItem onto DrawMenuItem using the default values
  1279.      * for hFont, color and textColor. DrawMenuItem is defined in
  1280.      * SMENU.H
  1281.      */
  1282.     if (drawinfo.CtlType == ODT_MENU)
  1283.         DrawMenuItem(drawinfo);
  1284. }
  1285.  
  1286. void
  1287. TViewWindow::EvInitMenuPopup(HMENU hPopupMenu, UINT index, BOOL sysMenu)
  1288. {
  1289.     if (!sysMenu && index == 5)
  1290.     {
  1291.         if (ToolbarPos != OldToolbarPos)
  1292.         {
  1293.             CheckMenuItem(hPopupMenu, ToolbarPos, MF_CHECKED);
  1294.             CheckMenuItem(hPopupMenu, OldToolbarPos, MF_UNCHECKED);
  1295.         }
  1296.         if (UseHints)
  1297.             CheckMenuItem(hPopupMenu, CM_HINTS, MF_CHECKED);
  1298.         else
  1299.             CheckMenuItem(hPopupMenu, CM_HINTS, MF_UNCHECKED);
  1300.     }
  1301.     else
  1302.         TSFXFrameWindow::EvInitMenuPopup(hPopupMenu, index, sysMenu);
  1303. }
  1304.  
  1305. void
  1306. TViewWindow::EvMeasureItem(UINT /*ctlId*/, MEASUREITEMSTRUCT far& measureinfo)
  1307. {
  1308.     /* MeasureMenuItem is defined in SMENU.H
  1309.      */
  1310.     if (measureinfo.CtlType == ODT_MENU)
  1311.         MeasureMenuItem(HWindow, measureinfo);
  1312. }
  1313.  
  1314. LRESULT
  1315. TViewWindow::EvMenuChar(WPARAM nChar, LPARAM lParam)
  1316. {
  1317.     /* OWL's EvMenuChar function doesn't seem to work properly so EvMenuChar
  1318.      * has been redefined using the EV_MESSAGE macro. ProcessSystemChar
  1319.      * automatically handles ownerdraw system menu mnemonics. Your application
  1320.      * must handle all other ownerdraw menu mnemonics.
  1321.      */
  1322.     if (LOWORD(lParam) & MF_SYSMENU)
  1323.         return ProcessSystemChar(nChar);
  1324.     else
  1325.     if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 0))
  1326.     {
  1327.         switch (nChar)
  1328.         {
  1329.             case 79:
  1330.             case 111:
  1331.                 return MAKELONG(0, 2);
  1332.  
  1333.             case 88:
  1334.             case 120:
  1335.                 return MAKELONG(1, 2);
  1336.  
  1337.             case 70:
  1338.             case 102:
  1339.                 return MAKELONG(2, 2);
  1340.  
  1341.             case 83:
  1342.             case 115:
  1343.                 return MAKELONG(3, 2);
  1344.  
  1345.             case 68:
  1346.             case 100:
  1347.                 return MAKELONG(5, 2);
  1348.  
  1349.             case 82:
  1350.             case 114:
  1351.                 return MAKELONG(6, 2);
  1352.  
  1353.             case 80:
  1354.             case 112:
  1355.                 return MAKELONG(8, 2);
  1356.  
  1357.             case 73:
  1358.             case 105:
  1359.                 return MAKELONG(9, 2);
  1360.  
  1361.             case 78:
  1362.             case 110:
  1363.                 return MAKELONG(10, 2);
  1364.  
  1365.             case 84:
  1366.             case 116:
  1367.                 return MAKELONG(11, 2);
  1368.  
  1369.             case 69:
  1370.             case 101:
  1371.                 return MAKELONG(13, 2);
  1372.         }
  1373.     }
  1374.     else
  1375.     if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 1))
  1376.     {
  1377.         switch (nChar)
  1378.         {
  1379.             case 70:
  1380.             case 102:
  1381.                 return MAKELONG(0, 2);
  1382.  
  1383.             case 73:
  1384.             case 105:
  1385.                 return MAKELONG(1, 2);
  1386.  
  1387.             case 82:
  1388.             case 114:
  1389.                 return MAKELONG(3, 2);
  1390.  
  1391.             case 69:
  1392.             case 101:
  1393.                 return MAKELONG(4, 2);
  1394.         }
  1395.     }
  1396.     else
  1397.     if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 2))
  1398.     {
  1399.         switch (nChar)
  1400.         {
  1401.             case 66:
  1402.             case 98:
  1403.                 return MAKELONG(0, 2);
  1404.  
  1405.             case 67:
  1406.             case 99:
  1407.                 return MAKELONG(1, 2);
  1408.  
  1409.             case 69:
  1410.             case 101:
  1411.                 return MAKELONG(3, 2);
  1412.  
  1413.             case 88:
  1414.             case 120:
  1415.                 return MAKELONG(4, 2);
  1416.         }
  1417.     }
  1418.     else
  1419.     if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 3))
  1420.     {
  1421.         switch (nChar)
  1422.         {
  1423.             case 66:
  1424.             case 98:
  1425.                 return MAKELONG(0, 2);
  1426.  
  1427.             case 70:
  1428.             case 102:
  1429.                 return MAKELONG(1, 2);
  1430.  
  1431.             case 69:
  1432.             case 101:
  1433.                 return MAKELONG(3, 2);
  1434.  
  1435.             case 88:
  1436.             case 120:
  1437.                 return MAKELONG(4, 2);
  1438.  
  1439.             case 84:
  1440.             case 116:
  1441.                 return MAKELONG(5, 2);
  1442.         }
  1443.     }
  1444.     else
  1445.     if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 4))
  1446.     {
  1447.         switch (nChar)
  1448.         {
  1449.             case 66:
  1450.             case 98:
  1451.                 return MAKELONG(0, 2);
  1452.  
  1453.             case 83:
  1454.             case 115:
  1455.                 return MAKELONG(1, 2);
  1456.  
  1457.             case 72:
  1458.             case 104:
  1459.                 return MAKELONG(2, 2);
  1460.  
  1461.             case 75:
  1462.             case 107:
  1463.                 return MAKELONG(3, 2);
  1464.  
  1465.             case 82:
  1466.             case 114:
  1467.                 return MAKELONG(4, 2);
  1468.  
  1469.             case 67:
  1470.             case 99:
  1471.                 return MAKELONG(5, 2);
  1472.  
  1473.             case 84:
  1474.             case 116:
  1475.                 return MAKELONG(7, 2);
  1476.  
  1477.             case 77:
  1478.             case 109:
  1479.                 return MAKELONG(8, 2);
  1480.  
  1481.             case 87:
  1482.             case 119:
  1483.                 return MAKELONG(10, 2);
  1484.         }
  1485.     }
  1486.     else
  1487.     if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 5))
  1488.     {
  1489.         switch (nChar)
  1490.         {
  1491.             case 84:
  1492.             case 116:
  1493.                 return MAKELONG(0, 2);
  1494.  
  1495.             case 70:
  1496.             case 102:
  1497.                 return MAKELONG(1, 2);
  1498.  
  1499.             case 66:
  1500.             case 98:
  1501.                 return MAKELONG(2, 2);
  1502.  
  1503.             case 83:
  1504.             case 115:
  1505.                 return MAKELONG(3, 2);
  1506.  
  1507.             case 72:
  1508.             case 104:
  1509.                 return MAKELONG(5, 2);
  1510.         }
  1511.     }
  1512.     else
  1513.     if ((HMENU)HIWORD(lParam) == GetSubMenu(GetMenu(), 6))
  1514.     {
  1515.         switch (nChar)
  1516.         {
  1517.             case 79:
  1518.             case 111:
  1519.                 return MAKELONG(0, 2);
  1520.  
  1521.             case 65:
  1522.             case 97:
  1523.                 return MAKELONG(1, 2);
  1524.         }
  1525.     }
  1526.     return 0L;
  1527. }
  1528.  
  1529. void
  1530. TViewWindow::EvMenuSelect(UINT menuItemId, UINT /*flags*/, HMENU /*hMenu*/)
  1531. {
  1532.     if (UseHints)
  1533.     {
  1534.         Text[0] = '\0';
  1535.         GetModule()->LoadString(menuItemId, Text, sizeof(Text));
  1536.         Toolbar->SetText(Text);
  1537.     }
  1538. }
  1539.  
  1540. void
  1541. TViewWindow::EvSize(UINT sizeType, TSize& size)
  1542. {
  1543.     /* AlignToolbar is a TSFXToolbar member function defined in STOOLBAR.H. It sends
  1544.      * a WM_ALIGNTOOLBAR message to itself to realign a Top, Left, Right or Bottom aligned
  1545.      * toolbar or status bar. It should be added to the WM_SIZE message response so that
  1546.      * an aligned toolbar gets realigned properly when its parent is resized.
  1547.      */
  1548.     Toolbar->AlignToolbar();
  1549.  
  1550.     /* The main window was not created with the CS_HREDRAW and CS_VREDRAW style
  1551.      * so the toolbar could be excluded from the main window's update region. The
  1552.      * left and top toolbar styles automatically redraw that area of the toolbar
  1553.      * window that has changed.
  1554.      */
  1555.     UpdateClientArea();
  1556.     TWindow::EvSize(sizeType, size);
  1557. }
  1558.  
  1559. void
  1560. TViewWindow::EvMouseMove(UINT, TPoint& point)
  1561. {
  1562.     MouseMove(point);
  1563. }
  1564.  
  1565. void
  1566. TViewWindow::EvNCMouseMove(UINT, TPoint& point)
  1567. {
  1568.     MouseMove(point);
  1569. }
  1570.  
  1571. void
  1572. TViewWindow::MouseMove(const TPoint& point)
  1573. {
  1574.     /* UseHints is a BOOL value thats switches on/off Flyover hints. This code
  1575.      * clears the toolbar/status bar text if the cursor is inside the main window
  1576.      * but out side the toolbar. The code that sets the text is in the TToolbar
  1577.      * EvMouseMove response.
  1578.      */
  1579.     if (UseHints)
  1580.     {
  1581.         TRect rc = *ChildToParentRect(Toolbar->HWindow);
  1582.         if (!PtInRect(&rc, point))
  1583.         {
  1584.             Toolbar->GetText(Text);
  1585.             if (strcmpi(Text, "\0") != 0)
  1586.                 Toolbar->SetText("\0");
  1587.         }
  1588.     }
  1589. }
  1590.  
  1591. LRESULT
  1592. TViewWindow::EvSFXApplyColor(WPARAM, LPARAM color)
  1593. {
  1594.     /* This private message is sent when the user presses the Apply button in
  1595.      * a Color common dialog box. WPARAM is zero and color is the new RGB color
  1596.      * value selected by the user. This value is used to change the window's
  1597.      * background brush.
  1598.      */
  1599.     delete Brush;
  1600.     Brush = new TBrush(color);
  1601.     UpdateClientArea();
  1602.     return 0;
  1603. }
  1604.  
  1605. LRESULT
  1606. TViewWindow::EvSFXApplyFont(WPARAM font, LPARAM color)
  1607. {
  1608.     /* This private message is sent when the user presses the Apply button in a
  1609.      * Font common dialog box. font is the handle of the newly created font
  1610.      * and color is the new RGB color value. If the color option is not used
  1611.      * by the font dialog box color is 'RGB(0, 0, 0)'. SFX200.DLL does not delete
  1612.      * this font, that's your responsiblilty! When you close the font dialog box
  1613.      * the LogFont structure is automatcially updated.
  1614.      */
  1615.     if (font)
  1616.     {
  1617.         delete Font;
  1618.         Color = TColor(color);
  1619.         Font = new TFont((HFONT)font, AutoDelete);
  1620.         UpdateClientArea();
  1621.     }
  1622.     return 0;
  1623. }
  1624.  
  1625. LRESULT
  1626. TViewWindow::EvSFXInitDialog(WPARAM wParam, LPARAM lParam)
  1627. {
  1628.     /* WM_SFXINITDIALOG is sent from an SFX common dialog box's WM_INITDIALOG message
  1629.      * response in SFX200.DLL. wParam is a handle to the common dialog box and lParam
  1630.      * is the DLG_XXX constant identifying the type of common dialog box template.
  1631.      * This message gives you a chance to do something extra initialization - like
  1632.      * setting the MWS_SFXCAPTION flag and specifying a custom icon for each template.
  1633.      */
  1634.     ::SetWindowLong((HWND)wParam, GWL_STYLE, ::GetWindowLong((HWND)wParam, GWL_STYLE) |
  1635.                      MWS_SFXCAPTION);
  1636.  
  1637.     /* A WM_SETBITMAP message is sent to specify the custom icon to display on the
  1638.      * title bar. The icon image has been drawn to fit exactly, depending on the
  1639.      * height of the title bar, so lParam is 1 to prevent the icon shrinking, as
  1640.      * occurs in the Object Viewer main window.
  1641.      */
  1642.     switch (HIWORD(lParam))
  1643.     {
  1644.         case DLG_FIND:
  1645.             ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*FindIcon), 1);
  1646.             break;
  1647.  
  1648.         case DLG_REPLACE:
  1649.             ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*ReplaceIcon), 1);
  1650.             break;
  1651.  
  1652.         case DLG_COLOR:
  1653.         case DLG_EXCOLOR:
  1654.             ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*ColorIcon), 1);
  1655.             break;
  1656.  
  1657.         case DLG_FONT:
  1658.         case DLG_EXFONT:
  1659.             ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*FontIcon), 1);
  1660.             break;
  1661.  
  1662.         case DLG_PRINT:
  1663.         case DLG_PRINTSETUP:
  1664.             ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*PrintIcon), 1);
  1665.             break;
  1666.  
  1667.         case DLG_OPENDIR:
  1668.             ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*DirIcon), 1);
  1669.             break;
  1670.  
  1671.         case DLG_OPENSAVE:
  1672.         case DLG_EXOPENSAVE:
  1673.             ::SendMessage((HWND)wParam, WM_SETBITMAP, (WPARAM)HICON(*FileIcon), 1);
  1674.             break;
  1675.     }
  1676.     return 0;
  1677. }
  1678.  
  1679. LRESULT
  1680. TViewWindow::EvSFXHelp(WPARAM, LPARAM lParam)
  1681. {
  1682.     /* This private message is sent when the user presses the help button in a
  1683.      * one of the common dialog boxes. WPARAM is zero, LOWORD of lParam is the
  1684.      * window handle of the common dialog box sending the message and the HIWORD of
  1685.      * lParam identifies the type of common dialog box template sending the message.
  1686.      * It is one of the common dialog template constants defined in the SFX200.H.
  1687.      */
  1688.     Text[0] = '\0';
  1689.     GetModule()->LoadString(HIWORD(lParam), Text, sizeof(Text));
  1690.     SFXMsgBox(HWindow, Text, "Information", MB_ICONINFORMATION, Style);
  1691.     return 0;
  1692. }
  1693.  
  1694. LRESULT
  1695. TViewWindow::EvFindMsg(WPARAM, LPARAM lParam)
  1696. {
  1697.     char szFindMsg[256];
  1698.  
  1699.     //    Find/Replace message sent to this window
  1700.     if (SearchDialog)
  1701.     {
  1702.         SearchDialog->UpdateData(lParam);
  1703.         if (SearchData.Flags & FR_DIALOGTERM)
  1704.         {
  1705.             SearchDialog = 0;
  1706.         }
  1707.         else
  1708.         {
  1709.             strcpy(szFindMsg, "Button:\t\t");
  1710.             if (FR_FINDNEXT & SearchData.Flags) strcat(szFindMsg, "Find Next\n");
  1711.             if (FR_REPLACE & SearchData.Flags) strcat(szFindMsg, "Replace\n");
  1712.             if (FR_REPLACEALL & SearchData.Flags) strcat(szFindMsg, "Replace All\n");
  1713.             strcat(szFindMsg, "Direction:\t");
  1714.             strcat(szFindMsg, (SearchData.Flags & FR_DOWN) ? "Forward\n" : "Backward\n");
  1715.             strcat(szFindMsg, "Whole Word:\t");
  1716.             strcat(szFindMsg, (SearchData.Flags & FR_WHOLEWORD) ? "On\n" : "Off\n");
  1717.             strcat(szFindMsg, "Match Case:\t");
  1718.             strcat(szFindMsg, (SearchData.Flags & FR_MATCHCASE) ? "On\n" : "Off\n");
  1719.             SFXMsgBox(HWindow, szFindMsg, "Find/Replace Message", MB_ICONINFORMATION, Style);
  1720.         }
  1721.     }
  1722.     return 0;
  1723. }
  1724.  
  1725. void
  1726. TViewWindow::UpdateClientArea()
  1727. {
  1728.     //    Calculates the client update region (minus the toolbar) and invalidates it.
  1729.     TRect rc = GetClientRect();
  1730.     if (ToolbarPos == CM_TOP)
  1731.         rc.top = 27;
  1732.     else
  1733.     if (ToolbarPos == CM_BOTTOM || ToolbarPos == CM_STATUS)
  1734.         rc.bottom -= 27;
  1735.     InvalidateRect(rc, TRUE);
  1736. }
  1737.  
  1738. //    File menu items
  1739.  
  1740. void
  1741. TViewWindow::CmFileOpen()
  1742. {
  1743.     *FileData.FileName = 0;
  1744.     FileData.Flags |= OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
  1745.     int OPENTEMPLATE = GetSFXTemplateId(Class, DLG_OPENSAVE);
  1746.  
  1747.     if (TFileOpenDialog(this, FileData, OPENTEMPLATE, "File Open",
  1748.                             dllModule).Execute() == IDOK)
  1749.     {
  1750.         SFXMsgBox(HWindow, FileData.FileName, "You Selected", MB_ICONINFORMATION, Style);
  1751.     }
  1752. }
  1753.  
  1754. void
  1755. TViewWindow::CmFileExOpen()
  1756. {
  1757.     /* Uses the new SFXOpenFile function to display a 'Open File' common dialog box.
  1758.      */
  1759.     char  str[256];
  1760.     char  filters[] = "All Files (*.*)\0*.*\0Source Code (*.cpp)\0*.cpp\0";
  1761.     int   id = GetSFXTemplateId(Class, DLG_EXOPENSAVE);
  1762.     DWORD flags = 0;
  1763.     //DWORD index = 2;
  1764.  
  1765.     str[0] = 0;
  1766.     if (SFXOpenFile(HWindow, str, filters, flags, id/*, FALSE, "Open", (DWORD far*)&index*/))
  1767.     {
  1768.         SFXMsgBox(HWindow, str, "You Selected", MB_ICONINFORMATION, Style);
  1769.     }
  1770. }
  1771.  
  1772. void
  1773. TViewWindow::CmFileOpenExtraFlags()
  1774. {
  1775.     *FileData.FileName = 0;
  1776.     FileData.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_SHOWHELP;
  1777.     int OPENTEMPLATE = GetSFXTemplateId(Class, DLG_OPENSAVE);
  1778.  
  1779.     if (TFileOpenDialog(this, FileData, OPENTEMPLATE, "File Open",
  1780.                         dllModule).Execute() == IDOK)
  1781.     {
  1782.         /* MB_OK is the default button and doesn't need to be specified. You can give
  1783.          * the message box an SFXCaption by combining the SFXMsgBox Style argument with
  1784.          * the MWS_SFXCAPTION flag.
  1785.          */
  1786.         SFXMsgBox(HWindow, FileData.FileName, "You Selected",
  1787.                   MB_ICONINFORMATION, Style | MWS_SFXCAPTION);
  1788.     }
  1789. }
  1790.  
  1791. void
  1792. TViewWindow::CmFileSaveAs()
  1793. {
  1794.     /* Uses the new SFXSaveFile function to display a 'Save File As' common dialog box
  1795.      */
  1796.     char  str[256];
  1797.     char  filters[] = "All Files (*.*)\0*.*\0Source Code (*.cpp)\0*.cpp\0";
  1798.     int   id = GetSFXTemplateId(Class, DLG_OPENSAVE);
  1799.     DWORD flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
  1800.  
  1801.     str[0] = 0;
  1802.     if (SFXSaveFile(HWindow, str, filters, flags, id, TRUE))
  1803.     {
  1804.         SFXMsgBox(HWindow, str, "You Selected", MB_ICONINFORMATION, Style);
  1805.     }
  1806.  
  1807. }
  1808.  
  1809. void
  1810. TViewWindow::CmPrint()
  1811. {
  1812.     PrintData.Flags = PD_COLLATE | PD_DISABLEPRINTTOFILE;
  1813.     char far* PRINTTEMPLATE = GetSFXTemplate(Class, DLG_PRINT);
  1814.     char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
  1815.  
  1816.     if (TPrintDialog(this, PrintData, PRINTTEMPLATE, PRINTSETUPTEMPLATE,
  1817.                      "Print", dllModule).Execute() == IDOK)
  1818.     {
  1819.         SFXMsgBox(HWindow, "Nothing to print", "Print Information",
  1820.                   MB_ICONINFORMATION, Style);
  1821.     }
  1822. }
  1823.  
  1824. void
  1825. TViewWindow::CmPrintHelp()
  1826. {
  1827.     PrintData.Flags = PD_COLLATE | PD_DISABLEPRINTTOFILE | PD_SHOWHELP;
  1828.     char far* PRINTTEMPLATE = GetSFXTemplate(Class, DLG_PRINT);
  1829.     char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
  1830.  
  1831.     if (TPrintDialog(this, PrintData, PRINTTEMPLATE, PRINTSETUPTEMPLATE,
  1832.                      "Print", dllModule).Execute() == IDOK)
  1833.     {
  1834.         SFXMsgBox(HWindow, "Nothing to print", "Print Information",
  1835.                   MB_ICONINFORMATION, Style);
  1836.     }
  1837. }
  1838.  
  1839. void
  1840. TViewWindow::CmPrintSetup()
  1841. {
  1842.     PrintData.Flags = PD_PRINTSETUP;
  1843.     char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
  1844.  
  1845.     if (TPrintDialog(this, PrintData, 0, PRINTSETUPTEMPLATE, 0,
  1846.                      dllModule).Execute() == IDOK)
  1847.     {
  1848.         SFXMsgBox(HWindow, "Nothing to print", "Print Information", MB_ICONINFORMATION, Style);
  1849.     }
  1850. }
  1851.  
  1852. void
  1853. TViewWindow::CmPrintSetupHelp()
  1854. {
  1855.     PrintData.Flags = PD_PRINTSETUP;
  1856.     char far* PRINTSETUPTEMPLATE = GetSFXTemplate(Class, DLG_PRINTSETUP);
  1857.  
  1858.     if (TPrintDialog(this, PrintData, 0, PRINTSETUPTEMPLATE, 0,
  1859.                      dllModule).DoExecute() == IDOK)
  1860.     {
  1861.         SFXMsgBox(HWindow, "Nothing to print", "Print Information",
  1862.                   MB_ICONINFORMATION, Style);
  1863.     }
  1864. }
  1865.  
  1866. void
  1867. TViewWindow::CmOpenDir()
  1868. {
  1869.     /* Uses the SFXDirBox function to display a 'Open File' style directory dialog box
  1870.      */
  1871.     char szDir[MAXDIR];
  1872.  
  1873.     if (SFXDirBox(HWindow, "Select Directory", szDir, (UINT)OFN_NOCHANGEDIR, Style) == IDOK)
  1874.     {
  1875.         SFXMsgBox(HWindow, szDir, "You Selected", MB_ICONEXCLAMATION, Style);
  1876.     }
  1877. }
  1878.  
  1879. void
  1880. TViewWindow::CmOpenDirHelp()
  1881. {
  1882.     /* Uses the new SFXOpenDir function to display a 'Open File' style directory dialog box
  1883.      */
  1884.     char szDir[MAXDIR];
  1885.     int  id = GetSFXTemplateId(Class, DLG_OPENDIR);
  1886.     DWORD flags = OFN_SHOWHELP;
  1887.  
  1888.     if (SFXOpenDir(HWindow, szDir, "Change Directory", flags, id))
  1889.     {
  1890.         SFXMsgBox(HWindow, szDir, "You Selected", MB_ICONINFORMATION, Style);
  1891.     }
  1892. }
  1893.  
  1894. void
  1895. TViewWindow::CmExitWindow()
  1896. {
  1897.     CloseWindow();
  1898. }
  1899.  
  1900. //    Search menu items
  1901.  
  1902. void
  1903. TViewWindow::CmSearchFind()
  1904. {
  1905.     if (!SearchDialog)
  1906.     {
  1907.         SearchData.FindWhat = "SearchString";
  1908.         SearchData.Flags |= FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD;
  1909.         int FINDTEMPLATE = GetSFXTemplateId(Class, DLG_FIND);
  1910.         SearchDialog = new TFindDialog(this, SearchData, FINDTEMPLATE, "Find Text", dllModule);
  1911.         SearchDialog->Create();
  1912.     }
  1913. }
  1914.  
  1915. void
  1916. TViewWindow::CmSearchFindHelp()
  1917. {
  1918.     if (!SearchDialog)
  1919.     {
  1920.         SearchData.FindWhat = "SearchString";
  1921.         SearchData.Flags |= FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_SHOWHELP;
  1922.         int FINDTEMPLATE = GetSFXTemplateId(Class, DLG_FIND);
  1923.         SearchDialog = new TFindDialog(this, SearchData, FINDTEMPLATE, "Find Text", dllModule);
  1924.         SearchDialog->Create();
  1925.     }
  1926. }
  1927.  
  1928. void
  1929. TViewWindow::CmSearchReplace()
  1930. {
  1931.     if (!SearchDialog)
  1932.     {
  1933.         SearchData.FindWhat = "SearchString";
  1934.         SearchData.ReplaceWith = "ReplaceString";
  1935.         SearchData.Flags |= FR_WHOLEWORD;
  1936.         int REPLACETEMPLATE = GetSFXTemplateId(Class, DLG_REPLACE);
  1937.         SearchDialog = new TReplaceDialog(this, SearchData, REPLACETEMPLATE,
  1938.                                           "Replace Text", dllModule);
  1939.         SearchDialog->Create();
  1940.     }
  1941. }
  1942.  
  1943. void
  1944. TViewWindow::CmSearchReplaceHelp()
  1945. {
  1946.     if (!SearchDialog)
  1947.     {
  1948.         SearchData.FindWhat = "SearchString";
  1949.         SearchData.ReplaceWith = "ReplaceString";
  1950.         SearchData.Flags |= FR_WHOLEWORD | FR_SHOWHELP;
  1951.         int REPLACETEMPLATE = GetSFXTemplateId(Class, DLG_REPLACE);
  1952.         SearchDialog = new TReplaceDialog(this, SearchData, REPLACETEMPLATE,
  1953.                                           "Replace Text", dllModule);
  1954.         SearchDialog->Create();
  1955.     }
  1956. }
  1957.  
  1958. //    Color menu items
  1959.  
  1960. void
  1961. TViewWindow::CmBasicColor()
  1962. {
  1963.     /* Uses the new SFXChooseColor function to display a "ChooseColor" common dialog box
  1964.      */
  1965.     COLORREF rgbColor = RGB(0, 128, 0);
  1966.     DWORD flags = CC_RGBINIT;
  1967.     int id = GetSFXTemplateId(Class, DLG_COLOR);
  1968.  
  1969.     if (SFXChooseColor(HWindow, (COLORREF far*)&rgbColor, flags, id,
  1970.                        FALSE/*, (COLORREF far*)custColors*/))
  1971.     {
  1972.         delete Brush;
  1973.         Brush = new TBrush(rgbColor);
  1974.         UpdateClientArea();
  1975.     }
  1976. }
  1977.  
  1978. void
  1979. TViewWindow::CmBasicColorHelp()
  1980. {
  1981.     Choose.Flags = CC_RGBINIT | CC_SHOWHELP;
  1982.     int COLORTEMPLATE = GetSFXTemplateId(Class, DLG_COLOR);
  1983.  
  1984.     if (TChooseColorDialog(this, Choose, COLORTEMPLATE, "Choose Color",
  1985.                            dllModule).Execute() == IDOK)
  1986.     {
  1987.         delete Brush;
  1988.         Brush = new TBrush(Choose.Color);
  1989.         UpdateClientArea();
  1990.     }
  1991. }
  1992.  
  1993. void
  1994. TViewWindow::CmExtendedColor()
  1995. {
  1996.     /* Uses the new SFXChooseColor function to display an "extended color" common dialog box
  1997.      */
  1998.     COLORREF rgbColor = RGB(0, 128, 0);
  1999.     DWORD flags = CC_RGBINIT | CC_FULLOPEN;
  2000.     int id = GetSFXTemplateId(Class, DLG_EXCOLOR);
  2001.  
  2002.     if (SFXChooseColor(HWindow, (COLORREF far*)&rgbColor, flags, id, TRUE))
  2003.     {
  2004.         delete Brush;
  2005.         Brush = new TBrush(rgbColor);
  2006.         UpdateClientArea();
  2007.     }
  2008. }
  2009.  
  2010. void
  2011. TViewWindow::CmExtendedColorHelp()
  2012. {
  2013.     Choose.Flags = CC_RGBINIT | CC_FULLOPEN | CC_SHOWHELP;
  2014.     int COLORTEMPLATE = GetSFXTemplateId(Class, DLG_EXCOLOR);
  2015.  
  2016.     if (TChooseColorDialog(this, Choose, COLORTEMPLATE, "Choose Color",
  2017.                            dllModule).Execute() == IDOK)
  2018.     {
  2019.         delete Brush;
  2020.         Brush = new TBrush(Choose.Color);
  2021.         UpdateClientArea();
  2022.     }
  2023. }
  2024.  
  2025. //    Font menu items
  2026.  
  2027. void
  2028. TViewWindow::CmBasicFont()
  2029. {
  2030.     FontData.Color = TColor::Black;
  2031.     FontData.Flags = CF_FORCEFONTEXIST | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
  2032.     int FONTTEMPLATE = GetSFXTemplateId(Class, DLG_FONT);
  2033.  
  2034.     if (TChooseFontDialog(this, FontData, FONTTEMPLATE, "Choose Font",
  2035.                           dllModule).Execute() == IDOK)
  2036.     {
  2037.         delete Font;
  2038.         Color = FontData.Color;
  2039.         Font = new TFont(&FontData.LogFont);
  2040.         UpdateClientArea();
  2041.     }
  2042. }
  2043.  
  2044. void
  2045. TViewWindow::CmBasicFontExtraFlags()
  2046. {
  2047.     /* Uses the new SFXChooseFont function to display a "ChooseFont" common dialog box
  2048.      */
  2049.     DWORD flags = CF_EFFECTS | CF_BOTH | CF_APPLY | CF_SHOWHELP;
  2050.     int id = GetSFXTemplateId(Class, DLG_FONT);
  2051.  
  2052.     if (SFXChooseFont(HWindow, (LOGFONT far*)&FontData.LogFont, flags, id,
  2053.                       FALSE, (COLORREF far*)&Color))
  2054.     {
  2055.         delete Font;
  2056.         Font = new TFont(&FontData.LogFont);
  2057.         UpdateClientArea();
  2058.     }
  2059. }
  2060.  
  2061. void
  2062. TViewWindow::CmExtendedFont()
  2063. {
  2064.     FontData.Color = TColor::Black;
  2065.     FontData.Flags = CF_FORCEFONTEXIST | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
  2066.     int FONTTEMPLATE = GetSFXTemplateId(Class, DLG_EXFONT);
  2067.  
  2068.     if (TChooseFontDialog(this, FontData, FONTTEMPLATE, "Choose Font",
  2069.                           dllModule).Execute() == IDOK)
  2070.     {
  2071.         delete Font;
  2072.         Color = FontData.Color;
  2073.         Font = new TFont(&FontData.LogFont);
  2074.         UpdateClientArea();
  2075.     }
  2076. }
  2077.  
  2078. void
  2079. TViewWindow::CmExtendedFontApply()
  2080. {
  2081.     /* Uses the new SFXChooseFont function to display an "extended font" common dialog box
  2082.      */
  2083.     DWORD flags = CF_APPLY | CF_SCREENFONTS | CF_FORCEFONTEXIST;
  2084.     int id = GetSFXTemplateId(Class, DLG_EXFONT);
  2085.  
  2086.     if (SFXChooseFont(HWindow, (LOGFONT far*)&FontData.LogFont, flags, id, TRUE))
  2087.     {
  2088.         delete Font;
  2089.         Color = TColor::Black;
  2090.         Font = new TFont(&FontData.LogFont);
  2091.         UpdateClientArea();
  2092.     }
  2093. }
  2094.  
  2095. void
  2096. TViewWindow::CmExtendedFontHelp()
  2097. {
  2098.     FontData.Color = TColor::Black;
  2099.     FontData.Flags = CF_FORCEFONTEXIST | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_SHOWHELP;
  2100.     int FONTTEMPLATE = GetSFXTemplateId(Class, DLG_EXFONT);
  2101.  
  2102.     if (TChooseFontDialog(this, FontData, FONTTEMPLATE, "Choose Font",
  2103.                           dllModule).Execute() == IDOK)
  2104.     {
  2105.         delete Font;
  2106.         Color = FontData.Color;
  2107.         Font = new TFont(&FontData.LogFont);
  2108.         UpdateClientArea();
  2109.     }
  2110. }
  2111.  
  2112. //    Objects menu items
  2113.  
  2114. void
  2115. TViewWindow::CmButton()
  2116. {
  2117.     TButtonDialog(this, "ButtonDialog").Execute();
  2118. }
  2119.  
  2120. void
  2121. TViewWindow::CmStatic()
  2122. {
  2123.     TStaticDialog(this, "StaticDialog").Execute();
  2124. }
  2125.  
  2126. void
  2127. TViewWindow::CmShade()
  2128. {
  2129.     TDefaultDialog(this, "ShadeDialog").Execute();
  2130. }
  2131.  
  2132. void
  2133. TViewWindow::CmCheck()
  2134. {
  2135.     TDefaultDialog(this, "CheckDialog").Execute();
  2136. }
  2137.  
  2138. void
  2139. TViewWindow::CmRadio()
  2140. {
  2141.     TDefaultDialog(this, "RadioDialog").Execute();
  2142. }
  2143.  
  2144. void
  2145. TViewWindow::CmControl()
  2146. {
  2147.     TControlDialog(this, "ControlDialog").Execute();
  2148. }
  2149.  
  2150. void
  2151. TViewWindow::CmToolbar()
  2152. {
  2153.     TToolbarDialog(this, "ToolbarDialog").Execute();
  2154. }
  2155.  
  2156. void
  2157. TViewWindow::CmMessage()
  2158. {
  2159.     TMessageDialog(this, "MessageInputDialog").Execute();
  2160. }
  2161.  
  2162. void
  2163. TViewWindow::CmWindows()
  2164. {
  2165.     SFXMsgBox(HWindow, "To view the various SpecialFX window, frame window "
  2166.                        "and MDI frame objects compile the sample applications "
  2167.                        "in your examples directory.", "Information",
  2168.                         MB_OK | MB_ICONINFORMATION, Style);
  2169. }
  2170.  
  2171. void
  2172. TViewWindow::CmTop()
  2173. {
  2174.     OldToolbarPos = ToolbarPos;
  2175.     if (ToolbarPos != CM_TOP)
  2176.     {
  2177.         /* An SFX Toolbar sizes itself according to the specified flags and the size
  2178.          * of the first button's bitmap, so cx and cy can be zero. x and y have
  2179.          * no effect on an aligned toolbar (here its top aligned as defined by MTB_TOP)
  2180.          * and are set to zero. To re position a toolbar you have to destroy the old
  2181.          * one and create a new one. When you do, you will have to make the MTB_ROWXX and
  2182.          * MTB_COLOUMNXX flags values appropriate for the new positon and change the
  2183.          * toolbar style flags. The style flags are MTB_TOP, MTB_LEFT, MTB_RIGHT,
  2184.          * MTB_BOTTOM, MTB_FLOAT and MTB_STATUS.
  2185.          */
  2186.         ToolbarPos = CM_TOP;
  2187.         if (Toolbar && Toolbar->HWindow)
  2188.             DestroyWindow(Toolbar->HWindow);
  2189.         Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804", 0, 0, TRUE);
  2190.         Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_TOP | MTB_BITMAPBUTTON | MTB_RADIO;
  2191.         Toolbar->Create();
  2192.  
  2193.         /* hToolWnd is created with the MTB_RADIO flag so its buttons behave as
  2194.          * a set of mutually exclusive radio buttons. WM_SETCHECK is a private message
  2195.          * that checks/unchecks a toolbar button. wParam is the button ID and lParam
  2196.          * is the check flag. 1 checks the button and 0 unchecks it. TSFXToolbar's
  2197.          * CheckTool and UncheckTool member functions send this message for you.
  2198.          */
  2199.         Toolbar->CheckTool(Tool);
  2200.  
  2201.         /* GetSFXObject retrieves the handle of the specified stock object. Do not delete
  2202.          * these handles as they are created, used and deleted by SFX200.DLL.
  2203.          * Here it sets the font for the toolbar's static control to the stock FINE_FONT
  2204.          * object (= MS San Serif 8).
  2205.          */
  2206.         Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
  2207.         UpdateClientArea();
  2208.     }
  2209. }
  2210.  
  2211. void
  2212. TViewWindow::CmFloat()
  2213. {
  2214.     OldToolbarPos = ToolbarPos;
  2215.     if (ToolbarPos != CM_FLOAT)
  2216.     {
  2217.         ToolbarPos = CM_FLOAT;
  2218.         if (Toolbar && Toolbar->HWindow)
  2219.             DestroyWindow(Toolbar->HWindow);
  2220.         UpdateClientArea();
  2221.         Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804",
  2222.                                GetSystemMetrics(SM_CXSCREEN), 0, TRUE);
  2223.         Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_FLOAT | MTB_BITMAPBUTTON |
  2224.                                MTB_RADIO | MTB_3DFRAME | WS_CAPTION;
  2225.         Toolbar->Create();
  2226.         Toolbar->CheckTool(Tool);
  2227.         Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
  2228.     }
  2229. }
  2230.  
  2231. void
  2232. TViewWindow::CmBottom()
  2233. {
  2234.     OldToolbarPos = ToolbarPos;
  2235.     if (ToolbarPos != CM_BOTTOM)
  2236.     {
  2237.         ToolbarPos = CM_BOTTOM;
  2238.         if (Toolbar != 0 && Toolbar->HWindow != 0)
  2239.             DestroyWindow(Toolbar->HWindow);
  2240.         Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804", 0, 0, TRUE);
  2241.         Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_BOTTOM | MTB_BITMAPBUTTON | MTB_RADIO;
  2242.         Toolbar->Create();
  2243.         Toolbar->CheckTool(Tool);
  2244.         Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
  2245.         UpdateClientArea();
  2246.     }
  2247. }
  2248.  
  2249. void
  2250. TViewWindow::CmStatus()
  2251. {
  2252.     OldToolbarPos = ToolbarPos;
  2253.     if (ToolbarPos != CM_STATUS)
  2254.     {
  2255.         ToolbarPos = CM_STATUS;
  2256.         if (Toolbar && Toolbar->HWindow)
  2257.             DestroyWindow(Toolbar->HWindow);
  2258.         Toolbar = new TToolbar(this, 101, "Dialog Classes,801,802,803,804", 0, 0, TRUE);
  2259.         Toolbar->Attr.Style |= MTB_ROW1 | MTB_COLUMN4 | MTB_STATUS | MTB_BITMAPBUTTON | MTB_RADIO;
  2260.         Toolbar->Create();
  2261.         Toolbar->CheckTool(Tool);
  2262.         Toolbar->SetFont((HFONT)GetSFXObject(FINE_FONT));
  2263.         UpdateClientArea();
  2264.     }
  2265. }
  2266.  
  2267. void
  2268. TViewWindow::CmHints()
  2269. {
  2270.     /* UseHints is a switches on and off Flyover hints. This code clears the
  2271.      * toolbar/status bar text if the cursor is inside the main window but out
  2272.      *  side the toolbar. The code that sets the text is in the TToolbar
  2273.      * EvMouseMove method.
  2274.      */
  2275.     if (!UseHints)
  2276.         Toolbar->SetText("");
  2277.     UseHints = !UseHints;
  2278. }
  2279.  
  2280. void
  2281. TViewWindow::CmHelp()
  2282. {
  2283.     WinHelp("SFX200.HLP", HELP_INDEX, 0);
  2284. }
  2285.  
  2286. void
  2287. TViewWindow::CmAbout()
  2288. {
  2289.     TDefaultDialog(this, "AboutDialog").Execute();
  2290. }
  2291.  
  2292. //    TViewApp class
  2293.  
  2294. class TViewApp : public TApplication
  2295. {
  2296.   public:
  2297.     TViewApp() : TApplication() {}
  2298.     void InitMainWindow();
  2299. };
  2300.  
  2301. void
  2302. TViewApp::InitMainWindow()
  2303. {
  2304.     MainWindow = new TViewWindow(0, "Object Viewer");
  2305.     MainWindow->SetIcon(this, APPNAME);
  2306.     nCmdShow = SW_SHOWMAXIMIZED;
  2307. }
  2308.  
  2309. int
  2310. OwlMain(int /*argc*/, char* /*argv*/ [])
  2311. {
  2312.     GetSFXVersion();
  2313.     return TViewApp().Run();
  2314. }
  2315.  
  2316.  
  2317.