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
This is a pretty clever way to solve the "maximize only the forms I want"- problem!
ReplyDeleteI 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.
ReplyDeleteNo sure i understand what you mean...
ReplyDeletei really dont get it please help me dude!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ReplyDeleteThanks Alex, much appreciated.
ReplyDeleteOmar, Australia
After struggling copying & pasting the code, it worked perfectly well. Thank you!
ReplyDeleteThanks ALEX great..... help greatly...my problem solved.
ReplyDeleteIt really works!!!
ReplyDeleteThank you very much!
You Roc Alex! this is awesome. The whole maximize thing has been a pain for ever....спасибо
ReplyDeleteVery easy to use and it really works!
ReplyDeleteThank you very much!