Access Window Resizing

H

Howard

I have code that sets the Access window to a certain
size. Is there a way to remove the Access window resizing
control from the window?
 
Y

Yuan Shao

Hi Howard,

Thanks for your post. According to your description, I am not quite clear
what you accurate concern. Do you mean that you want to remove the Max and
Min buttons from the form? If so, please set the Min Max buttons property
in the form property to "None".

For more information regarding this issue, please refer to the following
articles on Microsoft Access Help.
Topic: "MinMaxButtons Property"

Also, if I have misunderstood, please feel free to let me know. Thanks for
using MSDN newsgroup.

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.
 
H

Howard Jenson

Hi Michael
Using the windows api or some other method, I want to open
access and set the Access window to a certain size, such
as 800 X 600 and remove the resize capability for the
window. Can this be done?

Howard
 
Y

Yuan Shao

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.
 
H

Howard

Hi Michael
Thank You so much, you have answered 75% of my question.
When I refer to resizing the window, I'm referring to the
resizing of the window with the cursor. For example put
your cursor in the lower right cornor of the window click-
and-hold then change the size of the window. If this
feature was removed, then the user could not change the
size of the window once it has been set to (0,0,480,640)

Hope I explained this correctly.

Thanks again
Howard
 
Y

Yuan Shao

Hi Howard,

Thanks for your feedback. I understand that you also want disable the
resize actoin using cursor. If I have misunderstood, please feel free to
let me know.

I made some changes on the previous codes. Please check to see if the
following codes meet your requirements.

I added two new lines in the codes.

Global Const WS_SIZEBOX = &H40000
L = L And Not (WS_SIZEBOX)

=========================
Codes
==========================

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 WS_SIZEBOX = &H40000

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 = L And Not (WS_SIZEBOX)

L = SetWindowLong(h, GWL_STYLE, L)

End Function

Please reply directly to the thread with any updates. Please be aware that
you may receive this email notification before you able to view my reply in
the newsgroup.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top