我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb点虐 窗体自动隐藏 vbs隐藏cmd窗口

vb程序设计中,如何实现窗口像QQ那样自动隐藏功能!

这很简单, 窗体无边框,你只要用API判断一下鼠标所在位置是不是在屏幕边,是再显示窗体即可,否则窗体高度为20就是一条线.

目前创新互联已为千余家的企业提供了网站建设、域名、网页空间、网站托管、企业网站设计、绵阳网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

最早的时候有个叫东方快车的软件是这样的,后来,我也做了一个和他一样的,不过好久没用这个API,一下想不起来了.你可以搜一下.

帮你做了一个

label1,timer1自己加一个,窗体BorderStyle=0

Option Explicit

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Type POINTAPI

X As Long

Y As Long

End Type

Dim p As POINTAPI

Private Enum emL

none = 0

Top = 1

Left = 2

Right = 3

End Enum

Dim pWhere As emL

Private onMove As Boolean, AutoHide As Boolean

Private iX As Single

Private iY As Single

Private blShow As Boolean

Private blIn As Boolean

Private myH As Single, myW As Single

Private Sub Form_Load()

myH = Me.Height

myW = Me.Width

Me.Label1.Move 0, 0, Me.ScaleWidth

Me.Timer1.Interval = 5

Me.Timer1.Enabled = True

End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

iX = X

iY = Y

onMove = True

End Sub

Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

onMove = False

End Sub

Private Sub Timer1_Timer()

GetCursorPos p

p.X = p.X * Screen.TwipsPerPixelX

p.Y = p.Y * Screen.TwipsPerPixelY

If AutoHide Then

If ((p.X 100 And pWhere = Left) Or (p.Y 100 And pWhere = Top) Or (Screen.Width - p.X 100 And pWhere = Right)) Or _

(p.X Me.Left And p.X Me.Width + Me.Left And p.Y Me.Top And p.Y Me.Top + Me.Height) Then

If Not blIn Then

blIn = True

Me.Height = myH

Me.Width = myW

If pWhere = Right Then Me.Left = Screen.Width - Me.Width

End If

Else

If blIn Then

blIn = False

Select Case pWhere

Case emL.Left

Me.Width = 20

Case emL.Right

Me.Width = 20

Me.Left = Screen.Width - 30

Case emL.Top

Me.Height = 20

Case Else

End Select

End If

End If

End If

If onMove Then

Me.Top = p.Y - iY

Me.Left = p.X - iX

If Me.Left 100 Then

pWhere = Left

AutoHide = True

Me.Left = 0

ElseIf Screen.Width - Me.Left - Me.Width 100 Then

Me.Left = Screen.Width - Me.Width

pWhere = Right

AutoHide = True

Else

If Me.Top 100 Then

Me.Top = 0

AutoHide = True

pWhere = Top

Else

AutoHide = False

Me.Width = myW

Me.Height = myH

End If

End If

End If

End Sub

VB.NET 窗体内的一个Panel容器失去焦点就自动隐藏

Public Class Form3 按下,显示控件,并获得焦点. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Visible = True TextBox1.Focus() End Sub 判断是否获得焦点. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If TextBox1.Focused = True Then MessageBox.Show("已经获得焦点了.") Else MessageBox.Show("已经失去焦点了.") End If End Sub 失去焦点后自动陷藏. Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus TextBox1.Visible = False End Sub End Class

如何让VB窗体靠边时窗体自动隐藏

计算TOP

left值

可以判断是否顶端,左侧。

加上高和宽即可判断是否在下端和右侧。

若当窗体靠近边界在50以内,则处理窗体进行到隐藏。也就是将窗体移出界面。只保留50在外面。当鼠标移动时将窗体展开即可。


网站题目:vb点虐 窗体自动隐藏 vbs隐藏cmd窗口
本文URL:http://shouzuofang.com/article/ddicjgp.html

其他资讯