📄 实现qq窗体的缩入伸出功能—编程爱好者网站http--www_programfan_com.htm
字号:
<DIV align=center>
<P><SELECT name=fw size=1> <OPTION selected
value=1>搜索本栏文章</OPTION> <OPTION
value=2>搜索全部文章</OPTION></SELECT><BR></P></DIV></FORM></TD></TR>
<TR>
<TD bgColor=#ff6600 height=20 width="100%">
<P align=center><STRONG><FONT color=#ffffff>栏 目 说
明</FONT></STRONG></P></TD></TR>
<TR>
<TD bgColor=#ffffcc width="100%">
本栏目大部分文章均来自于互联网,版权归原作者和各发布网站所有。本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业目的。否则后果自负。<BR>
如果您对本栏目有什么意见和建议,欢迎<A
href="mailto:yaoz@163.com">和我联系</A>。</TD></TR></TBODY></TABLE></CENTER></DIV></TD>
<TD height=234 vAlign=top width="80%">
<DIV align=center>
<CENTER>
<TABLE border=0 cellPadding=0 cellSpacing=1 height=509 width="98%">
<TBODY>
<TR>
<TD bgColor=#99ccff height=18
style="BORDER-BOTTOM: rgb(0,0,0) 1px solid"
width="100%"><STRONG>您所在的位置:<A
href="http://www.programfan.com/">编程爱好者网站</A> -<A
href="http://www.programfan.net/article.asp">文档中心</A> - <A
href="http://www.programfan.net/article.asp?classid=3"
style="COLOR: rgb(255,0,0)">Delphi文章 </STRONG></A></TD></TR>
<TR>
<TD align=middle bgColor=#fafafa height=248
style="FONT-FAMILY: 宋体; FONT-SIZE: 11pt">
<DIV align=center>
<TABLE border=0 cellPadding=0 cellSpacing=0 height=217
width="90%"><TBODY>
<TR>
<TD align=middle bgColor=#fafafa height=24
style="FONT-FAMILY: 宋体; FONT-SIZE: 11pt"><FONT
color=#ff0000><B>实现QQ窗体的缩入伸出功能</B></FONT></TD></TR>
<TR>
<TD align=middle bgColor=#fafafa height=70><FONT
color=#c0c0c0>(加入日期:2004-2-9 点击数:37)</FONT><BR><B>【<A
href="http://www.programfan.net/comment.asp?id=2430">对此文发表评论</A>】 【<A
href="http://www.programfan.net/club">编程爱好者论坛</A>】 【<A
href="http://www.programfan.net/showarticle.asp?id=2430#"
onclick=javascript:WebBrowser.ExecWB(4,1)>保存文章至硬盘</A>】
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2
height=0 id=WebBrowser width=0></OBJECT> 【<A
href="http://www.programfan.net/showarticle.asp?id=2430#"
onclick=javascript:window.print()>打印文章</A>】</B></TD></TR>
<CENTER></CENTER>
<CENTER></CENTER>
<TR>
<TD align=middle bgColor=#fafafa>
<P align=center><FONT color=#0000ff><A
href="http://www.programfan.net/club/listbbs.asp?rootclassid=8"
style="COLOR: #ff0000"><B>Borland开发讨论区</B></A><B> </B><A
href="http://www.programfan.net/club/listbbs.asp?rootclassid=9"
style="COLOR: #ff0000"><B>微软开发讨论区</B></A> <B><A
href="http://www.programfan.net/club/listbbs.asp?rootclassid=10"
style="COLOR: #ff0000">C/C++讨论区</A> <A
href="http://www.programfan.net/club/listbbs.asp?rootclassid=2"
style="COLOR: #ff0000">新手入门专区</A></B></FONT></P></TD></TR>
<CENTER>
<CENTER>
<TR>
<TD bgColor=#fafafa
height=123><BR> 不知道大家在使用QQ时有没有想到它的缩入伸出的功能是如何实现的呢?实现这个效果的关键在于如何判断当前鼠标指针下面的窗体是不是我们的程序窗体。GetCursorPos()是一个可以获得鼠标指针在屏幕中的坐标的API函数,利用它与FindVCLWindow()的结合就可以轻易地获得鼠标指针下的VCL可视组件,但当一个窗体中不只一个VCL可视组件,例如可能还有TPanel、TMemo等等类型时,那么我们就必须要查找到它们的Parent级,最终得到TForm,那就是指我们的程序窗体。按照这个思路我自定义了GetFormNameAt()函数,它可获得当前鼠标指针下面的窗体的名称。以下列出程序的主要实现代码,供大家参考:<BR><BR>//自定义函数GetFormNameAt,获得鼠标针指下窗体的Name<BR>function
GetFormNameAt ( X, Y : integer ) :
string;<BR>var<BR> P:TPoint;<BR> W:TWinControl;<BR>begin<BR> P.X
:= X;<BR> P.Y := Y;<BR> W :=
FindVCLWindow(P); //得到鼠标指针下的VCL可视组件<BR> if (
nil <> W )
then<BR> begin<BR> while
w.Parent<>nil do
//当W的上级Parent不为空时就继续往上找<BR> w:=w.Parent;
<BR> Result :=
W.Name;//最后返回窗体的名称Name<BR> end<BR> else<BR> begin<BR> Result
:=
'';<BR> end;<BR>end;<BR><BR><BR><BR><BR>procedure
TForm1.Timer1Timer(Sender:
TObject);<BR>var<BR> winPos:TPoint;<BR>begin<BR> GetCursorPos(winpos); //得到当前鼠标指针的在屏幕上的坐标<BR> <BR> //当鼠标指针下的窗体的Name等于form1.name时<BR> if
form1.name=GetFormNameAt(winpos.X,winpos.Y)
then<BR> {在此我们可以为form1取一个特别的名称,以防有别的窗体名称与它相同}<BR> begin<BR> form1.Timer2.Enabled:=false;
//停用Timer2<BR> form1.Top:=0; //form1的Top与屏幕对齐<BR> end<BR> else<BR> form1.Timer2.Enabled:=true;
//开启Timer2<BR>end;<BR><BR><BR><BR>procedure
TForm1.Timer2Timer(Sender:
TObject);<BR>begin<BR> if form1.Top<=20
then<BR> form1.Top:=-(form1.Height-10);//将form1向上移,在屏幕上方露出10像素<BR>end;
<BR><BR>
<P align=right>【<A
href="http://www.programfan.net/comment.asp?id=2430">对此文发表评论</A>】 【<A
href="http://www.programfan.net/club">编程爱好者论坛</A>】 【<B><A
href="http://www.programfan.net/ad/ad.asp?id=12"
target=_blank>Borland专题讨论区</A></B>】 【<A
href="javascript:window.close()">关闭窗口</A>】<BR></P></TD></TR></TBODY></TABLE></DIV></CENTER></CENTER></TD></TR>
<TR>
<TD height=237>
<P align=center><A
href="http://www.programfan.net/club"><B>[论坛]</B></A> <A
href="http://www.programfan.net/club/showbbs.asp?id=17608"
style="COLOR: #ff0000"><B>编程爱好者论坛回帖有奖活动</B></A><B><A
style="COLOR: #ff0000"> </A><A
href="http://www.programfan.net/club/expoint.asp"
style="COLOR: #ff0000">专家分排行榜</A><A
style="COLOR: #ff0000"> </A></B><BR><B><A
href="http://www.programfan.net/bookcd.asp"
title=编程书籍刻盘服务>[<STRONG>刻盘服务]</STRONG></A><FONT color=#0000ff><A
href="http://www.programfan.net/bookcd/msdn.htm"
style="COLOR: #ff0000">MSDN 系列光盘</A></FONT></B> <A
href="http://www.programfan.net/ad/ad.asp?id=9"
style="COLOR: #ff0000"><B>编程爱好者光盘第一期</B></A><A
href="http://www.programfan.net/ad/ad.asp?id=9"
style="COLOR: #ff0000"><B><BR></B></A><A
href="http://www.programfan.net/upload">编程爱好者网站推出文件交流服务</A> <BR><A
href="http://www.programfan.net/ad/ad.asp?id=13"
style="COLOR: #ff0066" target=_blank>站长尊容首次亮相,大家要看的快来看啊!</A><BR><A
href="http://www.programfan.net/club/bbs.asp?bbsid=53"
style="COLOR: #ff0000"
target=_blank>新增二手书籍交流栏目,让你多余的编程书籍发挥余热</A><BR><A
href="http://www.programfan.net/download.asp">[编程工具]</A><B> </B><A
href="http://www.programfan.net/downcolumn.asp?id=1"
style="COLOR: #ff0000">经典编程工具系列 </A><BR><A
href="http://www.programfan.net/job.asp">全新推出招聘求职,为您提供人才交流的平台。</A>
<CENTER>
<P align=center><A href="http://www.programfan.net/club"
target=_blank><IMG border=0
src="实现QQ窗体的缩入伸出功能—编程爱好者网站http--www_programfan_com.files/ad1.gif"></A></P>
<DIV align=center>
<TABLE border=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD vAlign=top width="50%">
<DIV align=center>
<TABLE border=1 borderColorDark=#ffffff
borderColorLight=#000000 cellPadding=0 cellSpacing=0
width="95%">
<TBODY>
<TR>
<TD bgColor=#99ccff height=20 width="100%">
<P align=center><STRONG>本 栏 热 门 文 章</STRONG></P></TD></TR>
<TR>
<TD width="100%"><FONT style="LINE-HEIGHT: 150%"><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=526">delphi函数参考手册</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2361">变速齿轮Delphi实现</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=1858">Delphi编程技巧集锦</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=1888">Delphi中预想不到的代码</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2157">用Delphi编程访问SQLServer数据库</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=1737">一个完整身份证效验程序</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=794">用Delphi发送SMS(手机短消息服务)</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=1844">使用Delphi对手机通讯的编程</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=1436">五子棋源代码</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2069">用好Delphi的打印技能的编程技巧</A><BR></FONT></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="50%">
<DIV align=center>
<TABLE border=1 borderColorDark=#ffffff
borderColorLight=#000000 cellPadding=0 cellSpacing=0
width="95%">
<TBODY>
<TR>
<TD bgColor=#99ccff height=20 width="100%">
<P align=center><STRONG>本 栏 最 新 文 章</STRONG></P></TD></TR>
<TR>
<TD width="100%"><FONT style="LINE-HEIGHT: 150%"><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2436">隐藏我的电脑中驱动器</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2437">Delphi开发基于DCOM的聊天室</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2431">Delphi
for Linux中应用共享对象库</A><BR><FONT color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2430">实现QQ窗体的缩入伸出功能</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2426">Delphi图像存取另类解决方案</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2423">Delphi8
for Microsoft&reg; .NET与Delphi 7的区别</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2412">DELPHI的通配符比较</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2409">QQ尾巴病毒的发送原理分析</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2408">利用语音Modem实现电话点播和留言功能</A><BR><FONT
color=#ff0000>● </FONT><A
href="http://www.programfan.net/showarticle.asp?id=2407">在工作组中寻找所有的计算机</A><BR></FONT></TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE></DIV></CENTER></TD></TR></TBODY></TABLE></DIV></CENTER></TD></TR></TBODY></TABLE></DIV>
<DIV align=center>
<CENTER>
<TABLE border=0 cellPadding=0 cellSpacing=1 width=755>
<TBODY>
<TR>
<TD width="100%">
<HR color=#ff0000 noShade SIZE=1>
<P align=center><A href="http://www.programfan.net/intro.asp">网站简介</A> -
<A href="http://www.programfan.net/daohang.asp">网站导航</A> - <A
href="http://www.programfan.net/ad.asp">广告服务</A> - <A
href="http://www.programfan.net/joinus.htm">诚邀加盟</A> - <A
href="http://www.programfan.net/contact.asp?subject=关于网站">联系站长</A> -
<A href="http://www.programfan.net/link.htm">友情链接</A><BR>Copyright©
1999-2004 Programfan.com. All Rights Reserved<BR>网站制作&维护:Hannibal
QQ:
15987743</P></TD></TR></TBODY></TABLE></CENTER></DIV>
<SCRIPT
src="实现QQ窗体的缩入伸出功能—编程爱好者网站http--www_programfan_com.files/counter.htm"></SCRIPT>
</CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -