home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / DIALOGS.INT < prev    next >
Text File  |  1996-05-08  |  7KB  |  222 lines

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