[RESOLVED] Moving Borderless Form..
Hello.
I'm using the following code to move borderless that contains an image as its title bar.
vb Code:
Private Sub ImgBanner_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = 15
Dim IX As Integer, IY As Integer
IX = X
IY = Y
End Sub
Private Sub ImgBanner_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Me.Top = X - IY
Me.Left = X - IX
End If
End Sub
Private Sub ImgBanner_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = 0
End Sub
But, as the mouse is moved, the pointer goes to the top-left corner. I want it remain at same place where it was clicked.
Re: Moving Borderless Form..
Use Option Explicit.
IY and IX are declared in MouseDown event, so those settings are not saved/used in the MouseMove event, so they become 0 & 0. If you have IY and IX declared in the Declarations section, remove the declarations in MouseDown; else move them from MouseDown to the Declarations section.
Re: Moving Borderless Form..
thanks... it works fine... now I want to make an entry in registry.. how can i go for it??
Re: Moving Borderless Form..
You're welcome. See this FAQ topic regarding the registry
Re: Moving Borderless Form..
Re: Moving Borderless Form..
One more simple way to do this using API. You don't need the ImgBanner_MouseMove or the ImgBanner_MouseUp event :)
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 Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const WM_SYSCOMMAND = &H112
Private Sub ImgBanner_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Re: Moving Borderless Form..
The problem with that is if he is using a true VB Image control then it does not have an .hWnd property.
Re: Moving Borderless Form..
Hack, if you mean the Image1 control then the above code that I gave will work for it as well...
Re: Moving Borderless Form..
thanks guys... but my method for now works well... if any problem persists futhrer, i will prefer your idea...
thanks any way..