PDA

Click to See Complete Forum and Search --> : moving windows w/o title bar


rboxnick
Jan 9th, 2000, 09:13 PM
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

Chuck Sweet
Jan 9th, 2000, 09:57 PM
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.

Aaron Young
Jan 9th, 2000, 10:59 PM
Add a Picturebox to the Form..

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
aarony@redwingsoftware.com
ajyoung@pressenter.com

rboxnick
Jan 10th, 2000, 02:41 AM
hot damn, well that was just too easy, thanks guys!

Frans C
Jan 11th, 2000, 11:43 AM
If you don't want to use a picturebox, you can use this:

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