Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / October 2004



Tip: Looking for answers? Try searching our database.

Form Move

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sharrukin Amiri - 29 Oct 2004 20:02 GMT
Hello,

How do you permit a client to move a form, with 'BorderStyle Property set to
none, in realtime?  Any guideline on how to do this?

Thanks!

Sharrukin
Tom Esh - 29 Oct 2004 17:52 GMT
>How do you permit a client to move a form, with 'BorderStyle Property set to
>none, in realtime?  Any guideline on how to do this?

Here's a popular method that works by using the Api to tell Windows a
mousedown has occurred on the titlebar. Works even if it has no
titlebar (providing you have not set the form's Moveable prop to
False).

'declaration section...
Private Const WM_NCLBUTTONDOWN = &HA1&
Private Const HTCAPTION = 2&
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

'code....
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
    x As Single, y As Single)
   If Button = vbLeftButton Then
       ReleaseCapture
       SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
   End If
End Sub

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
J French - 30 Oct 2004 14:12 GMT
>Hello,
>
>How do you permit a client to move a form, with 'BorderStyle Property set to
>none, in realtime?  Any guideline on how to do this?

Option Explicit

Private Declare Function ReleaseCapture _
       Lib "user32" () As Long
Private Declare Function SendMessage _
       Lib "user32" _
       Alias "SendMessageA" _
       (ByVal hwnd As Long, _
        ByVal wMsg As Long, _
        ByVal wParam As Long, _
        ByVal lParam As Any) As Integer
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2

Public Sub MoveObject(hwnd As Long)
  ReleaseCapture
  SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub

Private Sub Form_MouseDown(Button As Integer, _
                          Shift As Integer, _
                          X As Single, _
                          Y As Single)
   MoveObject Me.hwnd
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.