Link to home
Start Free TrialLog in
Avatar of rincewind666
rincewind666

asked on

Runnng Acrobat Reader + my form on same screen (500 points)

When I click a button, I want to run Acrobat Reader but I do not want it to cover the whole screen - just the bottom 2 thirds of it.  I also want to show a form of my own at the top at the same time.

I am using Delphi 6.

I am giving 500 points for this as it is URGENT.  Many thanks for your help.
Avatar of MerijnB
MerijnB
Flag of Netherlands image

You can try to start adobe, and then set it's parent to a panel on your form.
Please see below a piece of code of one of the project I did which does this with an another application. It works quite well. I've not tested it with acrobat though.

You'll need to add a Panel to your form called PanelAcrobat

Hope it helps.
procedure TMainForm.StartAcrobat;
const COMMANDLINE = 'c:\myfile.pdf';
var StartupInfo: TStartUpInfo;
    ProcessInformation: TProcessInformation;
    Style: integer;
begin
 if not FileExists(fAcrobatLocation) then Exit;
 
 ZeroMemory(@StartupInfo, sizeof(StartupInfo));
 StartupInfo.cb := sizeof(StartupInfo);
 CreateProcess(pchar(fAcrobatLocation), PChar(COMMANDLINE), nil, nil, false, 0, nil, nil, StartupInfo, ProcessInformation);
 
 fAcrobatProcessHandle := ProcessInformation.hProcess;
 fAcrobatProcessID := ProcessInformation.dwProcessId;
 
 WaitForInputIdle(fAcrobatProcessHandle, INFINITE);
 
 fAcrobatWndHandle := GetWindowHandle(fAcrobatProcessID);
 if fAcrobatWndHandle = 0 then
  fAcrobatWndHandle := FindAcrobatByTitle();
 
 Style := GetWindowLong(fAcrobatWndHandle, GWL_STYLE);
 Style := Style and (not (WS_CAPTION));
 SetWindowLong(fAcrobatWndHandle, GWL_STYLE, Style);
 
 Windows.SetParent(fAcrobatWndHandle, PanelAcrobat.Handle);
 
 SetWindowPos(fAcrobatWndHandle, 0, 0, 0, PanelAcrobat.ClientWidth, PanelAcrobat.ClientHeight, SWP_NOZORDER or SWP_SHOWWINDOW);
 ShowWindow(fAcrobatWndHandle, SW_MAXIMIZE);
 
 SetForegroundWindow(Handle);
end;

Open in new window

Avatar of rincewind666
rincewind666

ASKER

MerijnB, I am getting the following errors:

[Error] Unit310.pas(49): Undeclared identifier: 'fAcrobatLocation'
[Error] Unit310.pas(55): Undeclared identifier: 'fAcrobatProcessHandle'
[Error] Unit310.pas(56): Undeclared identifier: 'fAcrobatProcessID'
[Error] Unit310.pas(60): Undeclared identifier: 'fAcrobatWndHandle'
[Error] Unit310.pas(60): Undeclared identifier: 'GetWindowHandle'
[Warning] Unit310.pas(61): Comparing signed and unsigned types - widened both operands
[Error] Unit310.pas(62): Undeclared identifier: 'FindAcrobatByTitle'
[Error] Unit310.pas(113): Undeclared identifier: 'HelpLabel'
[Hint] Unit310.pas(28): Private symbol 'StartAcrobat' declared but never used
[Fatal Error] Script_Installer.dpr(48): Could not compile used unit 'Unit310.pas'
This is example code, not something completely working. The hard part is there, are you able to use this?
Sorry. I'm a beginner in Delphi. Thans for the help anyway MerijnB.
Ok, hold on, I'll try to make something working shortly.
ASKER CERTIFIED SOLUTION
Avatar of JDSkinner
JDSkinner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
'somewhat costly '
The PDF Viewer is free, if you want more than just viewing pdf files then there will be a cost.
The website says:

From ¬ 245.00
(ca. US$ 330.00)

Am I missing something?
Found it!  To be fair to MerijnB it is not very clear.  It is only shown in the drop-down list at the top of this page and not on the page itself.  I will try this. Thanks.
In that case it's a good one to remember!
It took me some time to find this. A case of bad webpage design.
@ rincewind666
do you need the running acrobat exe and then put your form (application) close to acroboat
can you accept an OLE instance runnning on your form
 
The Synactis PDF Viewer is a wrapper of the Adobe Reader programming interface.
A copy of your existing Adobe Reader will run in background, having been
started by the PDF viewer component.  

The Synactis PDF Viewer has been tested with various versions of Adobe Reader,
its behavior may depend on the version in use on individual PCs.

You can use it to view and print pdf files from within a Delphi enviroment.
I feel the real target is to view the pdf file and then to save it as text
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_24082971.html#a23472366
Viewing the pdf file on a form is easy using activeX typeLibs, but I could not find a solution for saving the pdf as TXT,  in the acrobat activeX docu  (acrobat homepage)  
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACReference.pdf  
i had no success?
Many thanks for your help.