.如果真 (到整数 (_启动窗口.左边团春咐) > 到整数 (取鼠标水平位置 ()) 或 到整数 (取鼠标水平位置 ()) > 到整数 (_启动窗口.左边 + _启动窗口.宽度) 或 到整数 (取鼠标垂直位置 ()) > 到整数 (_启动窗口.顶边 + _启动窗口.高度))
_启动窗口.顶边 = _启动窗口.顶边 - 30
.如果真 (_启动窗口.顶边 + _启动窗口.高度 ≤ 10)
_启动窗口.顶边 = 3 - _启动窗口.高度
时钟1.时钟周期 = 0
时钟2.时钟周期 = 1
.如果真结束.如果真结束.如果真结束 .子程序 _时钟2_周期事件.如果真 (取森岁鼠标垂直位置 () ≤ 5)
.如果真 (到整数 (取鼠标水平位置 ()) > 到整数 (_启动窗口.左边) 且 到整数 (取鼠标水塌纯平位置 ()) < 到整数 (_启动窗口.左边 + _启动窗口.宽度))
_启动窗口.顶边 = _启动窗口.顶边 + 30
.如果真 (_启动窗口.顶边 ≥ -10)
_启动窗口.顶边 = 0
时钟1.时钟周期 = 1
时钟2.时钟周期 = 0
.如果真结束.如果真结束.如果真结束
.子程序 __启动窗口_创建完毕时钟1.时钟周期 = 1
但无边框的直接调节大小,目前我还不能实现。
xh=me.height, xw=me.width, X=10上,左:窗体<=X,窗体向上(top=xh-xh+X)或左移动;
右、下:窗体与屏幕判断比较,当屏幕宽-(窗体左+宽)<=X,右移;屏幕高-(窗体上+高)<=X,下移
然后鼠标指向窗体后拉出窗体,
有些得加些API函数用于检测鼠标移入移出,窗体置顶,窗体也不能是普通类型的,有些难度,你也可以烂银自己在网上找找看更好的。新建工程,将窗体的BorderStyle设置为0,再加入一个Command按钮,粘贴以下代码测试
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)
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Dim nX As Single, nY As Single
Private Sub Command1_Click()
SetWindowPos Me.hwnd, -2, 0, 0, 0, 0, 3
Unload Me
End Sub
Private Sub Form_Load()
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
nX = X: nY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Me.Move Me.Left - nX + X, Me.Top - nY + Y
Me.Caption = Me.Top
End If
Dim pW!, pH!, mL!, mT!, mW!, mH!
pW = Screen.Width
pH = Screen.Height
mL = Me.Left
mT = Me.Top
mW = Me.Width
mH = Me.Height
Const m = 50
Dim MouseEnter As Boolean
MouseEnter = (0 <= X) And (X <= mW) And (0 <= Y) And (Y <= mH)
If MouseEnter Then '进入
If mL <= m Then Me.Left = -m
If mT <= m Then Me.Top = -m
If mL >= pW - m Then Me.Left = pW - mW
If mT >= pH - m Then Me.Top = pH - mH
SetCapture Me.hwnd
Else '移出
If mL <= m Then Me.Left = m - mW '左隐
If mT <= m Then Me.Top = m - mH '上隐
If pW - mL - mW <= m Then Me.Left = pW - m '右隐
If pH - mT - mH <= m Then Me.Top = pH - m '下悄历迹隐
ReleaseCapture
End If
End Sub这样设启并定以后你的窗口可以自由移动,在靠边时可以也像QQ一样自动隐藏。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)