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
Printable View
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
You can't move a sub :)
Move a form instead (without Title bar)
Have fun :)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
oopss, sotty guys, I did a mistake! Moving a form!
hehe No problem mate, I understood that :)
Actually you can move a sub just cut and paste :) *LOL*
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
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
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
Maybe I read it wrong, but isn't that what HeSaidJoe was referring to?
If you want to move the form using a PictureBox or Label than you just keep it as Me.Quote:
Then the form only moves via thepicture and
not the form...
As I understand, he wanted to use a PictureBox to simulate a TitleBar, hence, changing Form_(EventName) to Picture1_(EventName) should do it.