Does anyone know how to make a label on a form act as the control to move the window around...That is, when the left mouse button is down on the label, you can drag the form around the screen.
Thanks.
Printable View
Does anyone know how to make a label on a form act as the control to move the window around...That is, when the left mouse button is down on the label, you can drag the form around the screen.
Thanks.
As the label doesn't have the Hwnd property. i am afraid it is not possible.. yes u can do one thing
Set the borderstyle property of Textbox to None.. Appearance to Flat and color to ButtonFace..(Gray) then you can use SendMessage to do what you want.. tell me if this textbox thingy is acceptable
Don't forget to set the mousepointer property to Arrow (1)
VB Code:
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 Declare Function ReleaseCapture Lib "user32" () As Long Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 Private Sub Form_Load() End Sub Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then ReleaseCapture SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 End If End Sub
Thanks for that one.
It works like a charm, but do you know how to remove the cursor that blinks with it?, because it's still flashing.
Thanks.:D
Here's another way to do it without using the API
VB Code:
Option Explicit Private MbMov As Boolean Private PrevX As Long Private PrevY As Long Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) MbMov = True PrevX = X PrevY = Y End Sub Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If MbMov Then Me.Move (Me.Left + X - PrevX), (Me.Top + Y - PrevY) End If End Sub Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) MbMov = False End Sub
hey thanks for those, they both worked like a charm...:D
I told ya can also use a picture boxQuote:
Originally posted by jontyrules
Thanks for that one.
It works like a charm, but do you know how to remove the cursor that blinks with it?, because it's still flashing.
Thanks.:D