home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Doc / DIALOGS.INT < prev    next >
Encoding:
Text File  |  1999-01-26  |  8.2 KB  |  252 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Visual Component Library         }
  5. {                                                       }
  6. {       Copyright (c) 1995,98 Inprise Corporation       }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit Dialogs;
  11.  
  12. {$R-}
  13.  
  14. interface
  15.  
  16. uses Windows, Messages, SysUtils, CommDlg, Classes, Graphics, Controls,
  17.   Forms, StdCtrls;
  18.  
  19. const
  20.  
  21. { Maximum number of custom colors in color dialog }
  22.  
  23.   MaxCustomColors = 16;
  24.  
  25. type
  26.  
  27. { TCommonDialog }
  28.  
  29.   TCommonDialog = class(TComponent)
  30.   protected
  31.     procedure DoClose; dynamic;
  32.     procedure DoShow; dynamic;
  33.     procedure WndProc(var Message: TMessage); virtual;
  34.     function MessageHook(var Msg: TMessage): Boolean; virtual;
  35.     function TaskModalDialog(DialogFunc: Pointer; var DialogData): Bool; virtual;
  36.     function Execute: Boolean; virtual; abstract;
  37.     property Template: PChar;
  38.   public
  39.     constructor Create(AOwner: TComponent); override;
  40.     destructor Destroy; override;
  41.     procedure DefaultHandler(var Message); override;
  42.     property Handle: HWnd;
  43.   published
  44.     property Ctl3D: Boolean default True;
  45.     property HelpContext: THelpContext default 0;
  46.     property OnClose: TNotifyEvent;
  47.     property OnShow: TNotifyEvent;
  48.   end;
  49.  
  50. { TOpenDialog }
  51.  
  52.   TOpenOption = (ofReadOnly, ofOverwritePrompt, ofHideReadOnly,
  53.     ofNoChangeDir, ofShowHelp, ofNoValidate, ofAllowMultiSelect,
  54.     ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofCreatePrompt,
  55.     ofShareAware, ofNoReadOnlyReturn, ofNoTestFileCreate, ofNoNetworkButton,
  56.     ofNoLongNames, ofOldStyleDialog, ofNoDereferenceLinks, ofEnableIncludeNotify,
  57.     ofEnableSizing);
  58.   TOpenOptions = set of TOpenOption;
  59.  
  60.   TFileEditStyle = (fsEdit, fsComboBox);
  61.  
  62.   TOpenDialog = class(TCommonDialog)
  63.   protected
  64.     function CanClose(var OpenFileName: TOpenFileName): Boolean;
  65.     function DoCanClose: Boolean; dynamic;
  66.     function DoExecute(Func: Pointer): Bool;
  67.     procedure DoSelectionChange; dynamic;
  68.     procedure DoFolderChange; dynamic;
  69.     procedure DoTypeChange; dynamic;
  70.     procedure DefineProperties(Filer: TFiler); override;
  71.     procedure GetFileNames(var OpenFileName: TOpenFileName);
  72.     function GetStaticRect: TRect; virtual;
  73.     procedure WndProc(var Message: TMessage); override;
  74.   public
  75.     constructor Create(AOwner: TComponent); override;
  76.     destructor Destroy; override;
  77.     function Execute: Boolean; override;
  78.     property FileEditStyle: TFileEditStyle;
  79.     property Files: TStrings;
  80.     property HistoryList: TStrings;
  81.   published
  82.     property DefaultExt: string;
  83.     property FileName: TFileName;
  84.     property Filter: string;
  85.     property FilterIndex: Integer default 1;
  86.     property InitialDir: string;
  87.     property Options: TOpenOptions default [ofHideReadOnly, ofEnableSizing];
  88.     property Title: string;
  89.     property OnCanClose: TCloseQueryEvent;
  90.     property OnFolderChange: TNotifyEvent;
  91.     property OnSelectionChange: TNotifyEvent;
  92.     property OnTypeChange: TNotifyEvent;
  93.   end;
  94.  
  95. { TSaveDialog }
  96.  
  97.   TSaveDialog = class(TOpenDialog)
  98.     function Execute: Boolean; override;
  99.   end;
  100.  
  101. { TColorDialog }
  102.  
  103.   TColorDialogOption = (cdFullOpen, cdPreventFullOpen, cdShowHelp,
  104.     cdSolidColor, cdAnyColor);
  105.   TColorDialogOptions = set of TColorDialogOption;
  106.  
  107.   TCustomColors = array[0..MaxCustomColors - 1] of Longint;
  108.  
  109.   TColorDialog = class(TCommonDialog)
  110.   public
  111.     constructor Create(AOwner: TComponent); override;
  112.     destructor Destroy; override;
  113.     function Execute: Boolean; override;
  114.   published
  115.     property Color: TColor default clBlack;
  116.     property Ctl3D default False;
  117.     property CustomColors: TStrings;
  118.     property Options: TColorDialogOptions default [];
  119.   end;
  120.  
  121. { TFontDialog }
  122.  
  123.   TFontDialogOption = (fdAnsiOnly, fdTrueTypeOnly, fdEffects,
  124.     fdFixedPitchOnly, fdForceFontExist, fdNoFaceSel, fdNoOEMFonts,
  125.     fdNoSimulations, fdNoSizeSel, fdNoStyleSel,  fdNoVectorFonts,
  126.     fdShowHelp, fdWysiwyg, fdLimitSize, fdScalableOnly, fdApplyButton);
  127.   TFontDialogOptions = set of TFontDialogOption;
  128.  
  129.   TFontDialogDevice = (fdScreen, fdPrinter, fdBoth);
  130.  
  131.   TFDApplyEvent = procedure(Sender: TObject; Wnd: HWND) of object;
  132.  
  133.   TFontDialog = class(TCommonDialog)
  134.   protected
  135.     procedure Apply(Wnd: HWND); dynamic;
  136.     procedure WndProc(var Message: TMessage); override;
  137.   public
  138.     constructor Create(AOwner: TComponent); override;
  139.     destructor Destroy; override;
  140.     function Execute: Boolean; override;
  141.   published
  142.     property Font: TFont;
  143.     property Device: TFontDialogDevice default fdScreen;
  144.     property MinFontSize: Integer;
  145.     property MaxFontSize: Integer;
  146.     property Options: TFontDialogOptions default [fdEffects];
  147.     property OnApply: TFDApplyEvent;
  148.   end;
  149.  
  150. { TPrinterSetupDialog }
  151.  
  152.   TPrinterSetupDialog = class(TCommonDialog)
  153.   public
  154.     function Execute: Boolean; override;
  155.   end;
  156.  
  157. { TPrintDialog }
  158.  
  159.   TPrintRange = (prAllPages, prSelection, prPageNums);
  160.   TPrintDialogOption = (poPrintToFile, poPageNums, poSelection, poWarning,
  161.     poHelp, poDisablePrintToFile);
  162.   TPrintDialogOptions = set of TPrintDialogOption;
  163.  
  164.   TPrintDialog = class(TCommonDialog)
  165.   public
  166.     function Execute: Boolean; override;
  167.   published
  168.     property Collate: Boolean default False;
  169.     property Copies: Integer default 0;
  170.     property FromPage: Integer default 0;
  171.     property MinPage: Integer default 0;
  172.     property MaxPage: Integer default 0;
  173.     property Options: TPrintDialogOptions default [];
  174.     property PrintToFile: Boolean default False;
  175.     property PrintRange: TPrintRange default prAllPages;
  176.     property ToPage: Integer default 0;
  177.   end;
  178.  
  179. { TFindDialog }
  180.  
  181.   TFindOption = (frDown, frFindNext, frHideMatchCase, frHideWholeWord,
  182.     frHideUpDown, frMatchCase, frDisableMatchCase, frDisableUpDown,
  183.     frDisableWholeWord, frReplace, frReplaceAll, frWholeWord, frShowHelp);
  184.   TFindOptions = set of TFindOption;
  185.  
  186.   TFindReplaceFunc = function(var FindReplace: TFindReplace): HWnd stdcall;
  187.  
  188.   TFindDialog = class(TCommonDialog)
  189.   protected
  190.     function MessageHook(var Msg: TMessage): Boolean; override;
  191.     procedure Find; dynamic;
  192.     procedure Replace; dynamic;
  193.   public
  194.     constructor Create(AOwner: TComponent); override;
  195.     destructor Destroy; override;
  196.     procedure CloseDialog;
  197.     function Execute: Boolean; override;
  198.     property Left: Integer;
  199.     property Position: TPoint;
  200.     property Top: Integer;
  201.   published
  202.     property FindText: string;
  203.     property Options: TFindOptions default [frDown];
  204.     property OnFind: TNotifyEvent;
  205.   end;
  206.  
  207. { TReplaceDialog }
  208.  
  209.   TReplaceDialog = class(TFindDialog)
  210.   public
  211.     constructor Create(AOwner: TComponent); override;
  212.   published
  213.     property ReplaceText;
  214.     property OnReplace;
  215.   end;
  216.  
  217. { Message dialog }
  218.  
  219. type
  220.   TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom);
  221.   TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore,
  222.     mbAll, mbNoToAll, mbYesToAll, mbHelp);
  223.   TMsgDlgButtons = set of TMsgDlgBtn;
  224.  
  225. const
  226.   mbYesNoCancel = [mbYes, mbNo, mbCancel];
  227.   mbOKCancel = [mbOK, mbCancel];
  228.   mbAbortRetryIgnore = [mbAbort, mbRetry, mbIgnore];
  229.  
  230. function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType;
  231.   Buttons: TMsgDlgButtons): TForm;
  232.  
  233. function MessageDlg(const Msg: string; DlgType: TMsgDlgType;
  234.   Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
  235. function MessageDlgPos(const Msg: string; DlgType: TMsgDlgType;
  236.   Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Integer;
  237. function MessageDlgPosHelp(const Msg: string; DlgType: TMsgDlgType;
  238.   Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer;
  239.   const HelpFileName: string): Integer;
  240.  
  241. procedure ShowMessage(const Msg: string);
  242. procedure ShowMessageFmt(const Msg: string; Params: array of const);
  243. procedure ShowMessagePos(const Msg: string; X, Y: Integer);
  244.  
  245. { Input dialog }
  246.  
  247. function InputBox(const ACaption, APrompt, ADefault: string): string;
  248. function InputQuery(const ACaption, APrompt: string;
  249.   var Value: string): Boolean;
  250.  
  251. implementation
  252.