Hello,
Opening an ANSI TXT file is easy as you can load it to TStringList, memory stream, TMemo component, etc. But everything depends on a particular task.
If you need to just display a TXT file in a TMemo component, the code may look like:
if not OpenDialog1.Execute then Exit;
Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
Reading a PDF file is not an easy task as PDF is a binary format.
I suppose you will have to use a PDF ActiveX control to display it, so it depends on the methods the control provides.
As to the secondary form, you will need to just open the form first and then display the file there. Thought, I prefer to create a secondary form dynamically (not in the DPR unit.)
For example:
MyForm:= Application.CreateForm(TMyForm, MyForm);
try
if not OpenDialog1.Execute then Exit;
MyForm.Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
if MyForm.ShowModal <> mrOk then Exit;
// some code here
finally
MyForm.Free;
end; HTH.
Tom Barnet
HelpSmith 2.0 is Released. Have You Yet Upgraded?