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ä¸æ ·èªå¨éèã
温馨提示:内容为网友见解,仅供参考