PrivateSubMaximizeRestoredReport(RAsReport)
'ThiscodewasoriginallywrittenbyTerryKreft
'Fullcreditsandacknowledgementstohim.
'
DimMDIRectAsRECT
'IftheReportismaximized,restoreit.
IfIsZoomed(R.hwnd)<>0Then
ShowWindowR.hwnd,SW_SHOWNORMAL
EndIf
'Getthescreencoordinatesandwindowsizeofthe
'MDIClientarea.
'Thisisthelinewhichisdifferent
GetClientRectGetParent(R.hwnd),MDIRect
'MovetheReporttotheupperleftcorneroftheMDIClient
'window(0,0)andsizeittothesamesizeasthe
'MDIClientwindow.
MoveWindowR.hwnd,0,0,MDIRect.right-MDIRect.left,_
MDIRect.bottom-MDIRect.top,True
EndSub
SubsRemoveCaption(rptAsReport)
DimlngRetAsLong,lngStyleAsLong
DimtRECTAsRECT,lngXAsLong
DimlngCaptionWidthAsLong
DimlngLeftAsLong
DimlngTopAsLong
DimlngWidthAsLong
DimlngHeightAsLong
lngRet=apiGetWindowLong(rpt.hwnd,GWL_STYLE)
lngStyle=(lngRetXorWS_DLGFRAMEXor_
WS_THICKFRAME)AndNotWS_CAPTION
'NeedtheXorabovetokeepwindowfrombeingsizable
lngRet=apiSetWindowLong(rpt.hwnd,GWL_STYLE,lngStyle)
lngX=apiGetWindowRect(rpt.hwnd,tRECT)
'havetoresizetheformnow
'howmuchwascaption'sscreenspace
lngCaptionWidth=apiGetSystemMetrics(SM_CYCAPTION)
WithtRECT
lngLeft=.left
lngTop=.top
lngWidth=.right-.left
lngHeight=.bottom-.top-lngCaptionWidth
ConvertPIXELSToTWIPSlngLeft,lngTop
ConvertPIXELSToTWIPSlngWidth,lngHeight
DoCmd.SelectObjectacReport,rpt.Name,False
DoCmd.Restore
DoCmd.MoveSizelngLeft,lngTop,lngWidth,lngHeight
EndWith
'nowuseTerry'scodehere
CallMaximizeRestoredReport(rpt)
EndSub
SubConvertPIXELSToTWIPS(xAsLong,YAsLong)
'FromtheKB
DimhDCAsLong,hwndAsLong,RetValAsLong
DimXPIXELSPERINCH,YPIXELSPERINCH
ConstLOGPIXELSX=88
ConstLOGPIXELSY=90
hDC=apiGetDC(0)
XPIXELSPERINCH=apiGetDeviceCaps(hDC,LOGPIXELSX)
YPIXELSPERINCH=apiGetDeviceCaps(hDC,LOGPIXELSY)
RetVal=apiReleaseDC(0,hDC)
x=(x/XPIXELSPERINCH)*TWIPSPERINCH
Y=(Y/YPIXELSPERINCH)*TWIPSPERINCH
EndSub
'************************CodeEnd**************************
责任编辑:小草