home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-06 | 34.3 KB | 1,158 lines |
- (*******************************************************************)
- (* *)
- (* Microworks ObjectMate 2.6 *)
- (* *)
- (* Windows Interface Develpment Kit the Borland Languages. *)
- (* *)
- (* SFX200.PAS : SFX Object Unit *)
- (* *)
- (* Copyright 1992-94 Microworks Sydney, Australia. *)
- (* *)
- (*******************************************************************)
-
- unit SFX200;
-
- interface
-
- uses WinTypes, WinProcs, Win31,
- {$IFDEF Ver15}
- WObjects;
- {$ELSE}
- Objects, OWindows, ODialogs;
- {$ENDIF}
-
- const
- { Border styles }
- bd_Recessed = $01;
- bd_Raised = $02;
-
- { Extra combo box style flag that specifies a SpecialFX combo box with no 3D border. }
- cbs_No3DBorder = $8000;
-
- { Extra wm_CtlColor value that identifies a SpecialFX combo box }
- ctlcolor_ComboBox = $0F;
-
- { Common dialog templates }
- dlg_Color = 1;
- dlg_ExColor = 2;
- dlg_OpenSave = 3;
- dlg_ExOpenSave = 4;
- dlg_Print = 5;
- dlg_PrintSetup = 6;
- dlg_Find = 7;
- dlg_Replace = 8;
- dlg_Font = 9;
- dlg_ExFont = 10;
- dlg_OpenDir = 11;
-
- { Old common dialog template ID's for backward compatibility }
- dlg_ChooseColor = 1;
- dlg_ExChooseColor = 2;
-
- { Extends standard button ID's from 7 to 11 }
- idHelp = 8;
- idBrowse = 9;
- idGo = 10;
- idStop = 11;
-
- { Extends standard button ID's from 7 to 11 }
- id_Help = 8;
- id_Browse = 9;
- id_Go = 10;
- id_Stop = 11;
-
- { Turns Edit mode on and off in a list edit box. wParam and lParam must be zero. }
- lb_ListEditOn = wm_User + $1001;
- lb_ListEditOff = wm_User + $1002;
-
- { Extra list box style flags }
- lbs_No3DBorder = $2000; { No 3D Border }
- lbs_SFXListEdit = $4000; { List edit box }
- lbs_SFXMultipleSel = $8000; { Right mouse button only multiple selection list box ]
-
- { Extra message box button combinations }
- mb_Go = $000A;
- mb_GoStop = $000B;
- mb_OkCancelHelp = $000C;
- mb_YesNoHelp = $000D;
-
- { Microworks button style flags }
- mbs_PushButton = bs_PushButton;
- mbs_CheckBox = bs_CheckBox;
- mbs_AutoCheckBox = bs_AutoCheckBox;
- mbs_RadioButton = bs_RadioButton;
- mbs_3State = bs_3State;
- mbs_Auto3State = bs_Auto3State;
- mbs_AutoRadioButton = bs_AutoRadioButton;
- mbs_IconButton = $000E;
- mbs_DefFont = $0010;
- mbs_LeftText = $0020;
- mbs_RaisedText = $0040;
- mbs_RecessedText = $0080;
- mbs_Red = $0100;
- mbs_Lime = $0200;
- mbs_Blue = $0300;
- mbs_Magenta = $0400;
- mbs_Maroon = $0500;
- mbs_Green = $0600;
- mbs_Navy = $0700;
- mbs_Purple = $0800;
- mbs_Yellow = $0900;
- mbs_Flush = $1000;
- mbs_Raised = $1000;
- mbs_Bitmap = $2000;
- mbs_BitmapButton = $4000;
- mbs_TextButton = $8000;
-
- { Microworks percent style flags }
- mps_Top = $0001;
- mps_Bottom = $0002;
- mps_Red = $0010;
- mps_Lime = $0020;
- mps_Blue = $0030;
- mps_Magenta = $0040;
- mps_Maroon = $0050;
- mps_Green = $0060;
- mps_Navy = $0070;
- mps_Purple = $0080;
-
- { Microworks scroll bar style flags }
- msb_Horz = $0000;
- msb_Vert = $0001;
- msb_TopLeft = $0010;
- msb_Bottomright = $0020;
-
- { Microworks shade style flags }
- msh_Left = $0000;
- msh_LtGray = $0000;
- msh_Rect = $0000;
- msh_Frame = $0001;
- msh_VLine = $0002;
- msh_HLine = $0004;
- msh_Recessed = $0008;
- msh_Raised = $0010;
- msh_Borstyle = $0020;
- msh_Center = $0040;
- msh_Right = $0080;
- msh_RecessedText = $0100;
- msh_RaisedText = $0200;
- msh_DefFont = $0400;
- msh_NoPrefix = $0800;
- msh_Steel = $1000;
- msh_Glaze = $2000;
- msh_Red = $3000;
- msh_Lime = $4000;
- msh_Blue = $5000;
- msh_Magenta = $6000;
- msh_Maroon = $7000;
- msh_Green = $8000;
- msh_Navy = $9000;
- msh_Purple = $A000;
- msh_Black = $B000;
- msh_WinColor = $C000;
- msh_Transparent = $D000;
- msh_VHump = msh_VLine + msh_Raised;
- msh_VDip = msh_VLine + msh_Recessed;
- msh_HHump = msh_HLine + msh_Raised;
- msh_HDip = msh_HLine + msh_Recessed;
- msh_RaisedFrame = msh_Raised + msh_Frame;
- msh_RecessedFrame = msh_Recessed + msh_Frame;
-
- { Microworks static style flags }
- mss_Text = $0000;
- mss_Top = $0000;
- mss_Left = $0000;
- mss_RecessedText = $0001;
- mss_RaisedText = $0002;
- mss_ShadowText = $0003;
- mss_Bitmap = $0004;
- mss_BitmapWindow = $0005;
- mss_HCenter = $0010;
- mss_Right = $0020;
- mss_Bottom = $0040;
- mss_VCenter = $0080;
- mss_Recessed = $0100;
- mss_Raised = $0200;
- mss_Frame = $0400;
- mss_WordWrap = $0800;
- mss_SingleLine = $1000;
- mss_NoPrefix = $2000;
- mss_SFXPaint = $2000;
- mss_ExpandTabs = $4000;
- mss_DefFont = $8000;
- mss_Center = mss_VCenter + mss_HCenter;
- mss_CenterBitmap = mss_BitmapWindow + mss_Center;
- mss_RaisedFrame = mss_Raised + mss_Frame;
- mss_RecessedFrame = mss_Recessed + mss_Frame;
-
- { Offset to the static control window handle in an aligned toolbar or status bar }
- mtb_WndStatic = 2;
-
- { Offset to the text string containing the toolbar title and current button ID's }
- mtb_WndText = 4;
-
- { Microworks toolbar style flags }
- mtb_Row1 = $0001;
- mtb_Row2 = $0002;
- mtb_Row3 = $0003;
- mtb_Row4 = $0004;
- mtb_Row5 = $0005;
- mtb_Row6 = $0006;
- mtb_Row7 = $0007;
- mtb_Row8 = $0008;
- mtb_Row9 = $0009;
- mtb_Row10 = $000A;
- mtb_Row11 = $000B;
- mtb_Row12 = $000C;
- mtb_Row13 = $000D;
- mtb_Row14 = $000E;
- mtb_Row15 = $000F;
- mtb_Column1 = $0010;
- mtb_Column2 = $0020;
- mtb_Column3 = $0030;
- mtb_Column4 = $0040;
- mtb_Column5 = $0050;
- mtb_Column6 = $0060;
- mtb_Column7 = $0070;
- mtb_Column8 = $0080;
- mtb_Column9 = $0090;
- mtb_Column10 = $00A0;
- mtb_Column11 = $00B0;
- mtb_Column12 = $00C0;
- mtb_Column13 = $00D0;
- mtb_Column14 = $00E0;
- mtb_Column15 = $00F0;
- mtb_Top = $0100;
- mtb_Left = $0200;
- mtb_Right = $0300;
- mtb_Bottom = $0400;
- mtb_Float = $0500;
- mtb_Status = $0600;
- mtb_3DFrame = $1000;
- mtb_Flush = $2000;
- mtb_Radio = $4000;
- mtb_BitmapButton = $8000;
-
- { Microworks window style flags }
- mws_SFXCaption = $0200;
- mws_FramedClient = $0400;
- mws_RaisedClient = $0800;
- mws_Gray = $0800;
- mws_3DFrame = $1000;
- mws_3DGray = $1000;
- mws_SFXFrame = $2000;
- mws_Glaze = $4000;
- mws_Steel = $8000;
- mws_3DGlaze = mws_Glaze + mws_3DFrame;
- mws_3DSteel = mws_Steel + mws_3DFrame;
- mws_Framed3DFrame = mws_3DFrame + mws_FramedClient;
- mws_Framed3DGlaze = mws_3DGlaze + mws_FramedClient;
- mws_Framed3DSteel = mws_3DSteel + mws_FramedClient;
- mws_Raised3DFrame = mws_3DFrame + mws_RaisedClient;
- mws_Raised3DGlaze = mws_3DGlaze + mws_RaisedClient;
- mws_Raised3DSteel = mws_3DSteel + mws_RaisedClient;
-
- { Old window style flags included for compatiblity }
- mws_Flat3DFrame = mws_3DFrame;
- mws_Flat3DGlaze = mws_3DGlaze;
- mws_Flat3DSteel = mws_3DSteel;
-
- { Hide menu item indentifier on the toolbar system menu }
- sc_Hide = $FF00;
-
- { High order word values of lParam identifying the control sending a wm_SFXCtlColor message }
- sfxctlcolor_Button = $10;
- sfxctlcolor_Check = $11;
- sfxctlcolor_Combo = $12;
- sfxctlcolor_Dlg = $13;
- sfxctlcolor_Radio = $14;
- sfxctlcolor_Shade = $15;
- sfxctlcolor_Static = $16;
- sfxctlcolor_Percent = $17;
-
- { Version number of SFX200.DLL -> 2.6 }
- sfxversion = $0260;
-
- { Undocumented window message posted in a window's message queue when a menu is cancelled.
- If the closing menu is the system menu wParam is 1. Otherwise it's zero. }
- wm_ExitMenuLoop = $0212;
-
- { Extra window messages }
- wm_AlignToolbar = wm_User + $1003;
- wm_DrawPercent = wm_User + $1004;
- wm_GetCheck = wm_User + $1005;
- wm_ResetPercent = wm_User + $1006;
- wm_SetBitmap = wm_User + $1007;
- wm_SetBrush = wm_User + $1008;
- wm_SetCheck = wm_User + $1009;
- wm_SetPen = wm_User + $100A;
- wm_SFXCtlColor = wm_User + $100B;
- wm_SFXApplyColor = wm_User + $100C;
- wm_SFXApplyFONT = wm_User + $100D;
- wm_SFXHelp = wm_User + $100E;
- wm_SFXInitDialog = wm_User + $100F;
-
- { Stock object values used in the GetSFXObject function }
- glaze_brush = 1;
- steel_brush = 2;
- red_brush = 3;
- lime_Brush = 4;
- blue_Brush = 5;
- magenta_Brush = 6;
- maroon_Brush = 7;
- green_Brush = 8;
- navy_Brush = 9;
- purple_brush = 10;
- fine_font = 11;
- bold_font = 12;
- red_pen = 13;
- blue_pen = 14;
- green_pen = 15;
- maroon_pen = 16;
- navy_pen = 17;
- purple_pen = 18;
- yellow_brush = 19;
- System_Fine_Font = 20;
-
- var
- SFXLib : THandle;
- SaveExit : Pointer;
-
- { Functions exported by SFX200.DLL }
- AlignBrush : procedure (Wnd: HWnd; DC: HDC; Brush: HBrush);
-
- BlackFrame : procedure (DC: HDC; X1, Y1, X2, Y2: Integer);
-
- CenterWindow : procedure (ParentWnd, Wnd: HWnd);
-
- ChildToParentRect : function (Wnd: HWnd): PRect;
-
- DrawBorder : procedure (DC: HDC; X, Y, W, H: Integer; Style: Word);
-
- Draw3DBorder : procedure (DC: HDC; X, Y, W, H: Integer; Style: Word);
-
- EraseObject : function (Handle: THandle): Bool;
-
- GetSFXCtrlFont : function (Wnd: HWnd): HFont;
-
- GetSFXInstance : function : THandle;
-
- GetSFXObject : function (Index: Integer): THandle;
-
- GetSFXTemplate : function (Class: PChar; Template: Word): PChar;
-
- GetSFXTemplateId : function (Class: PChar; Template: Word): Integer;
-
- GetSFXVersion : function : Word;
-
- IsNCActive : function (Wnd: HWnd): Bool;
-
- PtInClient : function (Wnd: HWnd; Point: TPoint): Bool;
-
- PtInWindow : function (Wnd: HWnd; Point: TPoint): Bool;
-
- SFXDefDlgProc : function (Dlg: HWnd; Msg, wParam: Word; lParam: Longint): Longint;
-
- SFXDefWindowProc : function (Wnd: HWnd; Msg, wParam: Word; lParam: Longint): Longint;
-
- (* SFXDefFrameProc has changed. It now includes the client window handle as a parameter
- *)
- SFXDefFrameProc : function (Wnd, ClientWnd: HWnd; Msg, wParam: Word; lParam: Longint): Longint;
-
- SFXDefMDIChildProc : function (Wnd: HWnd; Msg, wParam: Word; lParam: Longint): Longint;
-
- SFXDirBox : function (WndParent: HWnd; Caption, Dir: PChar; Flags, Style: Word): Integer;
-
- SFXMsgBox : function (WndParent: HWnd; Txt, Caption: PChar; TextType, Style: Word):Integer;
-
- SFXInputBox : function (WndParent: HWnd; Caption, Prompt, Text: PChar; MaxCount: Integer;
- Style: Word): Integer;
-
- (* New Function: displays a directory selection common dialog box
- *)
- SFXOpenDir : function (WndParent: HWnd; Buffer, Title: PChar; OFNFlags: LongInt;
- Template: Integer; Center: Boolean): BOOL;
-
- (* New Function: displays a 'Open File' common dialog box
- *)
- SFXOpenFile : function (WndParent: HWnd; Buffer, Filters: PChar; OFNFlags: LongInt;
- Template: Integer; Center: Boolean; Title: PChar;
- var FilterIndex: LongInt; DefExt: PChar): BOOL;
-
- (* New Function: displays a 'Save File As' common dialog box
- *)
- SFXSaveFile : function (WndParent: HWnd; Buffer, Filters: PChar; OFNFlags: LongInt;
- Template: Integer; Center: Boolean; Title: PChar;
- var FilterIndex: LongInt; DefExt: PChar): BOOL;
-
- (* New Function: displays a 'Choose Color' common dialog box
- *)
- SFXChooseColor : function (WndParent: HWnd; var RGBColor: LongInt; CCFlags: LongInt;
- Template: Integer; Center: Boolean; CustomColors: PLongInt): BOOL;
-
- (* New Function: displays a 'Choose Font' common dialog box
- *)
- SFXChooseFont : function (WndParent: HWnd; var LogFont: TLogFont; CFFlags: LongInt;
- Template: Integer; Center: Boolean; var RGBColor: LongInt): BOOL;
-
- type
- { ObjectWindows Objects specific to SFX200 }
-
- PSFXButton = ^TSFXButton;
- TSFXButton = object(TButton)
- constructor Init (AParent: PWindowsObject; AnID: Integer; AText: PChar; X, Y, W, H: Integer);
- constructor InitResource (AParent: PWindowsObject; ResourceID: Word);
- function GetClassName: PChar; virtual;
- procedure SetButton (NewID: Integer);
- procedure SetIcon (NewIcon: HIcon);
- procedure SetText (ATextString: PChar);
- end;
-
- PSFXStatic = ^TSFXStatic;
- TSFXStatic = object(TStatic)
- function GetClassName: PChar; virtual;
- end;
-
- PSFXShade = ^TSFXShade;
- TSFXShade = object(TGroupBox)
- constructor Init(AParent: PWindowsObject; AnID: Integer; AText: PChar; X, Y, W, H: Integer);
- constructor InitResource (AParent: PWindowsObject; ResourceID: Word);
- function GetClassName: PChar; virtual;
- end;
-
- PSFXCheckBox = ^TSFXCheckBox;
- TSFXCheckBox = object(TCheckBox)
- function GetClassName: PChar; virtual;
- end;
-
- PSFXRadioButton = ^TSFXRadioButton;
- TSFXRadioButton = object(TRadioButton)
- function GetClassName: PChar; virtual;
- end;
-
- PSFXScrollBar = ^TSFXScrollBar;
- TSFXScrollBar = object(TScrollBar)
- function GetClassName: PChar; virtual;
- end;
-
- PSFXEdit = ^TSFXEdit;
- TSFXEdit = object(TEdit)
- function GetClassName: PChar; virtual;
- end;
-
- PSFXListBox = ^TSFXListBox;
- TSFXListBox = object(TListBox)
- function GetClassName: PChar; virtual;
- end;
-
- PSFXComboBox = ^TSFXComboBox;
- TSFXComboBox = object(TComboBox)
- function GetClassName: PChar; virtual;
- end;
-
- PSFXToolbar = ^TSFXToolbar;
- TSFXToolbar = object(TWindow)
- (* SetFont, SetText and SetTool are new. SetFont and SetText and are used
- * only for status bars.
- *)
- constructor Init (AParent: PWindowsObject; AnID: Integer; ATitle: PChar;
- X, Y: Integer; IsChild: Boolean);
- constructor InitResource (AParent: PWindowsObject; ResourceID: Word);
- function GetClassName: PChar; virtual;
- function Register: Boolean; virtual;
- procedure WMPaint (var Msg: TMessage); virtual wm_First + wm_Paint;
- procedure GetTitle (ATextString: PChar);
- procedure AlignToolbar;
- function GetCheck (ToolID: Integer): Word;
- procedure CheckTool (ToolID: Integer);
- procedure UncheckTool (ToolID: Integer);
- function IsToolEnabled(ToolID: Integer): BOOL;
- procedure EnableTool(ToolID: Integer; Enabled: BOOL);
- procedure GetText (ATextString: PChar);
- procedure SetText (ATextString: PChar);
- procedure SetFont (Font: HFont);
- procedure SetTool (NewID, ToolID: Integer);
- function StatusWindow: HWnd;
- end;
-
- PSFXPercent = ^TSFXPercent;
- TSFXPercent = object(TControl)
- constructor Init (AParent: PWindowsObject; AnID: Integer; X, Y, W, H: Integer);
- constructor InitResource (AParent: PWindowsObject; ResourceID: Word);
- function GetClassName: PChar; virtual;
- function SetPercent (Percent: Word): LongInt;
- procedure Reset;
- end;
-
- PSFXDivider = ^TSFXDivider;
- TSFXDivider = object(TControl)
- constructor Init (AParent: PWindowsObject; AnID, X, Y, Length: Integer;
- IsVertical, IsHump, Borstyle: Boolean);
- constructor InitResource (AParent: PWindowsObject; ResourceID: Word);
- function GetClassName: PChar; virtual;
- end;
-
- PSFXBitmap = ^TSFXBitmap;
- TSFXBitmap = object(TControl)
- constructor Init (AParent: PWindowsObject; AnID: Integer; X, Y: Integer);
- constructor InitResource (AParent: PWindowsObject; ResourceID: Word);
- function GetClassName: PChar; virtual;
- end;
-
- PSFXWindow = ^TSFXWindow;
- TSFXWindow = object(TWindow)
- constructor Init (AParent: PWindowsObject; AName: PChar);
- constructor Load (var S: TStream);
- procedure Store (var S: TStream);
- end;
-
- PSFXMDIClient = ^TSFXMDIClient;
- TSFXMDIClient = object(TMDIClient)
- constructor Init(AParent: PMDIWindow; SFXClient: Boolean);
- function GetClassName: PChar; virtual;
- private
- IsSFXClient : Boolean;
- end;
-
- PSFXMDIWindow = ^TSFXMDIWindow;
- TSFXMDIWindow = object(TMDIWindow)
- constructor Init(ATitle: PChar; AMenu: HMenu);
- procedure GetWindowClass (var AWndClass: TWndClass); virtual;
- procedure InitClientWindow; virtual;
- procedure DefWndProc (var Msg: TMessage); virtual;
- end;
-
- function SFXDefMsgBox (WndParent: HWnd; Txt, Caption: PChar; TextType: Word): Integer;
-
- procedure RegisterSFX200;
-
- procedure UnitExit;
-
- const
- { Stream registration records }
- RSFXButton : TStreamRec = (
- ObjType : 15201;
- VmtLink : Ofs(TypeOf(TSFXButton)^);
- Load : @TSFXButton.Load;
- Store : @TSFXButton.Store);
-
- RSFXStatic : TStreamRec = (
- ObjType : 15202;
- VmtLink : Ofs(TypeOf(TSFXStatic)^);
- Load : @TSFXStatic.Load;
- Store : @TSFXStatic.Store);
-
- RSFXShade : TStreamRec = (
- ObjType : 15203;
- VmtLink : Ofs(TypeOf(TSFXShade)^);
- Load : @TSFXShade.Load;
- Store : @TSFXShade.Store);
-
- RSFXCheckBox : TStreamRec = (
- ObjType : 15204;
- VmtLink : Ofs(TypeOf(TSFXCheckBox)^);
- Load : @TSFXCheckBox.Load;
- Store : @TSFXCheckBox.Store);
-
- RSFXRadioButton : TStreamRec = (
- ObjType : 15205;
- VmtLink : Ofs(TypeOf(TSFXRadioButton)^);
- Load : @TSFXRadioButton.Load;
- Store : @TSFXRadioButton.Store);
-
- RSFXScrollBar : TStreamRec = (
- ObjType : 15206;
- VmtLink : Ofs(TypeOf(TSFXScrollBar)^);
- Load : @TSFXScrollBar.Load;
- Store : @TSFXScrollBar.Store);
-
- RSFXEdit : TStreamRec = (
- ObjType : 15207;
- VmtLink : Ofs(TypeOf(TSFXEdit)^);
- Load : @TSFXEdit.Load;
- Store : @TSFXEdit.Store);
-
- RSFXListBox : TStreamRec = (
- ObjType : 15208;
- VmtLink : Ofs(TypeOf(TSFXListBox)^);
- Load : @TSFXListBox.Load;
- Store : @TSFXListBox.Store);
-
- RSFXComboBox : TStreamRec = (
- ObjType : 15209;
- VmtLink : Ofs(TypeOf(TSFXComboBox)^);
- Load : @TSFXComboBox.Load;
- Store : @TSFXComboBox.Store);
-
- RSFXMDIClient : TStreamRec = (
- ObjType : 15210;
- VmtLink : Ofs(TypeOf(TSFXMDIClient)^);
- Load : @TSFXMDIClient.Load;
- Store : @TSFXMDIClient.Store);
-
- RSFXToolbar : TStreamRec = (
- ObjType : 15211;
- VmtLink : Ofs(TypeOf(TSFXToolbar)^);
- Load : @TSFXToolbar.Load;
- Store : @TSFXToolbar.Store);
-
- RSFXPercent : TStreamRec = (
- ObjType : 15212;
- VmtLink : Ofs(TypeOf(TSFXPercent)^);
- Load : @TSFXPercent.Load;
- Store : @TSFXPercent.Store);
-
- RSFXDivider : TStreamRec = (
- ObjType : 15213;
- VmtLink : Ofs(TypeOf(TSFXDivider)^);
- Load : @TSFXDivider.Load;
- Store : @TSFXDivider.Store);
-
- RSFXBitmap : TStreamRec = (
- ObjType : 15214;
- VmtLink : Ofs(TypeOf(TSFXBitmap)^);
- Load : @TSFXBitmap.Load;
- Store : @TSFXBitmap.Store);
-
- RSFXWindow : TStreamRec = (
- ObjType : 15215;
- VmtLink : Ofs(TypeOf(TSFXWindow)^);
- Load : @TSFXWindow.Load;
- Store : @TSFXWindow.Store);
-
- RSFXMDIWindow : TStreamRec = (
- ObjType : 15218;
- VmtLink : Ofs(TypeOf(TSFXMDIWindow)^);
- Load : @TSFXMDIWindow.Load;
- Store : @TSFXMDIWindow.Store);
-
- implementation
-
- {********** TSFXButton **********}
-
- constructor TSFXButton.Init (AParent: PWindowsObject; AnID: Integer; AText: PChar;
- X, Y, W, H: Integer);
- begin
- TButton.Init(AParent, AnID, AText, X, Y, W, H, False);
- end;
-
- constructor TSFXButton.InitResource (AParent: PWindowsObject; ResourceID: Word);
- begin
- TButton.InitResource(AParent, ResourceID);
- end;
-
- function TSFXButton.GetClassName: PChar;
- begin
- GetClassName := 'SFXButton';
- end;
-
- procedure TSFXButton.SetButton (NewID: Integer);
- begin
- (* Sets the button id to AnID and changes the button's bitmaps, if any?
- *)
- SendMessage(HWindow, wm_SetBitmap, NewID, 0);
- end;
-
- procedure TSFXButton.SetIcon (NewIcon: HIcon);
- var
- lStyle : LongInt;
- begin
- (* If the button is an icon button (MBS_ICONBUTTON style), SetIcon changes
- * the icon displayed by the button to NewIcon. SFX200.DLL doesn't delete
- * the icon handle, that's your responsibilty.
- *)
- lStyle := GetWindowLong(HWindow, GWL_STYLE);
- if lStyle and $F = mbs_IconButton then
- SendMessage(HWindow, wm_SetBitmap, NewIcon, 0);
- end;
-
- procedure TSFXButton.SetText (ATextString: PChar);
- begin
- (* Sets a text button's text to ATextString.
- *)
- SetWindowText(HWindow, ATextString);
- end;
-
- {********** TSFXStatic **********}
-
- function TSFXStatic.GetClassName: PChar;
- begin
- GetClassName := 'SFXStatic';
- end;
-
- {********** TSFXShade **********}
-
- constructor TSFXShade.Init(AParent: PWindowsObject; AnID: Integer;
- AText: PChar; X, Y, W, H: Integer);
- begin
- (* DO NOT set the bs_GroupBox style flag, TSFXShade doesn't use it!
- *)
- TGroupBox.Init(AParent, AnId, AText, X, Y, W, H);
- Attr.Style := ws_Child or ws_Visible or ws_ClipSiblings;
- end;
-
- constructor TSFXShade.InitResource (AParent: PWindowsObject; ResourceID: Word);
- begin
- TGroupBox.InitResource(AParent, ResourceID);
- end;
-
- function TSFXShade.GetClassName: PChar;
- begin
- GetClassName := 'SFXShade';
- end;
-
- {********** TSFXCheckBox **********}
-
- function TSFXCheckBox.GetClassName: PChar;
- begin
- GetClassName := 'SFXCheck';
- end;
-
- {********** TSFXRadioButton **********}
-
- function TSFXRadioButton.GetClassName: PChar;
- begin
- GetClassName := 'SFXRadio';
- end;
-
- {********** TSFXScrollBar **********}
-
- function TSFXScrollBar.GetClassName: PChar;
- begin
- GetClassName := 'SFXScrollBar';
- end;
-
- {********** TSFXEdit **********}
-
- function TSFXEdit.GetClassName: PChar;
- begin
- GetClassName := 'SFXEdit';
- end;
-
- {********** TSFXListBox **********}
-
- function TSFXListBox.GetClassName: PChar;
- begin
- GetClassName := 'SFXListBox';
- end;
-
- {********** TSFXComboBox **********}
-
- function TSFXComboBox.GetClassName: PChar;
- begin
- GetClassName := 'SFXComboBox';
- end;
-
- {********** TSFXToolbar **********}
-
- constructor TSFXToolbar.Init (AParent: PWindowsObject; AnID: Integer; ATitle: PChar;
- X, Y: Integer; IsChild: Boolean);
- begin
- TWindow.Init(AParent, ATitle);
- SetFlags(wb_MDIChild, False);
- if IsChild then
- begin
- Attr.Style := ws_Child or ws_Visible or ws_Group or ws_Tabstop;
- Attr.ID := AnID;
- end
- else
- Attr.Style := ws_PopupWindow or ws_Caption or ws_Visible or mtb_3DFrame;
- Attr.X := X;
- Attr.Y := Y;
- end;
-
- constructor TSFXToolbar.InitResource (AParent: PWindowsObject; ResourceID: Word);
- begin
- TWindow.InitResource(AParent, ResourceID);
- end;
-
- function TSFXToolbar.Register: Boolean;
- begin
- Register := True;
- end;
-
- function TSFXToolbar.GetClassName: PChar;
- begin
- GetClassName := 'SFXToolbar';
- end;
-
- procedure TSFXToolbar.WMPaint (var Msg: TMessage);
- begin
- DefWndProc(Msg);
- end;
-
- procedure TSFXToolbar.GetTitle (ATextString: PChar);
- var
- HText : THandle;
- PText : PChar;
- begin
- (* GetTitle retrieves the full title text that was used to create the toolbar.
- *)
- HText := GetWindowWord(HWindow, 4);
- if HText <> 0 then
- begin
- PText := GlobalLock(HText);
- lstrcpyn(ATextString, PText, lstrlen(PText) + 1);
- GlobalUnlock(HText);
- end;
- end;
-
- procedure TSFXToolbar.AlignToolbar;
- begin
- (* Realigns a top, left, right or bottom aligned toolbar and status bar. You
- * should add AlignToolbar to your window's WM_SIZE method so that the toolbar
- * (or status bar) is properly realigned when ever the window is resized.
- *)
- SendMessage(HWindow, wm_AlignToolbar, 0, 0);
- end;
-
- function TSFXToolbar.GetCheck (ToolID: Integer): Word;
- begin
- (* GetCheck returns the check state (bf_Checked or bf_Unchecked) of the
- * radiobutton-style toolbar button identified by ToolID.
- *)
- GetCheck := SendMessage(HWindow, wm_GetCheck, ToolID, 0);
- end;
-
- procedure TSFXToolbar.CheckTool (ToolID: Integer);
- begin
- (* CheckTool checks the toolbar button identified by ToolID. All other
- * toolbar buttons are unchecked.
- *)
- SendMessage(HWindow, wm_SetCheck, ToolID, 1);
- end;
-
- procedure TSFXToolbar.UncheckTool (ToolID: Integer);
- begin
- (* UncheckTool unchecks the toolbar button identifed by ToolID.
- *)
- SendMessage(HWindow, wm_SetCheck, ToolID, 0);
- end;
-
- function TSFXToolbar.IsToolEnabled (ToolID: Integer): BOOL;
- begin
- (* IsToolEnabled returns TRUE if the toolbar button identifed by ToolID
- * is enabled. Otherwise it returns FALSE.
- *)
- IsToolEnabled := IsWindowEnabled(GetDlgItem(HWindow, ToolID));
- end;
-
- procedure TSFXToolbar.EnableTool (ToolID: Integer; Enabled: BOOL);
- begin
- (* EnableTool enables/disables the toolbar button identfied by ToolID.
- * If Enabled is TRUE ToolID is enabled. If its FALSE its disabled.
- *)
- if (Enabled and not IsToolEnabled(ToolID)) then
- begin
- EnableWindow(GetDlgItem(HWindow, ToolID), True);
- InvalidateRect(GetDlgItem(HWindow, ToolID), nil, True);
- end
- else
- if (IsToolEnabled(ToolID) and not Enabled) then
- begin
- EnableWindow(GetDlgItem(HWindow, ToolID), False);
- InvalidateRect(GetDlgItem(HWindow, ToolID), nil, True);
- end
- end;
-
- procedure TSFXToolbar.GetText (ATextString: PChar);
- begin
- (* GetText retrieves the text displayed in a toolbar/statusbar.
- *)
- GetWindowText(StatusWindow, ATextString, SizeOf(ATextString));
- end;
-
- procedure TSFXToolbar.SetText (ATextString: PChar);
- begin
- (* SetText sets the text in a toolbar/statusbar.
- *)
- if (Attr.Style and $F00 <> mtb_Left) and (Attr.Style and $F00 <> mtb_Right) and
- (Attr.Style and $F00 <> mtb_Float) then
- SetWindowText(StatusWindow, ATextString);
- end;
-
- procedure TSFXToolbar.SetFont (Font: HFont);
- begin
- (* SetFont sets the toolbar/statusbar font to 'Font'.
- *)
- SendMessage(StatusWindow, wm_SetFont, Font, 1);
- end;
-
- procedure TSFXToolbar.SetTool (NewID, ToolID: Integer);
- begin
- (* SetTool changes a toolbar button's ID and bitmaps. AnID is the new button ID
- and ToolID is the current button ID. Resource bitmaps must be specified
- for AnID.
- *)
- SendMessage(HWindow, wm_SetBitmap, NewID, ToolID);
- end;
-
- function TSFXToolbar.StatusWindow: HWnd;
- begin
- (* StatusWindow returns a handle to the toolbar/statusbar static control.
- *)
- StatusWindow := GetWindowWord(HWindow, mtb_WndStatic);
- end;
-
- {********** TSFXPercent **********}
-
- constructor TSFXPercent.Init (AParent: PWindowsObject; AnID: Integer; X, Y, W, H: Integer);
- begin
- TControl.Init(AParent, AnID, nil, X, Y, W, H);
- DisableTransfer;
- end;
-
- constructor TSFXPercent.InitResource (AParent: PWindowsObject; ResourceID: Word);
- begin
- TControl.InitResource(AParent, ResourceID);
- DisableTransfer;
- end;
-
- function TSFXPercent.GetClassName: PChar;
- begin
- GetClassName := 'SFXPercent';
- end;
-
- function TSFXPercent.SetPercent (Percent: Word): LongInt;
- begin
- (* SetPercent sets the percentage drawn to 'Percent'. Percent must be in
- * the range 0 to 100%. When then percentage drawn reaches 100% the return
- * value is 1. Otherwise the return value is zero.
- *)
- SetPercent := SendMessage(HWindow, wm_DrawPercent, Percent, 0);
- end;
-
- procedure TSFXPercent.Reset;
- begin
- (* Reset resets the percentage drawn to zero.
- *)
- SendMessage(HWindow, wm_ResetPercent, 0, 0);
- end;
-
- {********** TSFXDivider **********}
-
- constructor TSFXDivider.Init (AParent: PWindowsObject; AnID, X, Y, Length: Integer;
- IsVertical, IsHump, Borstyle: Boolean);
- begin
- TControl.Init(AParent, AnID, nil, X, Y, 0, 0);
- DisableTransfer;
- Attr.Style := Attr.Style and (not ws_Tabstop);
- if IsVertical then
- begin
- if IsHump then
- Attr.Style := Attr.Style or msh_VHump
- else
- Attr.Style := Attr.Style or msh_VDip;
- Attr.H := Length;
- end
- else
- begin
- if IsHump then
- Attr.Style := Attr.Style or msh_HHump
- else
- Attr.Style := Attr.Style or msh_HDip;
- Attr.W := Length;
- end;
- if Borstyle then
- Attr.Style := Attr.Style or msh_BorStyle;
- end;
-
- constructor TSFXDivider.InitResource (AParent: PWindowsObject; ResourceID: Word);
- begin
- TControl.InitResource(AParent, ResourceID);
- DisableTransfer;
- end;
-
- function TSFXDivider.GetClassName: PChar;
- begin
- GetClassName := 'SFXShade';
- end;
-
- {********** TSFXBitmap **********}
-
- constructor TSFXBitmap.Init (AParent: PWindowsObject; AnId: Integer; X, Y: Integer);
- begin
- TControl.Init(AParent, AnId, nil, X, Y, 0, 0);
- Attr.Style := (Attr.Style or mbs_Bitmap) and (not ws_Tabstop);
- DisableTransfer;
- end;
-
- constructor TSFXBitmap.InitResource (AParent: PWindowsObject; ResourceID: Word);
- begin
- TControl.InitResource(AParent, ResourceID);
- DisableTransfer;
- end;
-
- function TSFXBitmap.GetClassName: PChar;
- begin
- GetClassName := 'SFXButton';
- end;
-
- {********** TSFXWindow **********}
-
- constructor TSFXWindow.Init (AParent: PWindowsObject; AName: PChar);
- begin
- TWindow.Init(AParent, AName);
- if IsFlagSet(wb_MDIChild) then
- DefaultProc := @SFXDefMDIChildProc
- else
- DefaultProc := @SFXDefWindowProc;
- end;
-
- constructor TSFXWindow.Load(var S: TStream);
- begin
- TWindow.Load(S);
- S.Read(DefaultProc, SizeOf(DefaultProc));
- end;
-
- procedure TSFXWindow.Store(var S: TStream);
- begin
- TWindow.Store(S);
- S.Write(DefaultProc, SizeOf(DefaultProc));
- end;
-
- {********** TSFXMDIClient **********}
-
- constructor TSFXMDIClient.Init(AParent: PMDIWindow; SFXClient: Boolean);
- begin
- TMDIClient.Init(AParent);
- if SFXClient then
- IsSFXClient := True
- else
- IsSFXClient := False;
- end;
-
- function TSFXMDIClient.GetClassName: PChar;
- begin
- if IsSFXClient then
- GetClassName := 'SFXMDIClient'
- else
- GetClassName := 'SFX3DMDIClient'
- end;
-
- {********** TSFXMDIWindow **********}
-
- constructor TSFXMDIWindow.Init(ATitle: PChar; AMenu: HMenu);
- begin
- TMDIWindow.Init(ATitle, AMenu);
- with Attr do
- Style := Style or mws_3DFrame;
- end;
-
- procedure TSFXMDIWindow.GetWindowClass (var AWndClass: TWndClass);
- begin
- TMDIWindow.GetWindowClass(AWndClass);
- AWndClass.hbrBackground := 0;
- end;
-
- procedure TSFXMDIWindow.InitClientWindow;
- begin
- ClientWnd := New(PSFXMDIClient, Init(@Self, False));
- end;
-
- procedure TSFXMDIWindow.DefWndProc (var Msg: TMessage);
- begin
- with Msg do
- Result := SFXDefFrameProc(HWindow, ClientWnd^.HWindow, Message, wParam, lParam);
- end;
-
- {********** SFXDefMsgBox **********}
-
- function SFXDefMsgBox (WndParent: HWnd; Txt, Caption: PChar; TextType: Word): Integer;
- begin
- (* SFXDefMsgBox is used to substitute an SFX style message box for the Windows API
- * MessageBox. The SFXMsgBox function can't be used directly because it takes an
- * extra argument. You can change the default message box by changing the
- * SFXMsgBox's wStyle argument.
- *)
- SFXDefMsgBox := SFXMsgBox(WndParent, Txt, Caption, TextType, MWS_SFXFRAME);
- end;
-
- {********** RegisterSFX200 **********}
-
- procedure RegisterSFX200;
- begin
- RegisterType(RSFXButton);
- RegisterType(RSFXStatic);
- RegisterType(RSFXShade);
- RegisterType(RSFXCheckBox);
- RegisterType(RSFXRadioButton);
- RegisterType(RSFXScrollBar);
- RegisterType(RSFXEdit);
- RegisterType(RSFXListBox);
- RegisterType(RSFXComboBox);
- RegisterType(RSFXMDIClient);
- RegisterType(RSFXToolbar);
- RegisterType(RSFXPercent);
- RegisterType(RSFXDivider);
- RegisterType(RSFXBitmap);
- RegisterType(RSFXWindow);
- RegisterType(RSFXMDIWindow);
- end;
-
- {********** Unit Exit Procedure **********}
-
- procedure UnitExit;
- begin
- FreeLibrary(SFXLib);
- ExitProc := SaveExit;
- end;
-
- begin
- { This unit automatically loads and unloads SFX200.DLL }
- SetErrorMode(SEM_NoOpenFileErrorBox);
- SFXLib := LoadLibrary('SFX200.DLL');
- if SFXLib < HINSTANCE_ERROR then
- begin
- MessageBox(0, 'SFX200.dll could not be found! This application requires SFX200.dll ' +
- 'to be in your Windows system subdirectory.',
- 'Unable to load application', mb_Ok or mb_IconStop);
- Halt(1);
- end
- else
- begin
- @AlignBrush := GetProcAddress(SFXLib, PChar(7));
- @BlackFrame := GetProcAddress(SFXLib, PChar(8));
- @CenterWindow := GetProcAddress(SFXLib, PChar(9));
- @ChildToParentRect := GetProcAddress(SFXLib, PChar(10));
- @DrawBorder := GetProcAddress(SFXLib, PChar(11));
- @Draw3DBorder := GetProcAddress(SFXLib, PChar(12));
- @EraseObject := GetProcAddress(SFXLib, PChar(13));
- @GetSFXInstance := GetProcAddress(SFXLib, PChar(14));
- @GetSFXObject := GetProcAddress(SFXLib, PChar(15));
- @GetSFXTemplate := GetProcAddress(SFXLib, PChar(16));
- @GetSFXTemplateId := GetProcAddress(SFXLib, PChar(17));
- @GetSFXVersion := GetProcAddress(SFXLib, PChar(18));
- @IsNCActive := GetProcAddress(SFXLib, PChar(19));
- @PtInClient := GetProcAddress(SFXLib, PChar(20));
- @PtInWindow := GetProcAddress(SFXLib, PChar(21));
- @SFXDirBox := GetProcAddress(SFXLib, PChar(22));
- @SFXOpenDir := GetProcAddress(SFXLib, PChar(23));
- @SFXOpenFile := GetProcAddress(SFXLib, PChar(24));
- @SFXSaveFile := GetProcAddress(SFXLib, PChar(25));
- @SFXChooseColor := GetProcAddress(SFXLib, PChar(26));
- @SFXChooseFont := GetProcAddress(SFXLib, PChar(27));
- @GetSFXCtrlFont := GetProcAddress(SFXLib, PChar(28));
- @SFXDefWindowProc := GetProcAddress(SFXLib, PChar(1));
- @SFXDefDlgProc := GetProcAddress(SFXLib, PChar(2));
- @SFXDefFrameProc := GetProcAddress(SFXLib, PChar(3));
- @SFXDefMDIChildProc := GetProcAddress(SFXLib, PChar(4));
- @SFXMsgBox := GetProcAddress(SFXLib, PChar(5));
- @SFXInputBox := GetProcAddress(SFXLib, PChar(6));
- RegisterSFX200;
-
- (* Substitutes DefDlgProc with SFXDefDlgProc and MessageBox with SFXDefMsgBox.
- * SFXDefDlgProc becomes the default dialog procedure. Any calls to the API
- * MessageBox function displays the SFX style message box declared in SFXDefMsgBox.
- *)
- {$IFDEF Ver15}
- WObjects.DefDlgProc := SFXDefDlgProc;
- WObjects.MessageBox := SFXDefMsgBox;
- {$ELSE}
- OWindows.DefDlgProc := SFXDefDlgProc;
- OWindows.MessageBox := SFXDefMsgBox;
- {$ENDIF}
- ExitProc := @UnitExit;
- end;
- end.
-