Make a form moveable...

Nightowl4933

Tryin' to do it right...
Local time
Today, 06:41
Joined
Apr 27, 2016
Messages
151
I didn't want to, but have now decided to make the forms in my database 'moveable', but I was wondering if there's a way of doing this without the form's caption being visible (i.e. when setting the border to 'Thin').

I appreciate I can make use a space " " to hide the form's name, but this leaves a wide bar across the top of the form, and the design makes this not look right.

Thank you,

Pete
 

Attachments

  • Screen Shot 2016-06-14 at 09.41.49.png
    Screen Shot 2016-06-14 at 09.41.49.png
    54.7 KB · Views: 119
copy the code in a new module.
you can set your form's Border Style to Thin or None.
on the form's Detail Section MouseDown Event, call the function:

Private Sub Detail_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
fDragWindow Me
End Sub

Code:
'
' arnelgp
' just for you my friend
'
Option Compare Database
Option Explicit
#If Win64 Then
Private Declare PtrSafe Function ReleaseCapture Lib "user32" () As Long
#Else
Private Declare Function ReleaseCapture Lib "user32" () As Long
#End If
#If Win64 Then
Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" ( _
            ByVal hwnd As LongPtr, _
                ByVal wMsg As Long, _
                    ByVal wParam As LongPtr, _
                        lParam As Any) As LongPtr
#Else
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


#End If
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2

Public Function fDragWindow(frm As Access.Form)

    With frm
        
        ReleaseCapture
        SendMessage .hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
    
    End With

End Function
 
Hi arnelgp,

Did as you suggested, but loads of the text has gone red, so have I copied it incorrectly?

Thanks,

Pete
 
if you have office x64 the #else part will go red, that's ok.
 

Users who are viewing this thread

Back
Top Bottom