Results 1 to 5 of 5

Thread: moving windows w/o title bar

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Willow Spring, NC, USA
    Posts
    7

    Post

    Is there a way to move a window by clicking somewhere else on the form, like on a picture or something, and not on the title bar? I'm pretty sure there is, i've seen other apps do it.
    thanks in advance

  2. #2
    Member
    Join Date
    Jan 2000
    Location
    Quantico, VA, USA
    Posts
    41

    Post

    Try this:

    When picture is clicked, get current mouse position( mousedown or mouseup event will give you these).

    on dragdrop event, get x&y values of mouse relative to last position.

    either add/subtract to x/y on form or use move method.

    i don't know if there's an easier way to do it or not. hope this helps a little.

    -chuck

    ------------------
    To err is human, but to apologize frequently is embarassing.

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Add a Picturebox to the Form..
    Code:
    Private oX As Single
    Private oY As Single
    
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            oX = X
            oY = Y
        End If
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then Move Left + (X - oX), Top + (Y - oY)
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Willow Spring, NC, USA
    Posts
    7

    Post

    hot damn, well that was just too easy, thanks guys!

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    If you don't want to use a picturebox, you can use this:
    Code:
    Option Explicit
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const HTCAPTION = 2
    Private Const WM_NCLBUTTONDOWN = &HA1
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Call ReleaseCapture
        Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width