| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 661 人关注过本帖
标题:隐藏窗体
只看楼主 加入收藏
naiq
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2005-4-4
收藏
 问题点数:0 回复次数:1 
隐藏窗体
如何用VB设计一个可以像QQ一样隐藏在屏幕上端的应用程序,请教大虾。
搜索更多相关主题的帖子: 窗体 隐藏 
2005-04-05 14:54
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 

'类似QQ的自动隐藏窗体 'By:griefforyou Option Explicit

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2

Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Const SWP_SHOWWINDOW = &H40

Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type

Private Type POINTAPI x As Long y As Long End Type

Dim HideFlag As Boolean Dim WindowRect As RECT Dim MousePos As POINTAPI

Private Sub Check1_Click() If Check1.Value = 1 Then SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Else SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE End If End Sub

Private Sub Check2_Click() Timer1.Enabled = Check2.Value End Sub

Private Sub Form_load() Check1.Value = 1 Check2.Value = 1 Timer1.Interval = 500 HideFlag = True Me.Top = -Me.Height + 30 End Sub

Private Sub Timer1_Timer() If Me.WindowState > 0 Then Exit Sub GetWindowRect Me.hwnd, WindowRect GetCursorPos MousePos If MousePos.x >= WindowRect.Left And MousePos.x <= WindowRect.Right And _ MousePos.y >= WindowRect.Top And MousePos.y <= WindowRect.Bottom Then If HideFlag = True Then Me.Top = -15 HideFlag = False End If Else If WindowRect.Top < 5 Then Debug.Print WindowRect.Top Me.Top = -Me.Height + 15 HideFlag = True End If End If End Sub


天津网站建设 http://www./
2005-04-05 15:55
快速回复:隐藏窗体
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023595 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved