Hi Howard,
Thanks for your feedback. I started to understand that you want to set the
Access program window size and remove the resize control (Minimize button
and Maximize button) for this window? If I have misunderstood, please feel
free to let me know.
Based on my research, I tested the following codes on my side with
SetWindowLong function and GetWindowLong function. It should help you a lot.
1. Start Microsoft Access, and then open any database file or a project
file.
2. Create a new module.
3. Type or paste the following code in the module:
'====================================
' Global Declarations
'====================================
Option Compare Database
Option Explicit
'NOTE: The following "Declare" statement is case sensitive.
Declare Sub SetWindowPos Lib "user32" (ByVal hwnd&, _
ByVal hWndInsertAfter&, _
ByVal X&, ByVal Y&, ByVal cX&, _
ByVal cY&, ByVal wFlags&)
Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) _
As Long
'Moves MS Access window to top of Z-order.
Global Const HWND_TOP = 0
'Creates a window with a maximize box
Global Const WS_MINIMIZEBOX = &H20000
'Creates a window with a minimize box
Global Const WS_MAXIMIZEBOX = &H10000
Global Const GWL_STYLE = (-16)
'Values for wFlags.
Global Const SWP_NOZORDER = &H4 'Ignores the hWndInsertAfter.
Function SizeAccess(cX As Long, cY As Long, _
cHeight As Long, cWidth As Long)
Dim h As Long
'Get handle to Microsoft Access.
h = Application.hWndAccessApp
'Position Microsoft Access.
SetWindowPos h, HWND_TOP, cX, cY, cWidth, _
cHeight, SWP_NOZORDER
Dim L As Long
'Get the current style.
L = GetWindowLong(h, GWL_STYLE)
'the Minimize Button, by uncommenting the following line.
L = L And Not (WS_MINIMIZEBOX)
'Further modify the current style, subtracting
'the Maximize Button, by uncommenting the following below.
L = L And Not (WS_MAXIMIZEBOX)
L = SetWindowLong(h, GWL_STYLE, L)
End Function
4. Open the Immediate window, and then type the sample command below. This
example sets both X and Y to 0, sets the width to 480, and sets the height
to 640.
"?SizeAccess(0,0,480,640)" (without the quotation marks)
5. Press ENTER, and then return to the Access window.
Please feel free to post in the group if this solves your problem or if you
would like further assistance.
Happy new year.
Regards,
Michael Shao
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.