|
-
Sep 12th, 2002, 07:58 PM
#1
Thread Starter
Member
Make a label control the window
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.
"We can't solve problems by using the same kind of thinking we used when we created them."
-Albert Einstein
-
Sep 12th, 2002, 08:06 PM
#2
Frenzied Member
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
-
Sep 12th, 2002, 08:12 PM
#3
Frenzied Member
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
-
Sep 13th, 2002, 01:44 AM
#4
Thread Starter
Member
Hey, thanks...also..
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.
"We can't solve problems by using the same kind of thinking we used when we created them."
-Albert Einstein
-
Sep 13th, 2002, 02:45 AM
#5
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
-
Sep 13th, 2002, 03:49 AM
#6
Thread Starter
Member
Ace
hey thanks for those, they both worked like a charm...
"We can't solve problems by using the same kind of thinking we used when we created them."
-Albert Einstein
-
Sep 13th, 2002, 04:27 AM
#7
Frenzied Member
Re: Hey, thanks...also..
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.
I told ya can also use a picture box
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|