interface
[...]
Type
TForm1 =
Class(TForm)
private
FAfxHandle: HWND;
Procedure SetAfxHandle;
public
Property AfxHandle: HWND
read FAfxHandle
write FAfxHandle;
End;
Function PDFWndProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
stdcall;
Var
Form1: TForm1;
pOrigPDFWndProc: FarProc;
Implementation
[...]
Procedure TForm1.FormShow(Sender: TObject);
Begin
SetAfxHandle;
End;
//zum eigentlichen Control durchhangeln und das Handle setzen
Procedure TForm1.SetAfxHandle;
Var
FormHandle: HWND;
PanelHandle: HWND;
AfxOleHandle: HWND;
AfxFrameHandle: HWND;
AfxMDIFrameHandle: HWND;
Begin
FAfxHandle := 0;
FormHandle := FindWindow('
TForm1', '
Form1');
If FormHandle > 0
Then
PanelHandle := FindWindowEx(FormHandle, 0, '
TPanel', '
Panel1')
Else Exit;
If PanelHandle > 0
Then
AfxOleHandle := FindWindowEx(PanelHandle, 0, '
AfxOleControl42s',
Nil)
Else Exit;
If AfxOleHandle > 0
Then
AfxFrameHandle := FindWindowEx(AfxOleHandle, 0, '
AfxFrameOrView42s',
Nil)
Else Exit;
If AfxFrameHandle > 0
Then
AfxMDIFrameHandle := FindWindowEx(AfxFrameHandle, 0, '
AfxMDIFrame42s',
Nil)
Else Exit;
If AfxMDIFrameHandle > 0
Then
FAfxHandle := FindWindowEx(AfxMDIFrameHandle, 0, '
Afx:f30000:b:0:6:0',
Nil);
If FAfxHandle > 0
Then Begin
//Original WndProc des Controls holen
pOrigPDFWndProc := Pointer(GetWindowLong(FAfxHandle, GWL_WNDPROC));
//WndProc dieses Controls überschreiben
setWindowLong(FAfxHandle, GWL_WNDPROC, LongInt(@PDFWndProc));
End;
End;
Function PDFWndProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
stdcall;
Begin
//Messages abfangen und ggf. ersetzen
Case uMsg
Of
WM_VSCROLL:
Begin
ShowMessage('
Scroll');
Result := CallWindowProc(pOrigPDFWndProc, hWnd, uMsg, wParam, lParam);
End Else
//Original WndProc aufrufen
Result := CallWindowProc(pOrigPDFWndProc, hWnd, uMsg, wParam, lParam);
End;
End;
[...]