Hi,
can anyone help with this? I'm trying to write some code in a button event handler. When a user clicks the button they are asked to select a file. This file then should be displayed in the TOleContainer object on my form.
At the moment all I'm getting in the TOleContainer is the name of the file. If you double click the file name however the application associated with the file is launched and the file is displayed. How can I get the file to display on my form though.
Here is my code:
procedure TForm1.Button1Click(Sender: TObject);
var
filename : string;
CreateInfo : TCreateInfo;
begin
if OpenDialog1.Execute then
begin
filename := OpenDialog1.FileName;
FillChar(CreateInfo, sizeOf(TCreateInfo), 0);
CreateInfo.CreateType := ctFromFile;
CreateInfo.ShowAsIcon := false;
CreateInfo.FileName := filename;
OleContainer1.CreateObjectFromInfo (CreateInfo);
end;
end;
Any help with this would be very much appreciated. Thanks in advance.
can anyone help with this? I'm trying to write some code in a button event handler. When a user clicks the button they are asked to select a file. This file then should be displayed in the TOleContainer object on my form.
At the moment all I'm getting in the TOleContainer is the name of the file. If you double click the file name however the application associated with the file is launched and the file is displayed. How can I get the file to display on my form though.
Here is my code:
procedure TForm1.Button1Click(Sender: TObject);
var
filename : string;
CreateInfo : TCreateInfo;
begin
if OpenDialog1.Execute then
begin
filename := OpenDialog1.FileName;
FillChar(CreateInfo, sizeOf(TCreateInfo), 0);
CreateInfo.CreateType := ctFromFile;
CreateInfo.ShowAsIcon := false;
CreateInfo.FileName := filename;
OleContainer1.CreateObjectFromInfo (CreateInfo);
end;
end;
Any help with this would be very much appreciated. Thanks in advance.