Is there a way to move a form without showing it outline? (Not using Windows to change anything.)
Printable View
Is there a way to move a form without showing it outline? (Not using Windows to change anything.)
Ok, here's what I mean:
But it's not working the way I want it to.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
When you move your mouse over the form, it goes to the bottom.
Can anyone fix it?
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
I found a much better code. One that is exactly what I was looking for.
Thanks anyway. :)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