Results 1 to 4 of 4

Thread: Mouse Contents?

  1. #1
    Guest
    Is there a way to move a form without showing it outline? (Not using Windows to change anything.)

  2. #2
    Guest
    Ok, here's what I mean:

    Code:
    Dim MousePress As Integer
    Dim MouseLocationX As Integer
    Dim MouseLocationY As Integer
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MousePress = 1
    MouseLocationX = X
    MouseLocationY = Y
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Me.Top = Me.Top + Y
        Me.Left = Me.Left + X
    End Sub
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MousePress = 0
    End Sub
    But it's not working the way I want it to.
    When you move your mouse over the form, it goes to the bottom.
    Can anyone fix it?

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Smile Try This

    Create a module and use put this code in it
    ---------------------------------------------
    Type POINTAPI 'Declare types
    x As Long
    y As Long
    End Type

    Declare Function GetCursorPos Lib "user32" _
    (lpPoint As POINTAPI) As Long 'Declare API

    ---------------------------------------------

    Put a new timer with interval=1 on your form and use this code:
    ---------------------------------------------

    Dim MousePress As Integer
    Dim MouseLocationX As Integer
    Dim MouseLocationY As Integer

    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    MousePress = 1
    MouseLocationX = x
    MouseLocationY = y
    End Sub


    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    MousePress = 0
    End Sub

    Private Sub Timer1_Timer()
    Dim z As POINTAPI
    If MousePress = 1 Then
    GetCursorPos z
    Me.Top = z.y * 10
    Me.Left = z.x * 10
    End If
    End Sub

    ---------------------------------------------

    I did not fool around with using pixels and stuff, that is
    why the *10 is in there. You can mess around with is and probably get it right.

    Hope this helps

  4. #4
    Guest
    I found a much better code. One that is exactly what I was looking for.

    Code:
    Option Explicit
    
    Private Declare Function SystemParametersInfo Lib "User32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
    Private Const SPI_SETDRAGFULLWINDOWS = 37
    
    Function SetWindowsDragStyle(ByVal FullDrag As Boolean) As Long
    Call SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, CLng(FullDrag), 0&, 0)
    SetWindowsDragStyle = Err.LastDLLError
    End Function
    
    The function SetWindowsDragStyle takes one parameter, FullDrag, which should be True to set drag style to full window, or False to set it to outline only. The function returns zero on success, or an API Error Number on failure (which would be equal to one of the ERROR_WHATEVER constants).
    
    
    Dim BeginX as Single
    Dim BeginY as Single
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    BeginX = X
    BeginY = Y
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
    Move ScaleX(X - BeginX, ScaleMode, vbTwips) + Left, ScaleY(Y - BeginY, ScaleMode, vbTwips) + Top 'If you multiple forms you want to move with one form, use this code to move them with respect to the form this code is in: FormName.Move Left + Width, Top
    End If
    End Sub
    Thanks anyway.

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