|
-
Feb 6th, 2024, 01:42 PM
#1
Thread Starter
Lively Member
[VB6]. Move a Window by dragging from any part of it
Good morning. I want to share this simple code. It allows the user to move the window, by clicking and dragging, from any point on the Form.
The scrolling achieved is smooth and pleasant, just as if the click had been on the title bar.
With almost no code, it provides elegant functionality.
Also useful when the Window Title Bar is higher up the screen. In this case, the Form can be downloaded by fishing it from any point on it.
You can also make the call from the MouseMove Event of a Control Frame. In this case, clicking on it and dragging moves the Form.
You could even put it in the MouseMove Event of any particular control, achieving the same effect, moving the form to any part of the screen. [/B]
Please, if you implemented it, comment if you liked it or not. This is a translation from Spanish, sorry if the reading is not pleasant. Thank you
.
In each Form to move:
Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)FormMove Me, Button, X, Y End Sub
In a module:
Static Sub FormMove(Formulario As Form, Button As Integer, X As Single, Y As Single)Dim MemX As Single, MemY As Single, YaMovio As Boolean, AchFrm As Single AchFrm = Formulario.Width If Button = 1 Then If Not YaMovio Then YaMovio = True: MemX = X: MemY = Y Formulario.Left = Formulario.Left + X - MemX Formulario.Top = Formulario.Top + Y - MemY Else End If End Sub
Last edited by Tabi; Feb 9th, 2024 at 09:20 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|