home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-06 | 69.4 KB | 2,054 lines |
- (*********************************************************************)
- (* *)
- (* Microworks ObjectMate 2.6 *)
- (* *)
- (* Windows Interface Develpment Kit for the Borland Languages. *)
- (* *)
- (* SFXVIEW.PAS : Object Viewer *)
- (* *)
- (* Copyright 1992-94 Microworks Sydney, Australia. *)
- (* *)
- (*********************************************************************)
-
- program SFXVIEW;
-
- {$R SFXView.res}
-
- uses WinTypes, WinProcs, ODMenu, SFX200, CommDlg, Strings,
- {$IFDEF Ver15}
- WObjects;
- {$ELSE}
- Objects, OWindows, ODialogs;
- {$ENDIF}
-
- const
-
- { Resource identifiers }
- id_Toolbar = 1;
-
- { File menu commands }
- cm_FileOpen = 100;
- cm_FileExOpen = 101;
- cm_FileOpenExtraFlags = 102;
- cm_FileSaveAs = 103;
- cm_OpenDir = 104;
- cm_OpenDirHelp = 105;
- cm_ExitWindow = 106;
-
- cm_PrintMin = 200;
- cm_Print = 200;
- cm_PrintHelp = 201;
- cm_PrintSetup = 202;
- cm_PrintSetupHelp = 203;
- cm_PrintMax = 203;
-
- { Search menu commands }
- cm_SearchMin = 300;
- cm_SearchFind = 300;
- cm_SearchFindHelp = 301;
- cm_SearchReplace = 302;
- cm_SearchReplaceHelp = 303;
- cm_SearchMax = 303;
-
- { Button identifiers }
- id_SFXFrame = 312;
- id_Gray = 313;
- id_Glaze = 314;
- id_Steel = 315;
- id_3DGray = 316;
- id_3DGlaze = 317;
- id_3DSteel = 318;
- id_mbOk = 319;
- id_mbOkCancel = 320;
- id_mbAbortRetryIgnore = 321;
- id_mbRetryCancel = 322;
- id_mbYesNo = 323;
- id_mbYesNoCancel = 324;
- id_mbGo = 325;
- id_mbGoStop = 326;
- id_mbOkCancelHelp = 327;
- id_mbYesNoHelp = 328;
-
- { Color menu commands }
- cm_BasicColor = 400;
- cm_BasicColorHelp = 401;
- cm_ExtendedColor = 402;
- cm_ExtendedColorHelp = 403;
-
- { Font menu commands }
- cm_BasicFont = 500;
- cm_BasicFontExtraFlags = 501;
- cm_ExtendedFont = 502;
- cm_ExtendedFontApply = 503;
- cm_ExtendedFontHelp = 504;
-
- { Object menu identifiers }
- cm_ObjectMin = 600;
- cm_Button = 601;
- cm_Static = 602;
- cm_Shade = 603;
- cm_Check = 604;
- cm_Radio = 605;
- cm_Control = 606;
- cm_Toolbar = 607;
- cm_MessageBox = 608;
- cm_Window = 609;
-
- { Toolbar menu identifiers }
- cm_Top = 610;
- cm_Float = 611;
- cm_Bottom = 612;
- cm_Status = 613;
- cm_Hints = 614;
- cm_ObjectMax = 614;
-
- { Miscellaneous identifiers }
- id_Timer = 700;
- id_StdBtn = 701;
- id_BitBtn = 702;
- id_StatBmp = 703;
- id_StatText = 704;
- id_Toolbar1 = 705;
- id_Toolbar2 = 706;
- id_Textbtn = 707;
- id_Splash = 708;
-
- { Toolbar identifiers }
- id_One = 801;
- id_Two = 802;
- id_Three = 803;
- id_Four = 804;
-
- { Help menu commands }
- cm_Help = 900;
- cm_About = 901;
-
- AppName : PChar = 'SFXVIEW';
-
- type
-
- PViewApp = ^TViewApp;
- TViewApp = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PDefaultDialog = ^TDefaultDialog;
- TDefaultDialog = object(TDialog)
- procedure SetUpWindow; virtual;
- end;
-
- PChildDialog = ^TChildDialog;
- TChildDialog = object(TDialog)
- procedure SetUpWindow; virtual;
- procedure OK (var Msg: TMessage); virtual id_First + id_Ok;
- procedure Cancel (var Msg: TMessage); virtual id_First + id_Cancel;
- end;
-
- PButtonDialog = ^TButtonDialog;
- TButtonDialog = object(TDialog)
- procedure SetUpWindow; virtual;
- procedure IDStdBtn (var Msg: TMessage); virtual id_First + id_StdBtn;
- procedure IDBitBtn (var Msg: TMessage); virtual id_First + id_BitBtn;
- procedure IDTextBtn (var Msg: TMessage); virtual id_First + id_TextBtn;
- end;
-
- PStaticDialog = ^TStaticDialog;
- TStaticDialog = object(TDialog)
- procedure SetUpWindow; virtual;
- procedure IDStatBmp (var Msg: TMessage); virtual id_First + id_StatBmp;
- procedure IDStatText (var Msg: TMessage); virtual id_First + id_StatText;
- end;
-
- PControlDialog = ^TControlDialog;
- TControlDialog = object(TDialog)
- i : Integer;
- destructor Done; virtual;
- procedure SetUpWindow; virtual;
- procedure WMSFXCtlColor (var Msg: TMessage); virtual wm_First + wm_SFXCtlColor;
- procedure WMTimer (var Msg: TMessage); virtual wm_First + wm_Timer;
- end;
-
- PToolbarDialog = ^TToolbarDialog;
- TToolbarDialog = object(TDialog)
- TB1, TB2, TB3 : PSFXToolbar;
- constructor Init(AParent: PWindowsObject; AName: PChar);
- procedure SetUpWindow; virtual;
- procedure WMCommand (var Msg: TMessage); virtual wm_First + wm_Command;
- end;
-
- PPopupToolbar = ^TPopupToolbar;
- TPopupToolbar = object(TSFXToolbar)
- procedure WMCommand (var Msg: TMessage); virtual wm_First + wm_Command;
- procedure WMNCActivate (var Msg: TMessage); virtual wm_First + wm_NCActivate;
- end;
-
- PMessageBoxDialog = ^TMessageBoxDialog;
- TMessageBoxDialog = object(TDialog)
- MsgStyle : Word;
- procedure SetUpWindow; virtual;
- procedure WMCommand (var Msg: TMessage); virtual wm_First + wm_Command;
- end;
-
- PToolbar = ^TToolbar;
- TToolbar = object(TSFXToolbar)
- procedure WMCommand (var Msg: TMessage); virtual wm_First + wm_Command;
- procedure WMMouseMove (var Msg: TMessage); virtual wm_First + wm_MouseMove;
- end;
-
- PSplashWindow = ^TSplashWindow;
- TSplashWindow = object(TSFXStatic)
- destructor Done; virtual;
- procedure SetUpWindow; virtual;
- procedure WMGetDlgCode (var Msg: TMessage); virtual wm_First + wm_GetDlgCode;
- procedure WMKeyDown (var Msg: TMessage); virtual wm_First + wm_KeyDown;
- procedure WMLButtonDown (var Msg: TMessage); virtual wm_First + wm_LButtonDown;
- procedure WMNCHitTest (var Msg: TMessage); virtual wm_First + wm_NCHitTest;
- procedure WMTimer (var Msg: TMessage); virtual wm_First + wm_Timer;
- end;
-
- PViewWindow = ^TViewWindow;
- TViewWindow = object(TSFXWindow)
- BkBrush : HBrush;
- OldBrush : HBrush;
- Font : HFont;
- OldFont : HFont;
- FindDlg : HWnd; { FindText dialog handle }
- ReplaceDlg : HWnd; { ReplaceText dialog handle }
- Splash : PSplashWindow;
- Toolbar : PToolbar;
- FontColor : TColorRef;
- LogFont : TLogFont;
- frFind : TFindReplace; { Persistent structure for FindText }
- frReplace : TFindReplace; { Persistent structure for ReplaceText }
- MsgFind : Word;
- OldToolbarPos : Word;
- ToolbarPos : Word;
- Text : array[0..255] of Char;
- Find : array[0..255] of Char; { Search string for FindText }
- ReplaceFind : array[0..255] of Char; { Search string for ReplaceText }
- Replace : array[0..255] of Char; { Replace string for ReplaceText }
- Template : Integer;
- Filters : PChar;
- OFNFlags : LongInt;
- szText : array[0..255] of Char;
- Index : LongInt;
- Color : TColorRef;
- CCFlags : LongInt;
- CFFlags : LongInt;
- FindIcon : HIcon;
- ReplaceIcon : HIcon;
- ColorIcon : HIcon;
- FontIcon : HIcon;
- PrintIcon : HIcon;
- DirIcon : HIcon;
- FileIcon : HIcon;
- constructor Init(AParent: PWindowsObject; AName: PChar);
- destructor Done; virtual;
- function GetClassName : PChar; virtual;
- procedure GetWindowClass(var AWndClass: TWndClass); virtual;
- procedure SetUpWindow; virtual;
- procedure Create3DMenus;
- procedure Paint (PaintDC: HDC; var PaintInfo: TPaintStruct); virtual;
- procedure WMSize (var Msg: TMessage); virtual wm_First + wm_Size;
- procedure WMCommand (var Msg: TMessage); virtual wm_First + wm_Command;
- procedure WMDrawItem (var Msg: TMessage); virtual wm_First + wm_DrawItem;
- procedure WMInitMenuPopup (var Msg: TMessage); virtual wm_First + wm_InitMenuPopup;
- procedure WMMeasureItem (var Msg: TMessage); virtual wm_First + wm_MeasureItem;
- procedure WMMenuChar (var Msg: TMessage); virtual wm_First + wm_MenuChar;
- procedure WMMenuSelect (var Msg: TMessage); virtual wm_First + wm_MenuSelect;
- procedure WMMouseMove (var Msg: TMessage); virtual wm_First + wm_MouseMove;
- procedure WMNCMouseMove (var Msg: TMessage); virtual wm_First + wm_NCMouseMove;
- procedure WMSFXApplyColor (var Msg: TMessage); virtual wm_First + wm_SFXApplyColor;
- procedure WMSFXApplyFont (var Msg: TMessage); virtual wm_First + wm_SFXApplyFont;
- procedure WMSFXHelp (var Msg: TMessage); virtual wm_First + wm_SFXHelp;
- procedure WMSFXInitDialog (var Msg: TMessage); virtual wm_First + wm_SFXInitDialog;
- procedure DefWndProc (var Msg: TMessage); virtual;
- procedure UpdateClientRect;
- procedure HandleMouseMove (Point: TPoint);
- procedure HandleSearch (WndOwner: HWnd; pFR: PFindReplace);
- function HandlePrintDialogs (WndOwner: HWnd; iDialog: Word): BOOL;
- function HandleSearchDialogs (WndOwner: HWnd; iDialog: Word): HWnd;
- procedure CMFileOpen (var Msg: TMessage); virtual cm_First + cm_FileOpen;
- procedure CMFileExOpen (var Msg: TMessage); virtual cm_First + cm_FileExOpen;
- procedure CMFileOpenExtraFlags (var Msg: TMessage); virtual cm_First + cm_FileOpenExtraFlags;
- procedure CMFileSaveAs (var Msg: TMessage); virtual cm_First + cm_FileSaveAs;
- procedure CMOpenDir (var Msg: TMessage); virtual cm_First + cm_OpenDir;
- procedure CMOpenDirHelp (var Msg: TMessage); virtual cm_First + cm_OpenDirHelp;
- procedure CMBasicColor (var Msg: TMessage); virtual cm_First + cm_BasicColor;
- procedure CMBasicColorHelp (var Msg: TMessage); virtual cm_First + cm_BasicColorHelp;
- procedure CMExtendedColor (var Msg: TMessage); virtual cm_First + cm_ExtendedColor;
- procedure CMExtendedColorHelp (var Msg: TMessage); virtual cm_First + cm_ExtendedColorHelp;
- procedure CMBasicFont (var Msg: TMessage); virtual cm_First + cm_BasicFont;
- procedure CMBasicFontExtraFlags (var Msg: TMessage); virtual cm_First + cm_BasicFontExtraFlags;
- procedure CMExtendedFont (var Msg: TMessage); virtual cm_First + cm_ExtendedFont;
- procedure CMExtendedFontApply (var Msg: TMessage); virtual cm_First + cm_ExtendedFontApply;
- procedure CMExtendedFontHelp (var Msg: TMessage); virtual cm_First + cm_ExtendedFontHelp;
- procedure CMButton (var Msg: TMessage); virtual cm_First + cm_Button;
- procedure CMStatic (var Msg: TMessage); virtual cm_First + cm_Static;
- procedure CMShade (var Msg: TMessage); virtual cm_First + cm_Shade;
- procedure CMCheck (var Msg: TMessage); virtual cm_First + cm_Check;
- procedure CMRadio (var Msg: TMessage); virtual cm_First + cm_Radio;
- procedure CMControl (var Msg: TMessage); virtual cm_First + cm_Control;
- procedure CMToolbar (var Msg: TMessage); virtual cm_First + cm_Toolbar;
- procedure CMMessageBox (var Msg: TMessage); virtual cm_First + cm_MessageBox;
- procedure CMWindow (var Msg: TMessage); virtual cm_First + cm_Window;
- procedure CMTop (var Msg: TMessage); virtual cm_First + cm_Top;
- procedure CMFloat (var Msg: TMessage); virtual cm_First + cm_Float;
- procedure CMBottom (var Msg: TMessage); virtual cm_First + cm_Bottom;
- procedure CMStatus (var Msg: TMessage); virtual cm_First + cm_Status;
- procedure CMHints (var Msg: TMessage); virtual cm_First + cm_Hints;
- procedure CMAbout (var Msg: TMessage); virtual cm_First + cm_About;
- procedure CMExitWindow (var Msg: TMessage); virtual cm_First + cm_ExitWindow;
- procedure CMHelp (var Msg: TMessage); virtual cm_First + cm_Help;
- end;
-
- var
- UseHints : Boolean;
- Style : Word;
- Tool : Word;
- ClassName : array[0..25] of Char;
-
- {********** TViewApp **********}
-
- procedure TViewApp.InitMainWindow;
- begin
- MainWindow := New(PViewWindow, Init(nil, 'Object Viewer'));
- end;
-
- {********** TViewWindow **********}
-
- constructor TViewWindow.Init(AParent: PWindowsObject; AName: PChar);
- begin
- TSFXWindow.Init(AParent, AName);
- Attr.Style := Attr.Style or mws_3DFrame or mws_SFXCaption;
- Attr.X := 0;
- Attr.Y := 0;
- Attr.W := cw_UseDefault;
- Attr.W := cw_UseDefault;
- Attr.Menu := LoadMenu(HInstance, AppName);
- Color := GetSysColor(Color_Window);
- BkBrush := CreateSolidBrush(Color);
-
- (* 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.
- *)
- Splash := New(PSplashWindow, Init(@Self, id_Splash, 'SplashPanel', 0, 0, 318, 153, 0));
- Splash^.Attr.Style := ws_Child or ws_Visible or mss_CenterBitmap or mss_Raised;
-
- { Set initial RGB font color and default LOGFONT values }
- FontColor := RGB(0, 0, 255);
- FillChar(LogFont, SizeOf(TLogFont), #0);
- with LogFont do
- begin
- lfHeight := 36;
- lfItalic := 0;
- lfWeight := fw_Bold;
- lfStrikeOut := 0;
- lfUnderline := 1;
- lfOutPrecision := Out_Stroke_Precis;
- lfClipPrecision := Clip_Stroke_Precis;
- lfQuality := Default_Quality;
- lfPitchAndFamily := Variable_Pitch;
- StrCopy(lfFaceName, 'Times New Roman');
- end;
- Font := CreateFontIndirect(LogFont);
-
- { Register the Find/Replace common dialog message }
- MsgFind := RegisterWindowMessage(FindMsgString);
- FindDlg := 0;
- ReplaceDlg := 0;
- Toolbar := nil;
- ToolbarPos := 0;
-
- { Load caption icons, depending on height of title bar }
- if GetSystemMetrics(SM_CYSIZE) = 26 then
- begin
- FindIcon := LoadIcon(HInstance, 'Find2');
- ReplaceIcon := LoadIcon(HInstance, 'Replace2');
- ColorIcon := LoadIcon(HInstance, 'Color2');
- FontIcon := LoadIcon(HInstance, 'Font2');
- PrintIcon := LoadIcon(HInstance, 'Print2');
- DirIcon := LoadIcon(HInstance, 'Dir2');
- FileIcon := LoadIcon(HInstance, 'File2');
- end
- else
- begin
- FindIcon := LoadIcon(HInstance, 'Find1');
- ReplaceIcon := LoadIcon(HInstance, 'Replace1');
- ColorIcon := LoadIcon(HInstance, 'Color1');
- FontIcon := LoadIcon(HInstance, 'Font1');
- PrintIcon := LoadIcon(HInstance, 'Print1');
- DirIcon := LoadIcon(HInstance, 'Dir1');
- FileIcon := LoadIcon(HInstance, 'File1');
- end;
-
- { Turn on Flyover Hints }
- UseHints := True;
- CmdShow := sw_ShowMaximized;
- end;
-
- destructor TViewWindow.Done;
- begin
- (* EraseObject is defined in the SFX200 unit. It checks first to
- * make sure the object handle is valid before calling DeleteObject.
- * This the safe way to delete a handle.
- *)
- EraseObject(BkBrush);
- EraseObject(Font);
- EraseObject(FindIcon);
- EraseObject(ReplaceIcon);
- EraseObject(ColorIcon);
- EraseObject(FontIcon);
- EraseObject(PrintIcon);
- EraseObject(DirIcon);
- EraseObject(FileIcon);
- TSFXWindow.Done;
- end;
-
- function TViewWindow.GetClassName;
- begin
- GetClassName := AppName;
- end;
-
- procedure TViewWindow.GetWindowClass(var AWndClass: TWndClass);
- begin
- TSFXWindow.GetWindowClass(AWndClass);
-
- (* SFXDefWindowProc's default window color is light gray. To override this
- * you must supply a valid brush handle or specify one of the color flags
- * MWS_GLAZE or MWS_STEEL with AWndClass.HBrBackground set to zero.
- *)
- AWndClass.HBrBackground := BkBrush;
- AWndClass.HIcon := LoadIcon(HInstance, AppName);
- AWndclass.Style := AWndclass.Style and not cs_HRedraw and not cs_VRedraw;
- end;
-
- procedure TViewWindow.SetUpWindow;
- var
- Msg : TMessage;
- begin
- TSFXWindow.SetUpWindow;
-
- (* Set up 3D ownerdraw menu items
- *)
- Create3DMenus;
-
- (* Create a top aligned toolbar - see CMTOP procedure
- *)
- Tool := id_One;
- CMStatus(Msg);
- CheckMenuItem(Attr.Menu, cm_Hints, mf_ByCommand or mf_Checked);
-
- (* Set the initial dialog class displayed to SFX3DDlg. This
- * information is changed when the user presses a toolbar button.
- *)
- StrCopy(ClassName, 'SFX3DDlg');
- Style := mws_SFXFrame;
-
- (* The CenterWindow function is defined in the SFX200 unit. 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);
- SetFocus(Splash^.HWindow);
- end;
-
- procedure TViewWindow.Create3DMenus;
- var
- Menu : HMenu;
- MenuText : PChar;
- begin
- (* 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(Attr.Menu, 0);
- MenuText := '&Open...';
- ModifyMenu(Menu, 0, mf_ByPosition or mf_OwnerDraw, cm_FileOpen, MenuText);
- MenuText := 'Open with E&xtended Select...';
- ModifyMenu(Menu, 1, mf_ByPosition or mf_OwnerDraw, cm_FileExOpen, MenuText);
- MenuText := 'Open with Extra &Flags...';
- ModifyMenu(Menu, 2, mf_ByPosition or mf_OwnerDraw, cm_FileOpenExtraFlags, MenuText);
- MenuText := '&Save As...';
- ModifyMenu(Menu, 3, mf_ByPosition or mf_OwnerDraw, cm_FileSaveAs, MenuText);
- MenuText := '&Directory...';
- ModifyMenu(Menu, 5, mf_ByPosition or mf_OwnerDraw, cm_OpenDir, MenuText);
- MenuText := 'Di&rectory with Help...';
- ModifyMenu(Menu, 6, mf_ByPosition or mf_OwnerDraw, cm_OpenDirHelp, MenuText);
- MenuText := '&Print...';
- ModifyMenu(Menu, 8, mf_ByPosition or mf_OwnerDraw, cm_Print, MenuText);
- MenuText := 'Pr&int with Help...';
- ModifyMenu(Menu, 9, mf_ByPosition or mf_OwnerDraw, cm_PrintHelp, MenuText);
- MenuText := 'Pri&nter Setup...';
- ModifyMenu(Menu, 10, mf_ByPosition or mf_OwnerDraw, cm_PrintSetup, MenuText);
- MenuText := 'Prin&ter Setup with Help...';
- ModifyMenu(Menu, 11, mf_ByPosition or mf_OwnerDraw, cm_PrintSetupHelp, MenuText);
- MenuText := '&Exit';
- ModifyMenu(Menu, 13, mf_ByPosition or mf_OwnerDraw, cm_ExitWindow, MenuText);
-
- Menu := GetSubMenu(Attr.Menu, 1);
- MenuText := '&Find...';
- ModifyMenu(Menu, 0, mf_ByPosition or mf_OwnerDraw, cm_SearchFind, MenuText);
- MenuText := 'F&ind with Help...';
- ModifyMenu(Menu, 1, mf_ByPosition or mf_OwnerDraw, cm_SearchFindHelp, MenuText);
- MenuText := '&Replace...';
- ModifyMenu(Menu, 3, mf_ByPosition or mf_OwnerDraw, cm_SearchReplace, MenuText);
- MenuText := 'R&eplace with Help...';
- ModifyMenu(Menu, 4, mf_ByPosition or mf_OwnerDraw, cm_SearchReplaceHelp, MenuText);
-
- Menu := GetSubMenu(Attr.Menu, 2);
- MenuText := '&Basic Color...';
- ModifyMenu(Menu, 0, mf_ByPosition or mf_OwnerDraw, cm_BasicColor, MenuText);
- MenuText := 'Basic &Color with Help...';
- ModifyMenu(Menu, 1, mf_ByPosition or mf_OwnerDraw, cm_BasicColorHelp, MenuText);
- MenuText := '&Extended Color...';
- ModifyMenu(Menu, 3, mf_ByPosition or mf_OwnerDraw, cm_ExtendedColor, MenuText);
- MenuText := 'E&xtended Color with Help...';
- ModifyMenu(Menu, 4, mf_ByPosition or mf_OwnerDraw, cm_ExtendedColorHelp, MenuText);
-
- Menu := GetSubMenu(Attr.Menu, 3);
- MenuText := '&Basic Font...';
- ModifyMenu(Menu, 0, mf_ByPosition or mf_OwnerDraw, cm_BasicFont, MenuText);
- MenuText := 'Basic &Font with Extra Flags...';
- ModifyMenu(Menu, 1, mf_ByPosition or mf_OwnerDraw, cm_BasicFontExtraFlags, MenuText);
- MenuText := '&Extended Font...';
- ModifyMenu(Menu, 3, mf_ByPosition or mf_OwnerDraw, cm_ExtendedFont, MenuText);
- MenuText := 'E&xtended Font with Apply...';
- ModifyMenu(Menu, 4, mf_ByPosition or mf_OwnerDraw, cm_ExtendedFontApply, MenuText);
- MenuText := 'Ex&tended Font with Help...';
- ModifyMenu(Menu, 5, mf_ByPosition or mf_OwnerDraw, cm_ExtendedFontHelp, MenuText);
-
- Menu := GetSubMenu(Attr.Menu, 4);
- MenuText := '&Buttons...';
- ModifyMenu(Menu, 0, mf_ByPosition or mf_OwnerDraw, cm_Button, MenuText);
- MenuText := '&Static Controls...';
- ModifyMenu(Menu, 1, mf_ByPosition or mf_OwnerDraw, cm_Static, MenuText);
- MenuText := 'S&hade Controls...';
- ModifyMenu(Menu, 2, mf_ByPosition or mf_OwnerDraw, cm_Shade, MenuText);
- MenuText := 'Chec&k Boxes...';
- ModifyMenu(Menu, 3, mf_ByPosition or mf_OwnerDraw, cm_Check, MenuText);
- MenuText := '&Radio Buttons...';
- ModifyMenu(Menu, 4, mf_ByPosition or mf_OwnerDraw, cm_Radio, MenuText);
- MenuText := '&Controls...';
- ModifyMenu(Menu, 5, mf_ByPosition or mf_OwnerDraw, cm_Control, MenuText);
- MenuText := '&Toolbars...';
- ModifyMenu(Menu, 7, mf_ByPosition or mf_OwnerDraw, cm_Toolbar, MenuText);
- MenuText := '&Message && Input Boxes...';
- ModifyMenu(Menu, 8, mf_ByPosition or mf_OwnerDraw, cm_MessageBox, MenuText);
- MenuText := '&Windows...';
- ModifyMenu(Menu, 10, mf_ByPosition or mf_OwnerDraw, cm_Window, MenuText);
-
- Menu := GetSubMenu(Attr.Menu, 5);
- MenuText := '&Top';
- ModifyMenu(Menu, 0, mf_ByPosition or mf_OwnerDraw, cm_Top, MenuText);
- MenuText := '&Floating';
- ModifyMenu(Menu, 1, mf_ByPosition or mf_OwnerDraw, cm_Float, MenuText);
- MenuText := '&Bottom';
- ModifyMenu(Menu, 2, mf_ByPosition or mf_OwnerDraw, cm_Bottom, MenuText);
- MenuText := '&Status Bar';
- ModifyMenu(Menu, 3, mf_ByPosition or mf_OwnerDraw, cm_Status, MenuText);
- MenuText := 'Flyover &Hints';
- ModifyMenu(Menu, 5, mf_ByPosition or mf_OwnerDraw, cm_Hints, MenuText);
-
- Menu := GetSubMenu(Attr.Menu, 6);
- MenuText := '&ObjectMate Reference...';
- ModifyMenu(Menu, 0, mf_ByPosition or mf_OwnerDraw, cm_Help, MenuText);
- MenuText := '&About ObjectMate...';
- ModifyMenu(Menu, 1, mf_ByPosition or mf_OwnerDraw, cm_About, MenuText);
- end;
-
- procedure TViewWindow.Paint (PaintDC: HDC; var PaintInfo: TPaintStruct);
- begin
- SetTextColor(PaintDC, FontColor);
- SetBkMode(PaintDC, TRANSPARENT);
- if Font <> 0 then
- OldFont := SelectObject(PaintDC, Font);
- TextOut(PaintDC, 10, 30, 'Microworks ObjectMate 2.6', 25);
- if Font <> 0 then
- SelectObject(PaintDC, OldFont);
- end;
-
- procedure TViewWindow.WMSize (var Msg: TMessage);
- var
- CRect : TRect;
- begin
- (* AlignToolbar is a TSFXToolbar object method defined in the SFX200 unit. 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.
- *)
- UpdateClientRect;
- end;
-
- procedure TViewWindow.WMCommand (var Msg: TMessage);
- begin
- with Msg do
- begin
- if UseHints and (lParamLo = 0) and (lParamHi = 0) then
- Toolbar^.SetText('');
- if (wParam >= cm_PrintMin) and (wParam <= cm_PrintMax) then
- HandlePrintDialogs(HWindow, wParam)
- else
- if (wParam >= cm_SearchMin) and (wParam <= cm_SearchMax) then
- HandleSearchDialogs(HWindow, wParam)
- else
- TSFXWindow.WMCommand(Msg);
- end;
- end;
-
- procedure TViewWindow.WMDrawItem (var Msg:tMessage);
- begin
- (* Pass WMDrawItem onto DrawMenuItem. If you don't want the user to
- * change fonts and highlight colors you can use the default zero
- * values for Font, Color and TextColor.
- *)
- if PDrawItemStruct(Msg.lParam)^.CtlType = ODT_MENU then
- DrawMenuItem(PDrawItemStruct(Msg.lParam), 0, 0, 0);
- end;
-
- procedure TViewWindow.WMInitMenuPopup (var Msg: TMessage);
- begin
- if (Msg.lParamHi = 0) and (Msg.lParamLo = 5) then
- begin
- if ToolbarPos <> OldToolbarPos then
- begin
- CheckMenuItem(Msg.wParam, ToolbarPos, MF_CHECKED);
- CheckMenuItem(Msg.wParam, OldToolbarPos, MF_UNCHECKED);
- end;
- if UseHints then
- CheckMenuItem(Msg.wParam, cm_Hints, MF_CHECKED)
- else
- CheckMenuItem(Msg.wParam, cm_Hints, MF_UNCHECKED);
- end
- else
- TSFXWindow.DefWndProc(Msg);
- end;
-
- procedure TViewWindow.WMMeasureItem (var Msg: TMessage);
- begin
- (* The same font handle passed to DrawMenuItem must be passed to MeasureMenuItem
- *)
- if PMeasureItemStruct(Msg.lParam)^.CtlType = ODT_MENU then
- MeasureMenuItem(HWindow, PMeasureItemStruct(Msg.lParam), 0);
- end;
-
- procedure TViewWindow.WMMenuChar (var Msg: TMessage);
- begin
- (* ProcessSystemChar automatically handles ownerdraw system menu mnemonics.
- *)
- if Msg.lParamLo and mf_SysMenu <> 0 then
- Msg.Result := ProcessSystemChar(Msg.wParam)
- else
- if Msg.lParamHi = GetSubMenu(GetMenu(HWindow), 0) then
- begin
- case Msg.wParam of
- 79, 111: Msg.Result := MakeLong(0, 2);
- 88, 120: Msg.Result := MakeLong(1, 2);
- 70, 102: Msg.Result := MakeLong(2, 2);
- 83, 115: Msg.Result := MakeLong(3, 2);
- 68, 100: Msg.Result := MakeLong(5, 2);
- 82, 114: Msg.Result := MakeLong(6, 2);
- 80, 112: Msg.Result := MakeLong(8, 2);
- 73, 105: Msg.Result := MakeLong(9, 2);
- 78, 110: Msg.Result := MakeLong(10, 2);
- 84, 116: Msg.Result := MakeLong(11, 2);
- 69, 101: Msg.Result := MakeLong(13, 2);
- end;
- end
- else
- if (Msg.lParamHi = GetSubMenu(GetMenu(HWindow), 1)) then
- begin
- case Msg.wParam of
- 70, 102: Msg.Result := MakeLong(0, 2);
- 73, 105: Msg.Result := MakeLong(1, 2);
- 82, 114: Msg.Result := MakeLong(3, 2);
- 69, 101: Msg.Result := MakeLong(4, 2);
- end;
- end
- else
- if Msg.lParamHi = GetSubMenu(GetMenu(HWindow), 2) then
- begin
- case Msg.wParam of
- 66, 98: Msg.Result := MakeLong(0, 2);
- 67, 99: Msg.Result := MakeLong(1, 2);
- 69, 101: Msg.Result := MakeLong(3, 2);
- 88, 120: Msg.Result := MakeLong(4, 2);
- end;
- end
- else
- if Msg.lParamHi = GetSubMenu(GetMenu(HWindow), 3) then
- begin
- case Msg.wParam of
- 66, 98: Msg.Result := MakeLong(0, 2);
- 70, 102: Msg.Result := MakeLong(1, 2);
- 69, 101: Msg.Result := MakeLong(3, 2);
- 88, 120: Msg.Result := MakeLong(4, 2);
- 84, 116: Msg.Result := MakeLong(5, 2);
- end;
- end
- else
- if Msg.lParamHi = GetSubMenu(GetMenu(HWindow), 4) then
- begin
- case Msg.wParam of
- 66, 98: Msg.Result := MakeLong(0, 2);
- 83, 115: Msg.Result := MakeLong(1, 2);
- 72, 104: Msg.Result := MakeLong(2, 2);
- 75, 107: Msg.Result := MakeLong(3, 2);
- 82, 114: Msg.Result := MakeLong(4, 2);
- 67, 99: Msg.Result := MakeLong(5, 2);
- 84, 116: Msg.Result := MakeLong(7, 2);
- 77, 109: Msg.Result := MakeLong(8, 2);
- 87, 119: Msg.Result := MakeLong(10, 2);
- end;
- end
- else
- if Msg.lParamHi = GetSubMenu(GetMenu(HWindow), 5) then
- begin
- case Msg.wparam of
- 84, 116: Msg.Result := MakeLong(0, 2);
- 70, 102: Msg.Result := MakeLong(1, 2);
- 66, 98: Msg.Result := MakeLong(2, 2);
- 83, 115: Msg.Result := MakeLong(3, 2);
- 72, 104: Msg.Result := MakeLong(5, 2);
- end;
- end
- else
- if Msg.lParamHi = GetSubMenu(GetMenu(HWindow), 6) then
- begin
- case Msg.wParam of
- 79, 111: Msg.Result := MakeLong(0, 2);
- 65, 97: Msg.Result := MakeLong(1, 2);
- end;
- end;
- end;
-
- procedure TViewWindow.WMMenuSelect (var Msg: TMessage);
- begin
- if UseHints then
- begin
- Text[0] := #0;
- LoadString(HInstance, Msg.wParam, Text, SizeOf(Text));
- Toolbar^.SetText(Text);
- end;
- end;
-
- procedure TViewWindow.WMMouseMove (var Msg: TMessage);
- begin
- HandleMouseMove(MakePoint(Msg.lParam));
- end;
-
- procedure TViewWindow.WMNCMousemove (var Msg: TMessage);
- begin
- HandleMouseMove(MakePoint(Msg.lParam));
- end;
-
- procedure TViewWindow.WMSFXApplyColor (var Msg: TMessage);
- begin
- (* This private message is sent when the user presses the Apply button in
- * a Color common dialog box. Msg.wParam is zero and Msg.lParam is the new RGB color
- * value selected by the user. This value is used to change the window's
- * background brush.
- *)
- BkBrush := CreateSolidBrush(Msg.lParam);
- OldBrush := SetClassWord(HWindow, gcw_HBrBackground, BkBrush);
- EraseObject(OldBrush);
- UpdateClientRect;
- end;
-
- procedure TViewWindow.WMSFXApplyFont (var Msg: TMessage);
- begin
- (* This private message is sent when the user presses the Apply button in a
- * Font common dialog box. Msg.wParam is the handle of the newly created font
- * and Msg.lParam is the new RGB color value. If the color option is not used
- * by the font dialog box Msg.lParam is 'RGB(0, 0, 0)'. SFX200.DLL does not delete
- * this font, that's your responsiblilty!
- *)
- EraseObject(Font);
- Font := Msg.wParam;
- FontColor := Msg.lParam;
- UpdateClientRect;
- end;
-
- procedure TViewWindow.WMSFXHelp (var Msg: TMessage);
- begin
- (* This private message is sent when the user presses the help button in a
- * one of the common dialog boxes. Msg.wParam is zero, Msg.lParamLo is the
- * window handle of the common dialog box sending the message and Msg.lParamHi
- * identifies the type of common dialog box template sending the message. It is
- * one of the common dialog constants defined in the SFX200 unit.
- *)
- Text[0] := #0;
- LoadString(HInstance, Msg.lParamHi, Text, SizeOf(Text));
- SFXMsgBox(HWindow, Text, 'Information', mb_IconInformation, Style);
- end;
-
- procedure TViewWindow.WMSFXInitDialog (var Msg: TMessage);
- begin
- (* 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(Msg.wParam, gwl_Style, GetWindowLong(Msg.wParam, gwl_Style) or 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 Msg.lParam is 1 to prevent the icon shrinking.
- *)
- if Msg.lParamHi = dlg_Find then
- SendMessage(Msg.wParam, wm_SetBitmap, FindIcon, 1);
- if Msg.lParamHi = dlg_Replace then
- SendMessage(Msg.wParam, wm_SetBitmap, ReplaceIcon, 1);
- if (Msg.lParamHi = dlg_Color) or (Msg.lParamHi = dlg_ExColor) then
- SendMessage(Msg.wParam, wm_SetBitmap, ColorIcon, 1);
- if (Msg.lParamHi = dlg_Font) or (Msg.lParamHi = dlg_ExFont) then
- SendMessage(Msg.wParam, wm_SetBitmap, FontIcon, 1);
- if (Msg.lParamHi = dlg_Print) or (Msg.lParamHi = dlg_PrintSetup) then
- SendMessage(Msg.wParam, wm_SetBitmap, PrintIcon, 1);
- if Msg.lParamHi = dlg_Opendir then
- SendMessage(Msg.wParam, wm_SetBitmap, DirIcon, 1);
- if (Msg.lParamHi = dlg_OpenSave) or (Msg.lParamHi = dlg_ExOpenSave) then
- SendMessage(Msg.wParam, wm_SetBitmap, FileIcon, 1);
- end;
-
- procedure TViewWindow.DefWndProc (var Msg: TMessage);
- begin
- { Trap the Find/Replace message }
- with Msg do
- if Message = MsgFind then
- HandleSearch(HWindow, PFindReplace(Msg.lParam))
- else
- TSFXWindow.DefWndProc(Msg);
- end;
-
- procedure TViewWindow.UpdateClientRect;
- var
- CRect : TRect;
- begin
- GetClientRect(HWindow, CRect);
- if ToolbarPos = cm_Top then
- Inc(CRect.Top, 27)
- else
- if (ToolbarPos = cm_Bottom) or (ToolbarPos = cm_Status) then
- Dec(CRect.Bottom, 27);
- InvalidateRect(HWindow, @CRect, True);
- end;
-
- procedure TViewWindow.HandleMouseMove (Point: TPoint);
- var
- ChildRect : TRect;
- begin
- (* UseHints is a boolean 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
- * WM_MOUSEMOVE method.
- *)
- if UseHints then
- begin
- ChildRect := ChildToParentRect(Toolbar^.HWindow)^;
- if not PtInRect(ChildRect, Point) then
- begin
- Toolbar^.GetText(Text);
- if StrIComp(Text, #0) <> 0 then
- Toolbar^.SetText(#0);
- end;
- end;
- end;
-
- procedure TViewWindow.HandleSearch (WndOwner: HWnd; pFR: PFindReplace);
- var
- FindMsg : array[0..512] of Char;
- begin
- with pFR^ do
- begin
- if fr_DialogTerm and Flags <> 0 then
- begin
- (* The dialog is closing on the Close button. Therefore we must
- * invalidate the handle we saved from FindText or ReplaceText.
- * Since we have two window handles for these dialogs we have to
- * determine which one to invalidate. Since the FINDMSGSTRING
- * message does not distinguish the two dialogs, we have stored
- * a non-zero in the FINDREPLACE structure's lCustData for
- * FindText and a zero for ReplaceText.
- *)
- if lCustData <> 0 then
- FindDlg := 0
- else
- ReplaceDlg := 0;
- Exit;
- end;
-
- (* Perform your searching here. For this example the state of the
- * various flags simply reported.
- *)
- StrCopy(FindMsg, 'Dialog:'#9#9);
- if lCustData <> 0 then
- StrCat(FindMsg, 'Find'#10#13)
- else
- StrCat(FindMsg, 'Replace'#10#13);
-
- StrCat(FindMsg, 'Button:'#9#9);
- if Flags and fr_FindNext <> 0 then
- StrCat(FindMsg, 'Find Next'#10#13)
- else
- if Flags and fr_Replace <> 0 then
- StrCat(FindMsg, 'Replace'#10#13)
- else
- if Flags and fr_ReplaceAll <> 0 then
- StrCat(FindMsg, 'Replace All'#10#13);
-
- StrCat(FindMsg, 'Direction:'#9);
- if Flags and fr_Down <> 0 then
- StrCat(FindMsg, 'Forward'#10#13)
- else
- StrCat(FindMsg, 'Backward'#10#13);
-
- StrCat(FindMsg, 'Whole Word:'#9);
- if Flags and fr_WholeWord <> 0 then
- StrCat(FindMsg, 'On'#10#13)
- else
- StrCat(FindMsg, 'Off'#10#13);
-
- StrCat(FindMsg, 'Match Case:'#9);
- if Flags and fr_MatchCase <> 0 then
- StrCat(FindMsg, 'On'#10#13)
- else
- StrCat(FindMsg, 'Off'#10#13);
- SFXMsgBox(WndOwner, FindMsg, 'Find/Replace Message', mb_IconInformation, 0);
- end;
- end;
-
- function TViewWindow.HandlePrintDialogs (WndOwner: HWnd; iDialog: Word): BOOL;
- var
- pd : TPrintDlg;
- Reply : BOOL;
- DocName : PChar;
- begin
- FillChar(pd, SizeOf(TPrintDlg), #0);
- with pd do
- begin
- lStructSize := SizeOf(TPrintDlg);
- hwndOwner := WndOwner;
- hInstance := GetSFXInstance; { Returns instance handle of SFX200.DLL }
- { GetSFXTemplate returns a pointer the string identifing which template to load }
- lpPrintTemplateName := GetSFXTemplate(ClassName, DLG_PRINT);
- lpSetupTemplateName := GetSFXTemplate(ClassName, DLG_PRINTSETUP);
-
- case iDialog of
- cm_Print, cm_PrintHelp:
- begin
- { Returns DC for printer }
- Flags := Flags or pd_ReturnDC or pd_AllPages or pd_Collate or pd_DisablePrintToFile or
- pd_EnablePrintTemplate or pd_EnableSetupTemplate;
-
- if iDialog = cm_PrintHelp then
- Flags := Flags or pd_ShowHelp;
-
- nCopies := 1; { Initial contents of the Copies edit control.}
- nFromPage := 1; { Initial contents of the From edit control.}
- nToPage := 25; { Initial contents of the To edit control.}
- nMinPage := 1; { Lowest possible number in the From/To edits.}
- nMaxPage := 25; { Highest possible number in the From/To edits.}
- Reply := PrintDlg(pd);
- if Reply then
- begin
- (* Print something useless...note that this code
- * ignores trying to make the point size in the
- * font match the point size on the printed page.
- * This is simply to demonstrate that the hDC is
- * immediately available for printing.
- *)
- if Font <> 0 then
- begin
- OldFont := SelectObject(pd.hDC, Font);
- DocName := 'Printing Test';
- Escape(pd.hDC, StartDoc, 14, DocName, nil);
- TextOut(pd.hDC, 50, 50, 'Microworks ObjectMate 2.3', 27);
- Escape(pd.hDC, NewFrame, 0, nil, nil);
- Escape(pd.hDC, EndDoc, 0, nil, nil);
-
- { Cleanup }
- if Font <> 0 then
- SelectObject(pd.hDC, OldFont);
- end;
- end;
- end;
-
- cm_PrintSetup, cm_PrintSetupHelp:
- begin
- (* Do Printer Setup only with PD_PRINTSETUP. You can still
- * retrieve the DC/IC from this with PD_RETURNDC or PD_RETURNIC.
- *)
- Flags := Flags or pd_ReturnIC or pd_PrintSetup or pd_EnableSetupTemplate;
-
- if iDialog = cm_PrintSetupHelp then
- Flags := Flags or pd_ShowHelp;
- Reply := PrintDlg(pd);
- end;
-
- end;
-
-
- (* Cleanup: Delete any DC or IC created by PrintDlg and free the
- * allocated handles hDevMode and hDevNames. The caller is responsible
- * to perform this cleanup once it is finished using the DC or the data.
- *)
- if pd.hDC <> 0 then
- DeleteDC(pd.hDC);
-
- if pd.hDevMode <> 0 then
- GlobalFree(pd.hDevMode);
-
- if pd.hDevNames <> 0 then
- GlobalFree(pd.hDevNames);
- HandlePrintDialogs := Reply;
- end;
- end;
-
- function TViewWindow.HandleSearchDialogs (WndOwner: HWnd; iDialog: Word): HWnd;
- var
- HDialog : HWnd;
- begin
- (* Since we pass a pointer to the TFindReplace structure for
- * a modeless dialog, the structure must persist outside the scope of
- * this function, that is, it must be global. We use a
- * different structure for FindText and ReplaceText since we allow
- * both dialogs to be active at one time.
- *)
- case iDialog of
- cm_SearchFind, cm_SearchFindHelp:
- begin
- if FindDlg <> 0 then
- Exit;
- FillChar(frFind, SizeOf(TFindReplace), #0);
- with frFind do
- begin
- lStructSize := SizeOf(TFindReplace);
- hwndOwner := WndOwner;
- hInstance := GetSFXInstance;
- lpTemplateName := GetSFXTemplate(ClassName, dlg_Find);
- StrCopy(Find, 'Search String');
- lpstrFindWhat := Find;
- wFindWhatLen := SizeOf(Find);
- Flags := Flags or fr_Down or fr_MatchCase or fr_WholeWord or fr_EnableTemplate;
- if iDialog = cm_SearchFindHelp then
- Flags := Flags or fr_ShowHelp;
- (* For our own purposes, use lCustData to distinguish
- * an invocation of Find vs. and invocation or Replace
- * within the message processing for FindMsgString. Otherwise
- * there's no way to distinguish where that message originated.
- *)
- lCustData := 1;
- FindDlg := FindText(frFind);
- HDialog := FindDlg;
- (* FindText returns as soon as the dialog is up. Therefore we
- * have to manage memory and so forth when we are told it's
- * closing. Memory for the TFindReplace structure and the
- * lpstrFindWhat string both must be global.
- *)
- end;
- end;
-
- cm_SearchReplace, cm_SearchReplaceHelp:
- begin
- if ReplaceDlg <> 0 then
- Exit;
- FillChar(frReplace, SizeOf(TFindReplace), #0);
- with frReplace do
- begin
- lStructSize := SizeOf(TFindReplace);
- hwndOwner := WndOwner;
- hInstance := GetSFXInstance;
- lpTemplateName := GetSFXTemplate(ClassName, dlg_Replace);
- StrCopy(ReplaceFind, 'Search String');
- lpstrFindWhat := ReplaceFind;
- wFindWhatLen := SizeOf(ReplaceFind);
- StrCopy(Replace, 'Replace String');
- lpstrReplaceWith := Replace;
- wReplaceWithLen := SizeOf(Replace);
- Flags := Flags or fr_WholeWord or fr_EnableTemplate;
- if iDialog = cm_SearchReplaceHelp then
- Flags := Flags or fr_ShowHelp;
- lCustData := 0;
- ReplaceDlg := ReplaceText(frReplace);
- HDialog := ReplaceDlg;
- end;
- end;
- end;
- HandleSearchDialogs := HDialog;
- end;
-
- procedure TViewWindow.CMFileOpen (var Msg: TMessage);
- begin
- (* The new SFXOpenFile function is the easiest way to display a 'Open File'
- * common dialog box. Many of the arguments have defaults and may only require
- * a 'nil' or '0' value, depending on your requirements.
- *)
- Filters := 'All Files (*.*)'#0'*.*'#0'Source Files (*.PAS)'#0'*.PAS'#0;
- OFNFlags := 0;
- Index := 1;
- szText[0] := #0;
- Template := GetSFXTemplateId(ClassName, dlg_OpenSave);
- if (SFXOpenFile(HWindow, szText, Filters, OFNFlags, Template, False, nil, index, nil)) then
- SFXMsgBox(HWindow, szText, 'You selected', mb_IconInformation, Style or mws_SFXCaption);
- end;
-
- procedure TViewWindow.CMFileExOpen (var Msg: TMessage);
- begin
- Filters := 'All Files (*.*)'#0'*.*'#0'Source Files (*.PAS)'#0'*.PAS'#0;
- OFNFlags := 0;
- Index := 1;
- szText[0] := #0;
- Template := GetSFXTemplateId(ClassName, dlg_ExOpenSave);
- if SFXOpenFile(HWindow, szText, Filters, OFNFlags, Template, TRUE, nil, index, nil) then
- SFXMsgBox(HWindow, szText, 'You selected', mb_IconInformation, Style or mws_SFXCaption);
- end;
-
- procedure TViewWindow.CMFileOpenExtraFlags (var Msg: TMessage);
- begin
- Filters := 'All Files (*.*)'#0'*.*'#0'Source Files (*.PAS)'#0'*.PAS'#0;
- OFNFlags := ofn_ShowHelp;
- Index := 1;
- szText[0] := #0;
- Template := GetSFXTemplateId(ClassName, dlg_OpenSave);
- if SFXOpenFile(HWindow, szText, Filters, OFNFlags, Template, TRUE, nil, index, nil) then
- SFXMsgBox(HWindow, szText, 'You selected', mb_IconInformation, Style);
- end;
-
- procedure TViewWindow.CMFileSaveAs (var Msg: TMessage);
- begin
- (* The new SFXSaveFile function is the easiest way to display a 'Save File As'
- * common dialog box. Many of the arguments have defaults and may only require
- * a 'nil' or '0' value, depending on your requirements.
- *)
- Filters := 'All Files (*.*)'#0'*.*'#0'Source Files (*.PAS)'#0'*.PAS'#0;
- OFNFlags := ofn_FileMustExist or ofn_HideReadOnly;
- Index := 1;
- szText[0] := #0;
- Template := GetSFXTemplateId(ClassName, dlg_OpenSave);
- if SFXSaveFile(HWindow, szText, Filters, OFNFlags, Template, TRUE, nil, index, nil) then
- SFXMsgBox(HWindow, szText, 'You selected', mb_IconInformation, Style);
- end;
-
- procedure TViewWindow.CMOpenDir (var Msg: TMessage);
- begin
- (* SFXDirBox displays a directory selection common dialog box. This function
- * displays the dialog box by MWS_XXX style flag (like the SFXMsgBox) not
- * template ID and it centers the dialog box over the desktop window.
- *)
- if SFXDirBox(HWindow, 'Select Directory', Text, 0, Style) = id_OK then
- SFXMsgBox(HWindow, Text, 'You Selected', mb_IconInformation, Style);
- end;
-
- procedure TViewWindow.CMOpenDirHelp (var Msg: TMessage);
- begin
- (* The new SFXOpenDir function is the easiest way to display an 'Open File' style
- * directory selection common dialog box style. Many of the arguments have defaults
- * and may only require a 'nil' or '0' value depending on your requirements. This
- * function is similar to SFXDirBox but gives you more options.
- *)
- OFNFlags := ofn_NoChangeDir or ofn_ShowHelp;
- szText[0] := #0;
- Template := GetSFXTemplateId(ClassName, dlg_OpenDir);
- if SFXOpenDir (HWindow, szText, 'Change Directory', OFNFlags, Template, TRUE) then
- SFXMsgBox(HWindow, szText, 'You selected', mb_IconInformation, Style or mws_SFXCaption);
- end;
-
- procedure TViewWindow.CMBasicColor (var Msg: TMessage);
- begin
- (* The new SFXChooseColor function is the easiest way to display a 'Choose color'
- * common dialog box. Many of the arguments have defaults and may only require
- * a 'nil' or '0' value, depending on your requirements.
- *
- * The basic 'CommDlg.dll' color dialog does not have an Apply button.
- * ObjectMate adds an Apply button to the color dialog box and displays
- * it by default. To use the apply button all you have to do is trap the
- * WM_SFXAPPLYCOLOR message in the parent's window function, SFX200.DLL
- * handles the button for you. wParam is zero and lParam contains the
- * selected RGB color value. The Apply button is only activated when the
- * CC_FULLOPEN flag is specified or the color dialog box has been opened
- * by the user.
- *
- * Specifing CC_SHOWHELP displays a help button instead of an Apply button.
- * SFX200.DLL manages the help button for you so you don't have to worry about
- * hooks. When you press the help button a WM_SFXHELP message is sent to the
- * owner of the dialog box. wParam is zero, LOWORD(lParam) contains the window
- * handle of the dialog box sending the message and HIWORD(lParam) contains the
- * dialog-identifier, identifying which type of common dialog box sent
- * the message. eg dlg_Color or dlg_ExColor.
- *)
- CCFlags := cc_RGBInit;
- Template := GetSFXTemplateId(ClassName, dlg_Color);
- if SFXChooseColor(HWindow, Color, CCFlags, Template, False, nil) then
- SendMessage(HWindow, wm_SFXApplyColor, 0, Color);
- end;
-
- procedure TViewWindow.CMBasicColorHelp (var Msg: TMessage);
- type
- TLongArray = array [0..15] of Longint;
- const
- { Establishes a set of custom colors in 15 shades of blue }
- CustColors: TLongArray = (
- $000000, $100000, $200000, $300000,
- $400000, $500000, $600000, $700000,
- $800000, $900000, $A00000, $B00000,
- $C00000, $D00000, $E00000, $F00000);
- begin
- CCFlags := cc_RGBInit or cc_ShowHelp or cc_FullOpen;
- Template := GetSFXTemplateId(ClassName, dlg_Color);
- if SFXChooseColor(HWindow, Color, CCFlags, Template, True, @CustColors) then
- SendMessage(HWindow, wm_SFXApplyColor, 0, Color);
- end;
-
- procedure TViewWindow.CMExtendedColor (var Msg: TMessage);
- begin
- (* The extended style color dialog box is customized to display
- * only 48 basic colors. It does not open. By default it displays an Apply
- * button. To activate the Apply button in this template you must
- * specify the CC_FULLOPEN flag. Specifying CC_FULLOPEN activates the
- * hidden controls SFX200.DLL reads to determine the color selection.
- *)
- CCFlags := cc_RGBInit or cc_FullOpen;
- Template := GetSFXTemplateId(ClassName, dlg_ExColor);
- if SFXChooseColor(HWindow, Color, CCFlags, Template, True, nil) then
- SendMessage(HWindow, wm_SFXApplyColor, 0, Color);
- end;
-
- procedure TViewWindow.CMExtendedColorHelp (var Msg: TMessage);
- begin
- (* Specifing CC_SHOWHELP displays a help button instead of an Apply button.
- *)
- CCFlags := cc_RGBInit or cc_ShowHelp;
- Template := GetSFXTemplateId(ClassName, dlg_ExColor);
- if SFXChooseColor(HWindow, Color, CCFlags, Template, False, nil) then
- SendMessage(HWindow, wm_SFXApplyColor, 0, Color);
- end;
-
- procedure TViewWindow.CMBasicFont (var Msg: TMessage);
- begin
- (* The new SFXChooseFont function is the easiest way to display a 'Choose Font'
- * common dialog box. Many of the arguments have defaults and may only require
- * a 'nil' or '0' value, depending on your requirements.
- *)
- CFFlags := 0;
- Template := GetSFXTemplateId(ClassName, dlg_Font);
- if SFXChooseFont(HWindow, LogFont, CFFlags, Template, False, FontColor) then
- begin
- EraseObject(Font);
- Font := CreateFontIndirect(LogFont);
- UpdateClientRect;
- end;
- end;
-
- procedure TViewWindow.CMBasicFontExtraFlags (var Msg: TMessage);
- begin
- (* When you specify CF_APPLY or CF_SHOWHELP SFX200.DLL activates the Apply and/or
- * Help buttons for you. You don't have to worry about hooks. When you press the
- * Apply button a WM_SFXAPPLYFONT message is sent to the owner of the font dialog box.
- * wParam contains the handle of the newly created font and lParam contains the
- * selected RGB color value. In reponse to this message you must delete the current font,
- * and replace it with wParam and you must update the color if color is used.
- * Everytime you press the Apply button a new font is created. SFX200.DLL does not
- * delete these fonts, you must do that!
- *
- * When you press the help button a WM_SFXHELP message is sent to the
- * owner of the dialog box. wParam is zero, LOWORD(lParam) contains the window
- * handle of the dialog box sending the message and HIWORD(lParam) contains the
- * dialog-identifier identifying which type of common dialog box template sent
- * the message. eg DLG_FONT or DLG_EXFONT.
- *)
- CFFlags := cf_Effects or cf_Both or cf_Apply or cf_ShowHelp;
- Template := GetSFXTemplateId(ClassName, dlg_Font);
- if SFXChooseFont(HWindow, LogFont, CFFlags, Template, True, FontColor) then
- begin
- EraseObject(Font);
- Font := CreateFontIndirect(LogFont);
- UpdateClientRect;
- end;
- end;
-
- procedure TViewWindow.CMExtendedFont (var Msg: TMessage);
- begin
- CFFlags := 0;
- Template := GetSFXTemplateId(ClassName, dlg_ExFont);
- if SFXChooseFont(HWindow, LogFont, CFFlags, Template, False, FontColor) then
- begin
- EraseObject(Font);
- FontColor := 0;
- Font := CreateFontIndirect(LogFont);
- UpdateClientRect;
- end;
- end;
-
- procedure TViewWindow.CMExtendedFontApply (var Msg: TMessage);
- begin
- CFFlags := cf_Apply;
- Template := GetSFXTemplateId(ClassName, dlg_ExFont);
- if SFXChooseFont(HWindow, LogFont, CFFlags, Template, True, FontColor) then
- begin
- EraseObject(Font);
- FontColor := 0;
- Font := CreateFontIndirect(LogFont);
- UpdateClientRect;
- end;
- end;
-
- procedure TViewWindow.CMExtendedFontHelp (var Msg: TMessage);
- begin
- CFFlags := cf_ShowHelp;
- Template := GetSFXTemplateId(ClassName, dlg_ExFont);
- if SFXChooseFont(HWindow, LogFont, CFFlags, Template, False, FontColor) then
- begin
- EraseObject(Font);
- FontColor := 0;
- Font := CreateFontIndirect(LogFont);
- UpdateClientRect;
- end;
- end;
-
- procedure TViewWindow.CMButton (var Msg: TMessage);
- var
- Dlg : PButtonDialog;
- begin
- Dlg := New(PButtonDialog, Init(@Self, 'ButtonDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMShade (var Msg: TMessage);
- var
- Dlg : PDefaultDialog;
- begin
- Dlg := New(PDefaultDialog, Init(@Self, 'ShadeDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMStatic (var Msg: TMessage);
- var
- Dlg : PStaticDialog;
- begin
- Dlg := New(PStaticDialog, Init(@Self, 'StaticDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMCheck (var Msg: TMessage);
- var
- Dlg : PDefaultDialog;
- begin
- Dlg := New(PDefaultDialog, Init(@Self, 'CheckDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMRadio (var Msg: TMessage);
- var
- Dlg : PDefaultDialog;
- begin
- Dlg := New(PDefaultDialog, Init(@Self, 'RadioDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMControl (var Msg: TMessage);
- var
- Dlg : PControlDialog;
- begin
- Dlg := New(PControlDialog, Init(@Self, 'ControlDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMToolbar (var Msg: TMessage);
- var
- Dlg : PToolbarDialog;
- begin
- Dlg := New(PToolbarDialog, Init(@Self, 'ToolbarDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMMessageBox (var Msg: TMessage);
- var
- Dlg : PMessageBoxDialog;
- begin
- Dlg := New(PMessageBoxDialog, Init(@Self, 'MessageInputDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMWindow (var Msg: TMessage);
- begin
- SFXMsgBox(HWindow, 'To view the various SpecialFX window, edit window, ' +
- 'file window and MDI window objects compile the sample ' +
- 'applications in the examples directory.', 'Information',
- mb_OK or mb_IconInformation, Style);
- end;
-
- procedure TViewWindow.CMTop (var Msg: TMessage);
- begin
- OldToolbarPos := ToolbarPos;
- if ToolbarPos <> cm_Top then
- begin
- (* 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 <> nil) and (Toolbar^.HWindow <> 0) then
- DestroyWindow(Toolbar^.HWindow);
- Toolbar := New(PToolbar, Init(@Self, id_Toolbar, 'Dialog Classes,801,802,803,804',
- 0, 0, True));
- Toolbar^.Attr.Style := Toolbar^.Attr.Style or mtb_Row1 or mtb_Column4 or
- mtb_BitmapButton or mtb_Top or mtb_Radio;
- Application^.MakeWindow(Toolbar);
-
- (* The toolbar is created with the MTB_RADIO flag so its buttons behave as
- * a set of mutually exclusive radio buttons. CheckTool sends a WM_SETCHECK
- * private message (see SFX200 unit) to the toolbar to check the button
- * identified by tool.
- *)
- 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 status bar to the stock FINE_FONT
- * object (= MS San Serif 8).
- *)
- Toolbar^.SetFont(GetSFXObject(Fine_Font));
- end;
- end;
-
- procedure TViewWindow.CMFloat (var Msg: TMessage);
- begin
- OldToolbarPos := ToolbarPos;
- if ToolbarPos <> cm_Float then
- begin
- ToolbarPos := cm_Float;
- if (Toolbar <> nil) and (Toolbar^.HWindow <> 0) then
- DestroyWindow(Toolbar^.HWindow);
- Toolbar := New(PToolbar, Init(@Self, id_Toolbar, 'Dialog Classes,801,802,803,804',
- GetSystemMetrics(SM_CXSCREEN), 0, True));
- Toolbar^.Attr.Style := Toolbar^.Attr.Style or mtb_Row1 or mtb_Column4 or
- mtb_BitmapButton or mtb_Float or mtb_Radio or
- mtb_3DFrame or ws_Caption;
- Application^.MakeWindow(Toolbar);
- Toolbar^.CheckTool(Tool);
- end;
- end;
-
- procedure TViewWindow.CMBottom (var Msg: TMessage);
- begin
- OldToolbarPos := ToolbarPos;
- if ToolbarPos <> cm_Bottom then
- begin
- ToolbarPos := cm_Bottom;
- if (Toolbar <> nil) and (Toolbar^.HWindow <> 0) then
- DestroyWindow(Toolbar^.HWindow);
- Toolbar := New(PToolbar, Init(@Self, id_Toolbar, 'Dialog Classes,801,802,803,804',
- 0, 0, True));
- Toolbar^.Attr.Style := Toolbar^.Attr.Style or mtb_Row1 or mtb_Column4 or
- mtb_BitmapButton or mtb_Bottom or mtb_Radio;
- Application^.MakeWindow(Toolbar);
- Toolbar^.CheckTool(Tool);
- Toolbar^.SetFont(GetSFXObject(Fine_Font));
- end;
- end;
-
- procedure TViewWindow.CMStatus (var Msg: TMessage);
- begin
- OldToolbarPos := ToolbarPos;
- if ToolbarPos <> cm_Status then
- begin
- ToolbarPos := cm_Status;
- if (Toolbar <> nil) and (Toolbar^.HWindow <> 0) then
- DestroyWindow(Toolbar^.HWindow);
- Toolbar := New(PToolbar, Init(@Self, id_Toolbar, 'Dialog Classes,801,802,803,804',
- 0, 0, True));
- Toolbar^.Attr.Style := Toolbar^.Attr.Style or mtb_Row1 or mtb_Column4 or
- mtb_BitmapButton or mtb_Status or mtb_Radio;
- Application^.MakeWindow(Toolbar);
- Toolbar^.CheckTool(Tool);
- Toolbar^.SetFont(GetSFXObject(Fine_Font));
- end;
- end;
-
- procedure TViewWindow.CMHints (var Msg: TMessage);
- begin
- if UseHints then
- Toolbar^.SetText('');
- UseHints := not UseHints;
- end;
-
- procedure TViewWindow.CMAbout (var Msg: TMessage);
- var
- Dlg : PDefaultDialog;
- begin
- Dlg := New(PDefaultDialog, Init(@Self, 'AboutDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TViewWindow.CMExitWindow (var Msg: TMessage);
- begin
- CloseWindow;
- end;
-
- procedure TViewWindow.CMHelp (var Msg: TMessage);
- begin
- WinHelp(HWindow, 'SFX200.HLP', HELP_INDEX, 0);
- end;
-
- {********* TSplashWindow **********}
-
- destructor TSplashWindow.Done;
- begin
- TSFXStatic.Done;
- end;
-
- procedure TSplashWindow.SetupWindow;
- begin
- TSFXStatic.SetupWindow;
- (* Sets a timer to destroy the splash window after 10 seconds
- *)
- SetTimer(HWindow, id_Timer, 10000, nil);
- end;
-
- procedure TSplashWindow.WMGetDlgCode (var Msg: TMessage);
- begin
- Msg.Result := dlgc_WantAllKeys;
- end;
-
- procedure TSplashWindow.WMKeyDown (var Msg: TMessage);
- begin
- if Msg.wParam = vk_Return then
- KillTimer(HWindow, id_Timer);
- CloseWindow;
- end;
-
- procedure TSplashWindow.WMLButtonDown (var Msg: TMessage);
- begin
- KillTimer(HWindow, id_Timer);
- CloseWindow;
- end;
-
- procedure TSplashWindow.WMNCHitTest (var Msg: TMessage);
- begin
- (* SFXStatic controls return HTTRANSPARENT. TSplashWindow overrides this
- * so it can respond to the WM_LBUTTONDOWN message.
- *)
- with Msg do
- DefWindowProc(HWindow, Message, wParam, lParam);
- end;
-
- procedure TSplashWindow.WMTimer (var Msg: TMessage);
- begin
- if Msg.wParam = id_Timer then
- begin
- KillTimer(HWindow, id_Timer);
- CloseWindow;
- end;
- end;
-
- {********** TToolbar **********}
-
- procedure TToolbar.WMCommand (var Msg: TMessage);
- begin
- (* These are the main toolbar buttons clicks. 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
- * save yourself time and effort and 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 within the parent window or dialog.
- *)
- case Msg.wParam of
- id_One:
- begin
- StrCopy(ClassName, 'SFX3DDlg');
- Style := mws_SFXFrame;
- Tool := Msg.wParam;
- end;
-
- id_Two:
- begin
- StrCopy(ClassName, 'SFXGlazeDlg');
- Style := mws_3DGlaze;
- Tool := Msg.wParam;
- end;
-
- id_Three:
- begin
- StrCopy(ClassName, 'SFXGrayDlg');
- Style := mws_3DGray;
- Tool := Msg.wParam;
- end;
-
- id_Four:
- begin
- StrCopy(ClassName, 'SFXSteelDlg');
- Style := mws_3DSteel;
- Tool := Msg.wParam;
- end;
-
- else
- TSFXToolbar.WMCommand(Msg);
- end;
- end;
-
- procedure TToolbar.WMMouseMove (var Msg: TMessage);
- var
- ChildWnd : HWnd;
- ChildID : Integer;
- szTemp : array[0..144] of Char;
- szText : array[0..144] of Char;
- begin
- (* 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.
- *)
- if UseHints then
- begin
- if not PtInClient(HWindow, MakePoint(Msg.lParam)) then
- Exit;
- ChildWnd := ChildWindowFromPoint(HWindow, MakePoint(Msg.lParam));
- GetText(szTemp);
- ChildID := GetDlgCtrlID(ChildWnd);
-
- (* The static control's id is -1.
- *)
- if ChildId <> -1 then
- begin
- szText[0] := #0;
- LoadString(HInstance, ChildID, szText, SizeOf(szText));
- if StrIComp(szText, szTemp) <> 0 then
- SetText(szText);
- end;
- end;
- end;
-
- {********** TMessageBoxDialog **********}
-
- procedure TMessageBoxDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
-
- (* Sets the new SFXCaption style - just for show! Since these dialogs don't have
- * an icon the text in the caption displays flush left.
- *)
- SetWindowLong(HWindow, gwl_Style, GetWindowLong(HWindow, gwl_Style) or mws_SFXCaption);
-
- (* SpecialFX check boxes and radio buttons respond the standard Windows
- * button messages. Here BM_SETCHECK is sent to check the first radiobutton.
- *)
- SendMessage(GetDlgItem(HWindow, id_SFXFrame), bm_SetCheck, bf_Checked, 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;
- end;
-
- procedure TMessageBoxDialog.WMCommand (var Msg: TMessage);
- var
- Reply : Integer;
- szText : array[0..144] of Char;
- begin
- (* These button respones use the SFXInputBox and SFXMsgBox functions to display
- * the 7 Input/Message box styles and the message box button combinations.
- *)
- if Msg.lParamHi = bn_Clicked then
- begin
- szText[0] := #0;
- case Msg.wParam of
- id_SFXFrame: MsgStyle := mws_SFXFrame;
-
- id_Gray: MsgStyle := mws_Gray;
-
- id_Glaze: MsgStyle := mws_Glaze;
-
- id_Steel: MsgStyle := mws_Steel;
-
- id_3DGray: MsgStyle := mws_3DGray;
-
- id_3DGlaze: MsgStyle := mws_3DGlaze;
-
- id_3DSteel: MsgStyle := mws_3DSteel;
-
- id_mbOk:
- begin
- Reply := SFXInputBox(HWindow, 'Password', 'Enter password:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your password is:', mb_OK or mb_IconAsterisk, MsgStyle);
- end;
-
- id_mbOkCancel:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_OKCancel or mb_IconInformation, MsgStyle);
- end;
-
- id_mbAbortRetryIgnore:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_AbortRetryIgnore or mb_IconQuestion, MsgStyle);
- end;
-
- id_mbRetryCancel:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_RetryCancel or mb_IconStop, MsgStyle);
- end;
-
- id_mbYesNo:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_YesNo or mb_IconExclamation, MsgStyle);
- end;
-
- id_mbYesNoCancel:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_YesNoCancel or mb_IconQuestion, MsgStyle);
- end;
-
- id_mbGo:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_Go or mb_IconAsterisk, MsgStyle);
- end;
-
- id_mbGoStop:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_GoStop or mb_IconInformation, MsgStyle);
- end;
-
- id_mbOkCancelHelp:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_OKCancelHelp or mb_IconStop, MsgStyle);
- end;
-
- id_mbYesNoHelp:
- begin
- Reply := SFXInputBox(HWindow, 'Input Box', 'Enter something:', szText,
- SizeOf(szText), MsgStyle);
- if Reply = id_OK then
- SFXMsgBox(HWindow, szText, 'Your entered:',
- mb_YesNoHelp or mb_IconQuestion, MsgStyle);
- end;
-
- id_Help:
- begin
- SFXMsgBox(HWindow, 'You clicked the help button', 'Message Box',
- mb_OK or mb_IconInformation, MsgStyle);
- end;
-
- else
- TDialog.WMCommand(Msg);
- end;
- end
- else
- TDialog.WMCommand(Msg);
- end;
-
- {********** TPopupToolbar **********}
-
- procedure TPopupToolbar.WMCommand (var Msg: TMessage);
- var
- szTemp : array[0..25] of Char;
- begin
- if Msg.lParamHi = bn_Clicked then
- begin
- wvsprintf(szTemp, 'You pressed button %u', Msg.wParam);
- SFXMsgBox(HWindow, szTemp, 'Information', mb_IconInformation, Style);
- end
- else
- TPopupToolbar.WMCommand(Msg);
- end;
-
- procedure TPopupToolbar.WMNCActivate (var Msg: TMessage);
- begin
- Msg.wParam := 1;
- DefWndProc(Msg)
- end;
-
- {********** TToolbarDialog **********}
-
- constructor TToolbarDialog.Init(AParent: PWindowsObject; AName: PChar);
- begin
- TDialog.Init(AParent, AName);
-
- (* 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 should be
- * created with the WS_POPUPWINDOW style, not WS_OVERLAPPED or
- * WS_OVERLAPPEDWINDOW.
- *)
- TB1 := New(PPopupToolbar, Init(@Self, 120, 'Popup Toolbar,304,305,306,307,308,309', 10, 30, False));
- TB1^.Attr.Style := TB1^.Attr.Style or mtb_Row1 or mtb_Column6 or mtb_BitmapButton;
- TB2 := New(PPopupToolbar, Init(@Self, 121, '?,301,302,303,304,305,306', 10, 100, False));
- TB2^.Attr.Style := TB2^.Attr.Style or mtb_Row3 or mtb_Column2 or mtb_BitmapButton;
- TB3 := New(PSFXToolbar, InitResource(@Self, 102));
- end;
-
- procedure TToolbarDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
-
- (* Sets the new SFXCaption style - just for show! Since these dialogs don't have
- * an icon the text in the caption displays flush left.
- *)
- SetWindowLong(HWindow, gwl_Style, GetWindowLong(HWindow, gwl_Style) or mws_SFXCaption);
- TB3^.SetFont(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');
- SendMessage(TB1^.HWindow, wm_NCActivate, 1, 0);
- SendMessage(TB2^.HWindow, wm_NCActivate, 1, 0);
- CenterWindow(0, HWindow);
- end;
-
- procedure TToolbarDialog.WMCommand (var Msg: TMessage);
- var
- szTemp : array[0..25] of Char;
- begin
- if (Msg.wParam > 2) and (Msg.lParamHi = bn_Clicked) then
- begin
- wvsprintf(szTemp, 'You pressed button %u', Msg.wParam);
- SFXMsgBox(HWindow, szTemp, 'Information', mb_IconInformation, Style);
- end
- else
- TDialog.WMCommand(Msg);
- end;
-
- {********** TControlDialog **********}
-
- destructor TControlDialog.Done;
- begin
- KillTimer(HWindow, id_Timer);
- TDialog.Done;
- end;
-
- procedure TControlDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
-
- (* Sets the new SFXCaption style - just for show! Since these dialogs don't have
- * an icon the text in the caption displays flush left.
- *)
- SetWindowLong(HWindow, gwl_Style, GetWindowLong(HWindow, gwl_Style) or mws_SFXCaption);
- CenterWindow(0, HWindow);
-
- (* For display purposes, this timer sets the rate at which the percent
- * gauge is updated.
- *)
- SetTimer(HWindow, id_Timer, 500, nil);
- i := 0;
- end;
-
- procedure TControlDialog.WMSFXCtlColor (var Msg: TMessage);
- begin
- (* 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. 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. Msg.wParam
- * is the display context for the control, Msg.lParamLo is its window handle
- * and Msg.lParamHi is the control identifier. For SFXPercent, this identifier
- * is SFXCTLCOLOR_PERCENT.
- *)
- if Msg.lParamHi = SFXCtlColor_Percent then
- begin
- SetBkMode(Msg.wParam, Transparent);
- if GetDlgCtrlID(Msg.lParamLo) = 109 then
- SetTextColor(Msg.wParam, RGB(0, 0, 255))
- else
- SetTextColor(Msg.wParam, RGB(0, 255, 0));
-
- (* GetSFXObject is defined in the SFX200 unit. Here its used to retrieve
- * a handle for the 'stock' red brush. Do not delete this handle!
- *)
- if GetDlgCtrlID(Msg.lParamLo) = 110 then
- SendMessage(Msg.lParamLo, wm_SetBrush, GetSFXObject(RED_BRUSH), 0);
- end;
- end;
-
- procedure TControlDialog.WMTimer (var Msg: TMessage);
- var
- Reply : Integer;
- begin
- Inc(i);
- if i <= 100 then
- begin
- (* WM_DRAWPERCENT is a private messge that is sent to the percent gauge
- * when you want to update the percent display. Msg.wParam is the percentage
- * to draw and must be a value between 0% and 100%. A value of 100% draws
- * a full percent gauge. Msg.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 the SFX200 unit, you can use its
- * 'SetPercent' and 'Reset' methods instead of sending these messages.
- *)
- Reply := SendMessage(GetDlgItem(HWindow, 109), wm_DrawPercent, i, 0);
- if Reply = 1 then
- begin
- { WM_RESETPERCENT sets the percentage displayed to zero }
- SendMessage(GetDlgItem(HWindow, 109), wm_ResetPercent, 0, 0);
- i := 0;
- end;
- Reply := SendMessage(GetDlgItem(HWindow, 110), wm_DrawPercent, i*2, 0);
- if Reply = 1 then
- SendMessage(GetDlgItem(HWindow, 110), wm_ResetPercent, 0, 0);
- end;
- end;
-
- {********** TStaticDialog **********}
-
- procedure TStaticDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
- SetWindowLong(HWindow, gwl_Style, GetWindowLong(HWindow, gwl_Style) or mws_SFXCaption);
- CenterWindow(0, HWindow);
- end;
-
- procedure TStaticDialog.IDStatBmp (var Msg: TMessage);
- var
- Dlg : PChildDialog;
- begin
- Dlg := New(PChildDialog, Init(@Self, 'BitmapAlignmentDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TStaticDialog.IDStatText (var Msg: TMessage);
- var
- Dlg : PChildDialog;
- begin
- Dlg := New(PChildDialog, Init(@Self, 'TextAlignmentDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- {********** TButtonDialog **********}
-
- procedure TButtonDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
- SetWindowLong(HWindow, gwl_Style, GetWindowLong(HWindow, gwl_Style) or mws_SFXCaption);
- CenterWindow(0, HWindow);
- end;
-
- procedure TButtonDialog.IDStdBtn (var Msg: TMessage);
- var
- Dlg : PChildDialog;
- begin
- Dlg := New(PChildDialog, Init(@Self, 'StandardButtonDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TButtonDialog.IDBitBtn (var Msg: TMessage);
- var
- Dlg : PChildDialog;
- begin
- Dlg := New(PChildDialog, Init(@Self, 'BitmapButtonDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- procedure TButtonDialog.IDTextBtn (var Msg: TMessage);
- var
- Dlg : PChildDialog;
- begin
- Dlg := New(PChildDialog, Init(@Self, 'TextButtonDialog'));
- Application^.ExecDialog(Dlg);
- end;
-
- {********** TChildDialog **********}
-
- procedure TChildDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
- SetWindowLong(HWindow, gwl_Style, GetWindowLong(HWindow, gwl_Style) or 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.
- *)
- ShowWindow(Parent^.HWindow, sw_Hide);
- end;
-
- procedure TChildDialog.OK (var Msg: TMessage);
- begin
- TDialog.OK(Msg);
- ShowWindow(Parent^.HWindow, sw_Normal);
- end;
-
- procedure TChildDialog.Cancel (var Msg: TMessage);
- begin
- TDialog.OK(Msg);
- ShowWindow(Parent^.HWindow, sw_Normal);
- end;
-
- {********** TDefaultDialog **********}
-
- procedure TDefaultDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
- CenterWindow(0, HWindow);
- end;
-
- {********** Main program **********}
-
- var
- App: TViewApp;
- begin
- App.Init(AppName);
- App.Run;
- App.Done;
- end.
-