PrivateSubMaximizeRestoredReport(RAsReport)
- D# N* r( K; b$ r 'ThiscodewasoriginallywrittenbyTerryKreft
, @3 M& d" A! l4 _# H& } 'Fullcreditsandacknowledgementstohim.
9 }8 a( _8 K a/ i3 o" ?0 U' G: u '* K, t: r# y* o
DimMDIRectAsRECT
* k6 ^5 x: o+ H3 W 'IftheReportismaximized,restoreit.- |+ z8 L# O8 @9 a/ h: m$ a
IfIsZoomed(R.hwnd)0Then
# R) n2 n( e% i7 S ShowWindowR.hwnd,SW_SHOWNORMAL `0 m% q: @9 P# O$ _8 g' B7 k( {
EndIf6 [6 d8 V5 h- X. w' A3 r
'Getthescreencoordinatesandwindowsizeofthe
2 x/ M2 v+ c4 K9 E h& L9 Q8 p 'MDIClientarea.
0 `+ l% o* O3 n 'Thisisthelinewhichisdifferent6 `5 u5 o2 h- | ]3 R: a7 ^$ A
GetClientRectGetParent(R.hwnd),MDIRect
& p. e) m* t2 T% W* F 'MovetheReporttotheupperleftcorneroftheMDIClient
9 r) X, l! D) y3 b m8 E- s$ W 'window(0,0)andsizeittothesamesizeasthe: ^! K$ G+ T+ {
'MDIClientwindow.9 t8 n* t9 Z6 U9 b7 c7 p
MoveWindowR.hwnd,0,0,MDIRect.right-MDIRect.left,_* l' [8 o; u. y% M+ ~5 s `
MDIRect.bottom-MDIRect.top,True
5 Q, |6 u8 K2 i9 [# a- ~1 h EndSub
/ j9 p9 ]! t8 H2 c SubsRemoveCaption(rptAsReport)
% ` H7 y+ k5 _5 _ DimlngRetAsLong,lngStyleAsLong
H5 @, M' u, a/ `5 ?* U DimtRECTAsRECT,lngXAsLong% G$ ~4 o# I4 E& W- F
DimlngCaptionWidthAsLong
; ~0 [+ g& d% Y; ` DimlngLeftAsLong2 b) @9 q& e3 ^% z
DimlngTopAsLong) T2 o+ P0 t2 P* _4 h- Z
DimlngWidthAsLong
5 `& B8 l) d1 o! _, Z2 m; F( y DimlngHeightAsLong
% A' _: m8 b# Y6 H, R lngRet=apiGetWindowLong(rpt.hwnd,GWL_STYLE)
& ~( j* e& Y# T: I lngStyle=(lngRetXorWS_DLGFRAMEXor_
! n& M: ]! B- }# w WS_THICKFRAME)AndNotWS_CAPTION6 s( Z2 Z( M& m* O9 V
'NeedtheXorabovetokeepwindowfrombeingsizable
/ p: q9 [6 B- I0 v' ~ lngRet=apiSetWindowLong(rpt.hwnd,GWL_STYLE,lngStyle)
" [/ \1 _% N4 {7 J4 i+ |- J3 ?; W8 \ lngX=apiGetWindowRect(rpt.hwnd,tRECT)# f& b4 ~, _* @# D ?% a
'havetoresizetheformnow& C O: e# W% W( X# D9 b1 G7 p$ l
'howmuchwascaption'sscreenspace
% f l4 {5 d- u; H2 L; S+ I3 ~ lngCaptionWidth=apiGetSystemMetrics(SM_CYCAPTION)
3 ]) }7 W9 [! i WithtRECT9 U; T* ~. W6 P8 V" S. {
lngLeft=.left
$ k3 ^& _3 N2 m! g! B. L, y3 ? lngTop=.top5 y& q1 y' I p$ Q
lngWidth=.right-.left x$ Q- f" a" r0 V4 D+ v
lngHeight=.bottom-.top-lngCaptionWidth
" D. F" ]5 d) K1 ~! j! L I ConvertPIXELSToTWIPSlngLeft,lngTop
5 U8 L- k3 I4 M7 l ConvertPIXELSToTWIPSlngWidth,lngHeight4 Y9 x E8 u {: R( z
DoCmd.SelectObjectacReport,rpt.Name,False% {: i# b, U: ]9 Z' i
DoCmd.Restore
" W3 d T0 q" m2 F) d5 q, e, M DoCmd.MoveSizelngLeft,lngTop,lngWidth,lngHeight. t Y+ t7 Z: @% C
EndWith
6 d; C* f* h$ C6 F$ ` 'nowuseTerry'scodehere+ ~# W, ], Y0 _& Z% P( N$ `
CallMaximizeRestoredReport(rpt)
8 I; L& F" l- w! ~ EndSub( ]% P5 ~0 K$ ~$ u4 |
SubConvertPIXELSToTWIPS(xAsLong,YAsLong)( R& I$ w3 u; Y/ R) ]
'FromtheKB
' [2 W- L, f0 s DimhDCAsLong,hwndAsLong,RetValAsLong
2 F9 e [: c w$ z* \ DimXPIXELSPERINCH,YPIXELSPERINCH
/ s2 t: E( M5 a& c. [ ConstLOGPIXELSX=881 i9 x- E8 {+ p$ Q7 |: `8 Y6 B4 ]+ M
ConstLOGPIXELSY=90
% s- e' T9 i. j/ x9 c hDC=apiGetDC(0). n6 I5 g$ A& ^7 W- h
XPIXELSPERINCH=apiGetDeviceCaps(hDC,LOGPIXELSX)' Z% s. y8 S1 j H6 M% A
YPIXELSPERINCH=apiGetDeviceCaps(hDC,LOGPIXELSY)- |! K1 ?& c1 Y4 Q2 t. y( z7 [
RetVal=apiReleaseDC(0,hDC)
0 s" r# Z' c+ O# X( D x=(x/XPIXELSPERINCH)*TWIPSPERINCH
# Q% l C/ q' M+ p/ }9 @ Y=(Y/YPIXELSPERINCH)*TWIPSPERINCH. ~$ q0 P$ }* M3 S& d! A3 j
EndSub
{% Z) y: }! i- Q. F4 h D '************************CodeEnd************************** |