问题一:用nil吧.<br>问题二:HWND是LongWord类型,不是指针类型,不能nil,而是0.<br>问题三:用createwindow创建的window,你必须先子类化一个新的子类出来,<br>然后将窗口定义成该子类,然后用setwiondowlong来设置它的wndproc.最后在<br>wndproc里面处理按键消息.<br>或者如下:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Edit1: TEdit;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> procedure mymessage(var msg:TMsg;var handled:boolean);<br> end;<br><br>var<br> Form1: TForm1;<br> hb: hwnd;<br>implementation<br><br>{$R *.DFM}<br>var<br> oldmessage:TMessageEvent;<br>procedure tform1.mymessage(var msg:TMsg;var handled:boolean);<br>begin<br> if @oldmessage<>nil then<br> oldmessage(msg,handled);<br> if msg.hwnd=hb then<br> begin<br> if msg.message=WM_KEYDOWN then<br> begin<br> if msg.wParam=VK_F1 then<br> begin<br> msg.wParam:=integer('2');<br>// handled:=true;<br> end;<br> end;<br> end;<br><br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br><br> hb:=Createwindow('edit',nil,ws_child or ws_visible or ws_border,<br> 10,10,200,20,self.handle,<br> hmenu(-1),hinstance,nil);<br> oldmessage:=application.OnMessage;<br> application.OnMessage:=mymessage;<br>end;<br><br>end.