Place TImage and TOpenPictureDialog on the Delphi form. Include the reference to DWG to the Uses section of the form. When OpenPictureDialog1.Execute has called DWG files will be shown in the Dialog preview window automatically. When the button is pressed, the selected DWG file is loaded into the scrolling window. The next example is used with TImage.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, StdCtrls, ExtCtrls, DWG;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
OpenPictureDialog1: TOpenPictureDialog;
procedure Button1Click(Sender: TObject);
procedure OpenPictureDialog1Show(Sender: TObject);
procedure OpenPictureDialog1Close(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
Image1.LoadFromFile(OpenPictureDialog1.FileName);
end;
procedure TForm1.OpenPictureDialog1Show(Sender: TObject);
begin
CADPreview := True;
end;
procedure TForm1.OpenPictureDialog1Close(Sender: TObject);
begin
CADPreview := False;
end;
end.
Go to CAD VCL Enterprise