UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Moving a none borderstyle form with the mouse    
 
   
Ernesto
post Jan 10 2006, 08:19 PM
Post#1



Posts: 129
Joined: 21-March 03
From: Argentina - Tucuman Province


This is the way I've found for moving a form with the mouse, when the form borderstyle property is set to none. Of course, the moveable property of the form must be set in yes.
form with none borderstyle doesn't have a 'control box' (which usually contains the min, max and close buttons, the title bar, and that let us move the form just left clicking with the mouse), but it´s possible to 'substitute' it with the use of other objects (as a rectangle, a line, an image or other form objects) and its mousedown event or click event.
In a form view, that 'substitution' will allow us to:
1) Select the form with the mouse from its actual position in the screen
2) Drag the form to the next position in the screen
In the code, in the form object mousedown event or click event, we have to use the sendkeys instruction and the DoCmd object with the runcommand method, as follows:
Private Sub rectangle1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = acLeftButton Then
'using both sendkeys instructions we avoid a little displacement of the form
SendKeys "{UP}"
SendKeys "{DOWN}"
'the four-headed arrow will indicate that we could drag the form
Screen.MousePointer = 3
DoCmd.RunCommand acCmdDocMove
'once we drop the form, the pointer will return to its original look
Screen.MousePointer = 0
End If
End Sub
Using the same code with the click event, causes that the form remains attached with the mouse pointer until we do another click.
The code has been proved in access 2000 and access xp, and it worked fine.
I hope this solution could be useful for those who are begining with access, or don't know how to do it.
If someone knows a more simple solution, please let me know it.
Ernesto
Attached File(s)
Attached File  MoveNoneBorderForm.zip ( 31.27K )Number of downloads: 381
 
Go to the top of the page
 
Cyberjudge
post Sep 23 2019, 08:48 PM
Post#2



Posts: 1
Joined: 23-September 19



Thank you
Go to the top of the page
 
isladogs
post Sep 23 2019, 11:13 PM
Post#3


UtterAccess VIP
Posts: 1,893
Joined: 4-June 18
From: Somerset, UK


This is certainly an ancient thread resurrected. from the dead.
A borderless form can be dragged to a new position using a MouseDown event without using SendKeys.

Place the following in a standard module
CODE
Option Compare Database
Option Explicit

'API to move a form with a mouse down event

Public Const WM_NCLBUTTONDOWN = &HA1

Public Const HT_CAPTION = &H2

#If VBA7 Then
    Public 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
    
    Public Declare PtrSafe Function ReleaseCapture Lib "user32.dll" () As Long
#Else
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
        ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    
    Public Declare Function ReleaseCapture Lib "user32.dll" () As Long
#End If


Then in your form add code like this to any part of the form you want to control dragging.
For example, using the Form header

CODE
Private Sub FormHeader_MouseDown(B
utton As Integer, Shift As Integer, X As Single, Y As Single)
   X = ReleaseCapture()
   X = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End Sub


The same code can also be applied to other objects such as a button or label

The attached example includes this feature and much more

You can find more information about this example application here Control the Application Interface
Attached File(s)
Attached File  SetWindows___v3.44.zip ( 311.82K )Number of downloads: 20
 

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    11th December 2019 - 03:59 AM