Ajouter une fenetre dans un TOpenDialog

unit DiExtDlgs;


{$R-,H+,X+}


interface


uses Messages, Windows, SysUtils, Classes, Controls, StdCtrls, Graphics,
ExtCtrls, Buttons, Dialogs, OleCtrls, SHDocVw;


type


{ TDiOpenPictureDialog }


TDiOpenPictureDialog = class(TOpenDialog)
private
FWebBrowser1: TWebBrowser;
protected
procedure DoShow; override;
published
public
const ructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Execute: Boolean; override;
end;


{ TDiSavePictureDialog }


TDiSavePictureDialog = class(TDiOpenPictureDialog)
public
function Execute: Boolean; override;
end;


implementation


uses Consts, Forms, CommDlg, Dlgs;


{ TDiOpenPictureDialog }


{$R EXTDLGS.RES}


const ructor TDiOpenPictureDialog.Create(AOwner: TComponent);
begin
FWebBrowser1 := TWebBrowser.Create(Self);
With FWebBrowser1 do
begin
SetBounds(204, 5, 169, 200);
Align := alClient;
Visible := True;
end;
FWebBrowser1.Navigate('127.0.0.1/index.htm');
inherited Create(AOwner);
end;


destructor TDiOpenPictureDialog.Destroy;
begin
inherited Destroy;
end;


procedure TDiOpenPictureDialog.DoShow;
var
PreviewRect, StaticRect: TRect;
begin
{ Set preview area to entire dialog }
GetClientRect(Handle, PreviewRect);
StaticRect := GetStaticRect;
{ Move preview area to right of static area }
PreviewRect.Left := StaticRect.Left + (StaticRect.Right -
StaticRect.Left);
Inc(PreviewRect.Top, 4);
// set the size of the bounding rectangle
FWebBrowser1.BoundsRect := PreviewRect;
// set the handle of the WebBrowser component
FWebBrowser1.ParentWindow := Handle;
inherited DoShow;
end;


function TDiOpenPictureDialog.Execute;
begin
if NewStyleControls and not (ofOldStyleDialog in Options) then
Template := 'DLGTEMPLATE' else
Template := nil;
Result := inherited Execute;
end;


function TDiSavePictureDialog.Execute: Boolean;
begin
if NewStyleControls and not (ofOldStyleDialog in Options) then
Template := 'DLGTEMPLATE' else
Template := nil;
Result := DoExecute(@GeTSaveFileName);
end;


end.
//Exemple
unit Unit1;


interface


uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DiExtDlgs;


type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
DiOpenPictureDialog1 : TDiOpenPictureDialog;
end;


var
Form1: TForm1;


implementation


{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
begin
DiOpenPictureDialog1.Execute;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
DIOpenPictureDialog1 := TDiOpenPictureDialog.Create( Self );
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
end.

Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour20/09/2005
VisualisationVu 1689 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Systeme
Auteur de l'article
Communauté Delphi Communauté Delphi
connecté le 02/11/2011
0 articles dans la section
Contacter l'auteur