home *** CD-ROM | disk | FTP | other *** search
- {*******************************************************}
- { }
- { Delphi Visual Component Library }
- { }
- { Copyright (c) 1995 Borland International }
- { }
- {*******************************************************}
-
- unit Dialogs;
-
- {$S-,W-,R-}
- {$C PRELOAD}
-
- interface
-
- uses WinTypes, SysUtils, CommDlg, Messages, Classes, Graphics, Controls,
- Buttons, StdCtrls, ExtCtrls, Forms;
-
- type
- TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom);
- TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore,
- mbAll, mbHelp);
- TMsgDlgButtons = set of TMsgDlgBtn;
-
- const
- mbYesNoCancel = [mbYes, mbNo, mbCancel];
- mbOKCancel = [mbOK, mbCancel];
- mbAbortRetryIgnore = [mbAbort, mbRetry, mbIgnore];
-
- type
- TCommonDialog = class(TComponent)
- protected
- function Message(var Msg: TMessage): Boolean; virtual; {$IFNDEF WIN32} export; {$ENDIF}
- public
- constructor Create(AOwner: TComponent); override;
- published
- property Ctl3D: Boolean default True;
- property HelpContext: THelpContext default 0;
- end;
-
- TOpenOption = (ofReadOnly, ofOverwritePrompt, ofHideReadOnly,
- ofNoChangeDir, ofShowHelp, ofNoValidate, ofAllowMultiSelect,
- ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofCreatePrompt,
- ofShareAware, ofNoReadOnlyReturn, ofNoTestFileCreate);
- TOpenOptions = set of TOpenOption;
-
- TFileExt = string[3];
-
- TFileEditStyle = (fsEdit, fsComboBox);
-
- TOpenDialog = class;
- TComboButton = class;
-
- TComboButton = class(TObject)
- end;
-
- TOpenDialog = class(TCommonDialog)
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean; virtual;
- property Files: TStrings;
- published
- property DefaultExt: TFileExt;
- property FileEditStyle: TFileEditStyle default fsEdit;
- property FileName: TFileName;
- property Filter: string;
- property FilterIndex: Integer default 1;
- property InitialDir: string;
- property HistoryList: TStrings;
- property Options: TOpenOptions default [];
- property Title: string;
- end;
-
- TSaveDialog = class(TOpenDialog)
- function Execute: Boolean; override;
- end;
-
- TColorDialogOption = (cdFullOpen, cdPreventFullOpen, cdShowHelp);
- TColorDialogOptions = set of TColorDialogOption;
-
- const
- MaxCustomColors = 16;
-
- type
-
- TCustomColors = array[0..MaxCustomColors - 1] of LongInt;
-
- TColorDialog = class(TCommonDialog)
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property Color: TColor default clBlack;
- property Ctl3D default False;
- property CustomColors: TStrings;
- property Options: TColorDialogOptions default [];
- end;
-
- TFontDialogOption = (fdAnsiOnly, fdTrueTypeOnly, fdEffects, fdFixedPitchOnly,
- fdForceFontExist, fdNoFaceSel, fdNoOEMFonts, fdNoSimulations, fdNoSizeSel,
- fdNoStyleSel, fdNoVectorFonts, fdShowHelp, fdWysiwyg, fdLimitSize,
- fdScalableOnly);
- TFontDialogOptions = set of TFontDialogOption;
-
- TFontDialogDevice = (fdScreen, fdPrinter, fdBoth);
-
- TFDApplyEvent = procedure(Sender: TObject; Wnd: HWND) of object;
-
- TFontDialog = class(TCommonDialog)
- protected
- procedure Apply(Wnd: HWND); dynamic;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property Font: TFont;
- property Device: TFontDialogDevice default fdScreen;
- property MinFontSize: Integer;
- property MaxFontSize: Integer;
- property Options: TFontDialogOptions default [fdEffects];
- property OnApply: TFDApplyEvent;
- end;
-
- TPrinterSetupDialog = class(TCommonDialog)
- public
- procedure Execute;
- end;
-
- TPrintRange = (prAllPages, prSelection, prPageNums);
- TPrintDialogOption = (poPrintToFile, poPageNums, poSelection, poWarning,
- poHelp, poDisablePrintToFile);
- TPrintDialogOptions = set of TPrintDialogOption;
-
- TPrintDialog = class(TPrinterSetupDialog)
- public
- function Execute: Boolean;
- published
- property Collate: Boolean default False;
- property Copies: Integer default 0;
- property FromPage: Integer default 0;
- property MinPage: Integer default 0;
- property MaxPage: Integer default 0;
- property Options: TPrintDialogOptions default [];
- property PrintToFile: Boolean default False;
- property PrintRange: TPrintRange default prAllPages;
- property ToPage: Integer default 0;
- end;
-
- TFindOption = (frDown, frFindNext, frHideMatchCase, frHideWholeWord,
- frHideUpDown, frMatchCase, frDisableMatchCase, frDisableUpDown,
- frDisableWholeWord, frReplace, frReplaceAll, frWholeWord, frShowHelp);
- TFindOptions = set of TFindOption;
-
- TFindDialog = class(TCommonDialog)
- protected
- procedure ConvertFields; virtual;
- procedure ConvertFieldsForCallBack; virtual;
- function GetLeft: Integer;
- function GetTop: Integer;
- procedure SetLeft(Value: Integer);
- procedure SetTop(Value: Integer);
- function GetPosition: TPoint;
- procedure SetPosition(const Point: TPoint);
- function Message(var Msg: TMessage): Boolean; override;
- procedure Find; dynamic;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean; virtual;
- procedure CloseDialog;
- property Position: TPoint;
- property Handle: HWnd;
- property Left: Integer default -1;
- property Top: Integer default -1;
- published
- property FindText: string;
- property Options: TFindOptions default [frDown];
- property OnFind: TNotifyEvent;
- end;
-
- TReplaceDialog = class(TFindDialog)
- protected
- procedure ConvertFields; override;
- procedure ConvertFieldsForCallBack; override;
- procedure Replace; dynamic;
- public
- destructor Destroy; override;
- function Execute: Boolean; override;
- function Message(var Msg: TMessage): Boolean; override;
- published
- property ReplaceText: string;
- property OnReplace: TNotifyEvent;
- end;
-
- function MessageDlg(const Msg: string; AType: TMsgDlgType;
- AButtons: TMsgDlgButtons; HelpCtx: Longint): Word;
- function MessageDlgPos(const Msg: string; AType: TMsgDlgType;
- AButtons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Word;
-
- function InputBox(const ACaption, APrompt, ADefault: string): string;
- function InputQuery(const ACaption, APrompt: string;
- var Value: string): Boolean;
-
- procedure ShowMessage(const Msg: string);
- procedure ShowMessagePos(const Msg: string; X, Y: Integer);
-
- function CreateMessageDialog(const Msg: string; AType: TMsgDlgType;
- AButtons: TMsgDlgButtons): TForm;
-
- const
- MsgDlgButtonStyle: TButtonStyle = bsAutoDetect;
- MsgDlgGlyphs: Boolean = True;
- MsgDlgBtnSize: TPoint = (X: 77; Y: 27);
-
- implementation
-