|
-
Sep 16th, 2000, 08:07 AM
#1
Thread Starter
Hyperactive Member
How can I move a sub without a title bar like a skin form.
----------------
ICQ:65287451
AIM:MBR5520
http://www.sx3k.le-site.net
[email protected]
Running VB5 Enterprise Edition
-
Sep 16th, 2000, 08:11 AM
#2
Frenzied Member
You can't move a sub 
Move a form instead (without Title bar)
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 Sub ReleaseCapture Lib "User32" ()
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngReturnValue As Long
'// Detect the left mouse button
If Button = 1 Then
'// Release the capture of the mouse
Call ReleaseCapture
'// Move the form with the mouse
lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, _
HTCAPTION, 0&)
End If
End Sub
Have fun
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 16th, 2000, 08:12 AM
#3
Thread Starter
Hyperactive Member
oopss, sotty guys, I did a mistake! Moving a form!
-
Sep 16th, 2000, 08:17 AM
#4
Frenzied Member
hehe No problem mate, I understood that
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 16th, 2000, 08:46 AM
#5
Actually you can move a sub just cut and paste *LOL*
-
Sep 16th, 2000, 10:31 AM
#6
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_SYSCOMMAND = &H112
Private Const SC_MOVE = &HF012
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_SYSCOMMAND, SC_MOVE, 0
End Sub
-
Sep 16th, 2000, 10:51 AM
#7
Or to move it without any API:
Code:
Dim oldX As Long, oldY As Long, isMoving As Boolean
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
oldX = X
oldY = Y
isMoving = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If isMoving Then
Me.Top = Me.Top - (oldY - Y)
Me.Left = Me.Left - (oldX - X)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
isMoving = False
End Sub
-
Sep 16th, 2000, 11:30 AM
#8
No, that will not work. If you change Me to Picture1, you will be moving the PictureBox, not the Form. In this case, simply place the events in a the PictureBox instead of the Form.
Code:
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
oldX = X
oldY = Y
isMoving = True
End Sub
-
Sep 16th, 2000, 11:36 AM
#9
Maybe I read it wrong, but isn't that what HeSaidJoe was referring to?
Then the form only moves via thepicture and
not the form...
If you want to move the form using a PictureBox or Label than you just keep it as Me.
-
Sep 16th, 2000, 11:45 AM
#10
As I understand, he wanted to use a PictureBox to simulate a TitleBar, hence, changing Form_(EventName) to Picture1_(EventName) should do it.
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
|