How to Maximize Access Form
In Access this is easy - just run Docmd.Maximize. But once you maximized one form - all others get maximized also. Of course you can run Docmd.Restore, but then forms start to show a lot of visual effects. I think the best approach - is to size form to maximum available size, so it will be looked like it is maximized. Below a sample code, just paste it in a new module, and in Form's Load event add: MaximizeForm Me.hWnd
You can also use same approach for reports, a sample download available at Point Limited site.
You can also use same approach for reports, a sample download available at Point Limited site.
Option Compare Database
Option Explicit
'**********************************
'** Constant Definitions:
Private Const GWL_STYLE& = (-16)
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMAXIMIZED = 3
'**********************************
'** Window Style Constants
Private Const WS_DLGFRAME& = &H400000
Private Const WS_THICKFRAME& = &H40000
'**********************************
'** Type Definitions:
Private Type RECT
x1 As Long
Y1 As Long
x2 As Long
Y2 As Long
End Type
'**********************************
'** Function Declarations:
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function IsZoomed Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal _
nCmdShow As Long) As Long
Private Declare Function MoveWindow Lib "user32" _
(ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private Declare Function GetParent Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetClientRect Lib "user32" _
(ByVal hWnd As Long, lpRect As RECT) As Long
Public Function MaximizeForm(ByVal lngHwnd As Long)
Dim rpt As Access.Report
Dim MR As RECT
Dim WinStyle As Long
Dim lngRet As Long
WinStyle = GetWindowLong(lngHwnd, GWL_STYLE)
WinStyle = WinStyle Xor WS_DLGFRAME Xor WS_THICKFRAME
Call SetWindowLong(lngHwnd, GWL_STYLE, WinStyle)
If IsZoomed(lngHwnd) <> 0 Then
Call ShowWindow(lngHwnd, SW_SHOWNORMAL)
End If
Call GetClientRect(GetParent(lngHwnd), MR)
Call MoveWindow(lngHwnd, 0, 0, MR.x2 - MR.x1, MR.Y2 - MR.Y1, True)
End Function
10 Comments:
This is a pretty clever way to solve the "maximize only the forms I want"- problem!
I decided not to set the form as a pop up, and now all the forms open at 0,0. I am now having problems undoing the change.
No sure i understand what you mean...
i really dont get it please help me dude!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thanks Alex, much appreciated.
Omar, Australia
After struggling copying & pasting the code, it worked perfectly well. Thank you!
Thanks ALEX great..... help greatly...my problem solved.
It really works!!!
Thank you very much!
You Roc Alex! this is awesome. The whole maximize thing has been a pain for ever....спасибо
Very easy to use and it really works!
Thank you very much!
Post a Comment
<< Home