|
-
Dec 10th, 2009, 07:25 PM
#1
Thread Starter
Member
[RESOLVED] Moving a Borderless form
I am making a project where the borderstyle of the form is 0. how do i make it move with a label and it it called label1
EDIT: Resolved!
Last edited by young.dragon; Dec 10th, 2009 at 07:41 PM.
Reason: Resolved
-
Dec 10th, 2009, 07:38 PM
#2
Re: Moving a Borderless form
Heres 3 ways to do that,
' Using APIs
Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Sub Label1_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&
' note code continues here on mouse up.
End If
End Sub
' Using VB code only #1
Code:
Option Explicit
Private lngX As Long
Private lngY As Long
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
lngX = X
lngY = Y
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then Me.Move Me.Left + X - lngX, Me.Top + Y - lngY
End Sub
' Using VB code only #2
Code:
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then Label1.Tag = X & "|" & Y
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1_MouseMove Button, Shift, X, Y
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lngLeft As Long, lngTop As Long, sngX As Single, sngY As Single
If Button = vbLeftButton And LenB(Label1.Tag) Then
sngX = Split(Label1.Tag, "|")(0)
sngY = Split(Label1.Tag, "|")(1)
lngLeft = Me.Left + X - sngX
lngTop = Me.Top + Y - sngY
Me.Move lngLeft, lngTop
End If
End Sub
Last edited by Edgemeal; Dec 12th, 2009 at 06:24 PM.
Reason: condensed to single response
-
Dec 10th, 2009, 07:40 PM
#3
Thread Starter
Member
Re: Moving a Borderless form
Thank you!
-
Dec 10th, 2009, 08:01 PM
#4
Re: Moving a Borderless form
 Originally Posted by young.dragon
Thank you! 
Here's yet another way, VB code only...
Code:
Code moved to post #2.
Last edited by Edgemeal; Dec 12th, 2009 at 06:25 PM.
-
Dec 11th, 2009, 04:41 AM
#5
PowerPoster
Re: Moving a Borderless form
Also set the Form property to this:
Code:
Form1.Moveable = True
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Dec 11th, 2009, 06:41 AM
#6
Re: Moving a Borderless form
If this is solved to your satisfaction, could you please do us a little favour, and mark the thread as Resolved? (editing the first post to add that word is far from obvious)
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).
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
|