D
DragonInCity
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Memo1: TMemo;<br> procedure FormCreate(Sender: TObject);<br> private<br> <br> public<br> { Public declarations }<br> end;<br> Function ClientWindowProc( wnd: HWND; msg: Cardinal; wparam, lparam: Integer ): Integer; stdcall;<br> Function ClientWindowProc11( wnd: HWND; msg: Cardinal; wparam, lparam: Integer ): Integer; stdcall;<br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>Function ClientWindowProc( wnd: HWND; msg: Cardinal; wparam, lparam: Integer ): Integer; stdcall;<br>Var<br> pUserdata: Pointer;<br>Begin<br> pUserdata:= Pointer( GetWindowLong( wnd, GWL_USERDATA ));<br> Case msg of<br> WM_MOUSEWHEEL:<br> begin<br> ShowMessage('WM_MOUSEWHEEL');<br> End;<br> Result := CallWindowProc(pUserdata, wnd, msg, wparam, lparam );<br>end;<br><br>Function ClientWindowProc11( wnd: HWND; msg: Cardinal; wparam, lparam: Integer ): Integer; stdcall;<br>Var<br> pUserdata: Pointer;<br>Begin<br> pUserdata:= Pointer( GetWindowLong( wnd, GWL_USERDATA ));<br> Case msg of<br> WM_RBUTTONDOWN:begin<br> showmessage('WM_RBUTTONDOWN');<br> end;<br> End;<br> Result := CallWindowProc(pUserdata, wnd, msg, wparam, lparam );<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> //为什么同一个控件不能用两次?<br> SetWindowLong(Memo1.Handle, GWL_USERDATA, SetWindowLong(Memo1.Handle, GWL_WNDPROC, integer( @ClientWindowProc)));<br> SetWindowLong(Memo1.Handle, GWL_USERDATA, SetWindowLong(Memo1.Handle, GWL_WNDPROC, integer( @ClientWindowProc11)));<br>end;<br><br>end.