home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk14 / doc.pak / DIALOGS.INT < prev    next >
Encoding:
Text File  |  1995-08-24  |  7.0 KB  |  219 lines

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