Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2005 Jul : SetWindowProc:: word or excel protected against it ?
| Subject: | SetWindowProc:: word or excel protected against it ? |
| Posted by: | "abella" (fabel..@testandgo.com) |
| Date: | Fri, 15 Jul 2005 17:20:58 |
Hi,
I am using the SETWINDOWPROC function using delphi 7 to trap the windows
Message and modify the WM_PAINT properties of any window form present. It's
works normaly with any current executed form, but when i try to use it to
trap an "excel" or "word" form, i have an error (not allowed). I think that
word, excel visio ... have a special protection against the SETWINDOWPROC !.
any idea to execute the setwindowproc with microsoft word, excel.... ???
Thank's a lot
Frank
(ps) my coding
type
TWndProcSendMessage = procedure (UwndProc:TObject;
HandleWindow: HWND;
Msg :TMessage) of object;
TUwndProc = class(tcomponent)
private
Handle:HWND;
Etat:PEtat;
FWndProcMessage : TWndProcMessage;
procedure TrapWndMessages(var Msg :TMessage);
public
FWndProcSendMessage: TWndProcSendMessage;
OldClientWP,NewClientWP : FARPROC ;
constructor create(AOwner: TComponent); override;
destructor Destroy; override;
end;
TFormCentral = class(TForm)
.......
...................
...................
constructor TFormCentral.create.....
var ps:TUwndProc;
begin
ps:=TUwndProc.create(self);
ps.Handle:=CurrentFormHandle;
ps.FWndProcSendMessage:=GestionProcedureWNDPROC;
fp:=FARPROC(MakeObjectInstance(ps.TrapWndMessages));
ps.NewClientWP:=fp;
ps.OldClientWP:=FARPROC(SetWindowLong(fenetre,
GWL_WNDPROC,longint(fp)));
...............
end
procedure TUwndProc.TrapWndMessages(var Msg :TMessage);
var ThisHdc : HDC ;
ha:hwnd;
Fonction:TWndProcSendMessage;
begin
Msg.Result := CallWindowProc(OldClientWP, self.Handle, Msg.Msg,
Msg.WParam, Msg.LParam);
ha:=self.Handle;
Fonction:=self.FWndProcSendMessage;
case (Msg.Msg) of
WM_ACTIVATE,WM_CLOSE:begin
fonction(self,ha,msg);
end;
WM_PAINT,WM_SIZE:begin
ThisHdc:=GetWindowDC(form1.Handle);
BitBlt(ThisHdc, 4, 4, 18, 18, Image1.Canvas.handle, 0, 0,
SRCCOPY);
releaseDC(form1.Handle,ThisHdc);
end;
end;
end;