vb如何使自定义控件自动调整大小? 当鼠标在控件上时,控件变大,鼠标移出后变小。
要考虑控件不能超出窗体,默认向下、向右变大,可能超出时,应向左、向上变大。默认条件窗体有足够的空间容纳控件。...
要考虑控件不能超出窗体,默认向下、向右变大,可能超出时,应向左、向上变大。
默认条件窗体有足够的空间容纳控件。 展开
默认条件窗体有足够的空间容纳控件。 展开
展开全部
设置控件的宽高就可以了
更多追问追答
追问
如果你懂,说详细点;不懂的话,不要浪费彼此的时间。
追答
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Command1
If (X .Width) Or (Y > .Height) Then
ReleaseCapture
.Width = 800
.Height = 400
Else
SetCapture .hWnd
.Width = 1000
.Height = 500
End If
End With
End Sub
Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Command2
If (X .Width) Or (Y > .Height) Then
ReleaseCapture
.Width = 800
.Height = 400
Else
SetCapture .hWnd
.Width = 1000
.Height = 500
End If
End With
End Sub
展开全部
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static i As Integer
If X >= 0 And X < Command1.Width And Y >= 0 And Y <= Command1.Height Then
SetCapture Command1.hwnd
If i = 0 Then '第一次进入才变大
Command1.Width = Command1.Width * 1.5
Command1.FontBold = True
i = 1
End If
Else
i = 0
Command1.Width = Command1.Width / 1.5
Command1.FontBold = False
ReleaseCapture
End If
End Sub
'其余那些位置的代码自己考虑哈,我就给你写了一点移进移出时的代码
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static i As Integer
If X >= 0 And X < Command1.Width And Y >= 0 And Y <= Command1.Height Then
SetCapture Command1.hwnd
If i = 0 Then '第一次进入才变大
Command1.Width = Command1.Width * 1.5
Command1.FontBold = True
i = 1
End If
Else
i = 0
Command1.Width = Command1.Width / 1.5
Command1.FontBold = False
ReleaseCapture
End If
End Sub
'其余那些位置的代码自己考虑哈,我就给你写了一点移进移出时的代码
追问
收缩时要回到原来的位置
追答
那个代码就会自动收缩回到原来的位置啊。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询