borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincani
:: Move a non-caption form using no API, no DLL

Author  

Umberto Sciarretta

Language  

VB5, VB6

Operating Systems  

Windows 95, 98 and NT
Module

' Move a non-caption form using no API, no DLL
' By U.Sciarretta
' umb.1@reteitalia.net

' paste the following code in a module
' and call it from the mousemove routine of the form
' that you like to move as: mousemove [form.name],x,y,button
' drag the form to move it
' use same calling code if you need to move the form dragging over
' a control in the form (pay attention to click_routine potential
' conflict)


Sub moveform(ff As Form, xx, yy, bt)
    Static oldx, oldy, mf
    Dim moveleft, movetop

    moveleft = ff.Left + xx - oldx
    movetop = ff.Top + yy - oldy
    If bt = vbLeftButton Then
        If mf = 0 Then
            ff.Move moveleft, movetop
            ff.Refresh
            mf = 1
        Else
            mf = 0
        End If
    End If
    oldx = xx
    oldy = yy
End Sub

Usage

'Usage:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    moveform Me, X, Y, Button
End Sub

:: Navigation

Home

Form Tips

Previous Tip

Next Tip

:: Search this site
Google
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder