Disabled的窗体怎么得到消息?(100分)

  • 主题发起人 主题发起人 BeginDelphi
  • 开始时间 开始时间
B

BeginDelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
最近小弟在研究IME,想用DELPHI开发一个"五笔输入法".<br>但不懂的是,IME中的窗体必须要Disabled,不能得到焦点;我在DELPHI中把Enabled<br>设为False后,根本得不到WM_MouseOver,WM_LButtonDown等消息.但DDK中的例程却是<br>这样的.为什么呢?
 
我以前做的输入法:<br>http://www.8421.org/download.php?id=91
 
http://wwsys.51.net/<br>输入法辅导站
 
我自定义一个TCOMPONENT,写上了procedure WMMouseOver(var msg:TMessage);message <br>wm_mouseover;<br><br>但放到一个Disable的窗体上时,这个事件根本不会触发,怎么办?
 
看看下面的代码对你有没有启发:<br>const UDF_SOCKETEVENT = WM_USER+500;<br>type<br>&nbsp; TComponent1 = class(Tcomponent)<br>&nbsp; private<br>&nbsp; &nbsp; FWindowHandle: HWND;<br>&nbsp; &nbsp; FOnMySocket : TNotifyEvent;<br>&nbsp; &nbsp; procedure WndProc(var Msg: TMessage);<br>&nbsp; protected<br>&nbsp; &nbsp; procedure MySocket; dynamic;<br>&nbsp; public<br>&nbsp; &nbsp; constructor Create(AOwner: TComponent); override;<br>&nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; &nbsp; procedure proc1;<br>&nbsp; Published<br>&nbsp; &nbsp; property OnMySocket: TNotifyEvent read FOnMySocket <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;write FOnMySocket;<br>&nbsp; end;<br><br>...<br><br>constructor TComponent1.Create(AOwner: TComponent);<br>begin<br>&nbsp; inherited Create(AOwner);<br>&nbsp; FWindowHandle := AllocateHWnd(WndProc);<br>end;<br><br>destructor TComponent1.Destroy;<br>begin<br>&nbsp; DeallocateHWnd(FWindowHandle);<br>&nbsp; inherited Destroy;<br>end;<br><br>procedure TComponent1.WndProc(var Msg: TMessage);<br>begin<br>&nbsp; with Msg do<br>&nbsp; &nbsp; if Msg = UDF_SOCKETEVENT then<br>&nbsp; &nbsp; &nbsp; MySocket<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);<br>end;<br><br>procedure TComponent1.MySocket;<br>begin<br>&nbsp; if Assigned(FOnMySocket) then FOnMySocket(Self);<br>end;<br><br>procedure TComponent1.proc1 ;<br>var<br>&nbsp; PopSocket : boolean;<br>begin<br>&nbsp; POPSocket:=NetPop.OpenSocketConnection(FWindowHandle,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;UDF_SOCKETEVENT,110);<br>&nbsp; ...<br><br>end;<br>
 
Thankx to forgot2002;<br><br>但我试过了,还是不行。我放在FORM上,当FORM是Enabled的时候可以得到消息,<br>当Form为disabled的时候还是得不到,怎么办呀?
 
不应该用窗体来做吧?<br><br>你需要用“应用程序桌面工具栏”来做,也就是AppBar,虽然它也是窗体,但和一般的窗体<br>是不同的,,你可以看《Delphi 5 开发人员指南》上的相关章节,说得很详细了,,希望对<br>你有帮助,,,其实我可以给你一个含有关键代码的例子的,,但老板的项目实在是太紧了,<br>没时间了,我现在上论坛都不一定了,,对不住了哈!!!
 
http://www.2ccc.com/article.asp?articleid=942 &nbsp;我做的
 
后退
顶部