|
-
Nov 15th, 2000, 10:02 PM
#1
Thread Starter
Hyperactive Member
I'd like to know how it would be possible to use a control (such as label) instead of a windows header bar (looks so dull). So how it would work is that you put your mouse over the label, mouse down, drag, and the window follows.
So if any of you know how to make this happen (preferrably without any special controls), I'd be very pleased.
Thanks in advance!
(These smilies are so cool !)
-JR-
-
Nov 15th, 2000, 10:43 PM
#2
Set the Form's BorderStyle to 0-None.
And add this in the label:
Code:
Dim prevX As Single, prevY As Single
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
prevX = X
prevY = Y
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Move Me.Left - (prevX - X), Me.Top - (prevY - Y)
End Sub
-
Nov 15th, 2000, 10:51 PM
#3
Thread Starter
Hyperactive Member
Thank you very much! I got it working! I'm not that familiar with all this so could you also give me a hint how to compensate with the original mouse position (like when you click the label with this code, the window snaps its left upper corner to the mouse location). This is of course just if you like have nothing else to do, you have already helped me a lot!
Thanks.
-
Nov 16th, 2000, 12:18 AM
#4
Taking another step ahead...
This code will snap it to the side of the screens (top,bottom,left,right).
Code:
Private Declare Sub ReleaseCapture Lib "user32" ()
Public 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 Sub FormMove(frm As Form)
ReleaseCapture
SendMessage frm.hwnd, &H112, &HF012, 0
frm.Refresh
If frm.Left < 0 Then 'left side of screen
frm.Left = 0
If frm.Top < 0 Then
frm.Top = 0
ElseIf frm.Top > Screen.Height - frm.Height Then
frm.Top = Screen.Height - frm.Height
End If
ElseIf frm.Top < 0 Then 'top of screen
frm.Top = 0
If frm.Left < 0 Then
frm.Top = 0
ElseIf frm.Left > Screen.Width - frm.Width Then
frm.Left = Screen.Width - frm.Width
End If
ElseIf frm.Left > Screen.Width - frm.Width Then 'right of screen
frm.Left = Screen.Width - frm.Width
If frm.Top < 0 Then
frm.Top = 0
ElseIf frm.Top > Screen.Height - frm.Height Then
frm.Top = Screen.Height - frm.Height
End If
ElseIf frm.Top > Screen.Height - frm.Height Then 'bottom of screen
frm.Top = Screen.Height - frm.Height
If frm.Left < 0 Then
frm.Top = 0
ElseIf frm.Left > Screen.Width - frm.Width Then
frm.Left = Screen.Width - frm.Width
End If
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call FormMove(Me)
End Sub
-
Nov 16th, 2000, 06:35 PM
#5
Thread Starter
Hyperactive Member
Thanks, already got it working!
And I might need those corner codes someday...
-JR-
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
|