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.
Delphi

Avatar of undefined
Last Comment
rincewind666

8/22/2022 - Mon
MerijnB

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

ASKER
rincewind666

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'
MerijnB

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
ASKER
rincewind666

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

Ok, hold on, I'll try to make something working shortly.
ASKER CERTIFIED SOLUTION
JDSkinner

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
or
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
SOLUTION
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.
JDSkinner

'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.
MerijnB

The website says:

From ¬ 245.00
(ca. US$ 330.00)

Am I missing something?
ASKER
rincewind666

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.
MerijnB

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
ASKER
rincewind666

It took me some time to find this. A case of bad webpage design.
BdLm

@ 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
 
JDSkinner

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.
BdLm

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?
ASKER
rincewind666

Many thanks for your help.