setwindowlong时的发生的一个编译错误,??(100分)

Y

yhzz

Unregistered / Unconfirmed
GUEST, unregistred user!
在我的代码中
SetWindowLong( strtoint(HandleEdit.Text),GWL_WNDPROC,Longint(@NewWndProc));
其中HandleEdit.text是获取的一个窗口handle,NewWndProc是我的一个窗口处理过程
function NewWndProc(Handle:HWND;Msg,wParam,lParam:Longint):Longint;stdcall;
在编译时在setwindowlong这一行出现variable required的错误提示,实在不清楚这是为什么了
请指教
 
给你一个简单的例子吧。DELPHI6+WIN2000上测试通过
---------------------------------------------------



unit MAIN;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FClientInstance, FPrevClientProc : TFarProc;
hand:THandle;
procedure ClientWndProc(var Message: TMessage);
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
hand:=Panel1.Handle;
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(hand, GWL_WNDPROC));
SetWindowLong(hand, GWL_WNDPROC, LongInt(FClientInstance));
end;

procedure TForm1.ClientWndProc(var Message: TMessage);
begin
case Message.Msg of
WM_LBUTTONDBLCLK:
begin
ShowMessage ('WM_LBUTTONDBLCLK事件');
end;
end;
Message.Result := CallWindowProc(FPrevClientProc, hand, Message.Msg, Message.wParam, Message.lParam);
end;

end.
 
感觉这种方法,好像无法替换别的程序窗口的消息处理吧!
 
只能处理本程序的消息。
 
接受答案了.
 
顶部