I successfully added AcroPDF in my application. When a PDF needs to be displayed I create an instance of AcroPDF dynamically and insert it into a TPanel with align set to alClient. My problem is that when the Form/Panel is resized the AcroPDF does not follow. Only if a new file is loaded. I tried several solutions to no avail. What should I do?
Asked
Active
Viewed 3,334 times
2 Answers
5
It's a problem with recent versions of the Adobe OCX control, which you can work around by refocusing the control. In a preview dialog I have (which has an embedded, client-aligned AcroPdf control) I use the following OnResize
handler for the form:
if Visible and (fPreviewV7 <> nil) then begin
FocusControl(nil);
FocusControl(fPreviewV7);
end;

mghie
- 32,028
- 6
- 87
- 129
1
If you use ActiveX from version 9 of Acrobat Reader try this code in OnResize event of TPanel:
procedure TForm.PanelResize(Sender: TObject);
var
rc: TRect;
h: THandle;
begin
if Assigned(AcroPdf) then
begin
if (Windows.GetClientRect(AcroPdf.Handle, rc)) then
begin
h := Windows.FindWindowEx(AcroPdf.Handle, 0, PChar('Static'), nil);
if (h <> 0) then
Windows.MoveWindow(h, 0, 0, rc.Right - rc.Left, rc.Bottom - rc.Top, True);
end;
end;
end;
The problem in that the child window of main AcroPdf window is not resized. So we found it by it's class name "Static" and manually move it to fill whole parent window. This code can not work on other versions of Acrobat Reader, because the window hierarchy and class name's may differ.

Schnider
- 93
- 1
- 5