关于截获窗体最小化,关闭按钮消息的问题(急急急……) ( 积分: 50 )

  • 主题发起人 主题发起人 小菜虫儿
  • 开始时间 开始时间

小菜虫儿

Unregistered / Unconfirmed
GUEST, unregistred user!
我想实现,点击窗体右上脚的最小化,关闭后,窗体隐藏,朋友写了一个函数,可是实现这个功能,但<br><br>问题是,我点击窗体菜单,菜单没有反应,请大家帮帮忙,代码如下:<br>procedure TForm2.WMSysCommand(var msg:TMessage);<br>begin &nbsp; &nbsp;<br> &nbsp;case msg.wParam of<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SC_CLOSE:begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form2.hide;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;SC_MINIMIZE:begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form2.Hide;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> &nbsp;end; &nbsp; &nbsp; <br>end;
 
我想实现,点击窗体右上脚的最小化,关闭后,窗体隐藏,朋友写了一个函数,可是实现这个功能,但<br><br>问题是,我点击窗体菜单,菜单没有反应,请大家帮帮忙,代码如下:<br>procedure TForm2.WMSysCommand(var msg:TMessage);<br>begin &nbsp; &nbsp;<br> &nbsp;case msg.wParam of<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SC_CLOSE:begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form2.hide;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;SC_MINIMIZE:begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form2.Hide;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> &nbsp;end; &nbsp; &nbsp; <br>end;
 
在函数声明时这样写:<br>procedure WMSysCommand(var Msg: TMessage); message WM_SYSCOMMAND;才可以截获消息。另你的过程最后最好加上一句:<br> &nbsp;case ... ( 你要截获的消息处理部分 )<br> &nbsp;else inherited; (其他消息就调用系统的)<br> &nbsp;end;
 
同意楼上意见
 
WMSysCommand,这个函数是自定义的还是系统原来就有,只是重新加载拉??
 
procedure WMSYSCOMMAND(var Msg: TWMSysCommand); message WM_SYSCOMMAND;<br><br>procedure TForm1.WMSYSCOMMAND(var Msg: TWMSysCommand);<br>begin<br> &nbsp;if Msg.CmdType = SC_MINIMIZE then<br> &nbsp; &nbsp;...<br> &nbsp;inherited;<br>end;
 
WMSysCommand,这个函数是自定义的还是系统原来就有,只是重新加载拉??
 
寒哦。消息处理handler的名字其实无关紧要的。关键是message这个关键字... ...
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
727
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
555
import
I
后退
顶部