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 undefined
Last Comment

8/22/2022 - Mon

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;
 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);

Open in new window


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?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

Sorry. I'm a beginner in Delphi. Thans for the help anyway MerijnB.

Ok, hold on, I'll try to make something working shortly.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

'somewhat costly '
The PDF Viewer is free, if you want more than just viewing pdf files then there will be a cost.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

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!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

I feel the real target is to view the pdf file and then to save it as text
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)  
i had no success?

Many thanks for your help.