|
-
Jun 16th, 2010, 10:22 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Jun 16th, 2010, 10:29 AM
#2
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.
-
Jun 16th, 2010, 10:32 AM
#3
Thread Starter
Hyperactive Member
Re: Moving Borderless Form..
thanks... it works fine... now I want to make an entry in registry.. how can i go for it??
-
Jun 16th, 2010, 10:34 AM
#4
Re: Moving Borderless Form..
You're welcome. See this FAQ topic regarding the registry
-
Jun 16th, 2010, 10:45 AM
#5
Thread Starter
Hyperactive Member
Re: Moving Borderless Form..
-
Jun 16th, 2010, 11:08 AM
#6
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
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 16th, 2010, 11:16 AM
#7
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.
-
Jun 16th, 2010, 11:58 AM
#8
Re: Moving Borderless Form..
Hack, if you mean the Image1 control then the above code that I gave will work for it as well...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 16th, 2010, 11:17 PM
#9
Thread Starter
Hyperactive Member
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..
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
|