移除报表预览窗口的Min/Max/Close按钮
发布日期:2002年11月13日
摘 要:从报表的预览窗口上移除最小化、最大化以及复原按钮,创建一个自定义的工具条让用户来关闭报表以及使用某些API函数来移除预览窗口上的标题栏。使用这种方法,一旦最大化报表,预览窗口将占据整个access的屏幕窗口而不出现允许复原按钮恢复原来窗口的大小以及不出现其它按钮。
正 文:
从报表的预览窗口上移除最小化、最大化以及复原按钮,创建一个自定义的工具条让用户来关闭报表以及使用某些API函数来移除预览窗口上的标题栏。使用这种方法,一旦最大化报表,预览窗口将占据整个access的屏幕窗口而不出现允许复原按钮恢复原来窗口的大小以及不出现其它按钮。
涉及的使用步骤如下:
1. 在每个报表的Deactivate事件处理程序中写入:
DoCmd.Close acReport, Me.Name |
2. 在一个总是打开的主菜单中放置一个唯一的退出数据库的按钮,并在引用报表的窗口(frmStart)中定义:
Dim CanClose as Integer |
在窗体的Open事件处理程序中写入:
CanClose = 0 |
在窗体的Unload事件处理程序中写入:
If Not CanClose Then Cancel = True Forms!frmStart.Visible = True 'form is hidden when report is previewed DoCmd.SelectObject acForm, "frmStart" CloseForms CloseReports ' CloseForms and CloseReports close any open objects ' other than frmStart End If |
3. 使用每个窗体的Open事件处理程序写入DoCmd.Maximize。
4. 为打印建立一个定置的工具条,放置关闭以及其它的功能按钮。设置报表的菜单为"-1",在工具条上做两个限制用户使用的操作。
5. 使用下面的代码预览报表:
DoCmd.OpenReport "TheReport", acViewPreview,... Call sRemoveCaption(Reports("TheReport") |
这样的话,用户就能:
1. 看到报表
2. 在工具条操作
3. 最小化access
好了,如果用户想关闭access,可以主菜单来做到,但在报表预览窗口没有最小化、最大化以及关闭按钮。
'********************* Code Start ************************ 'This code was originally written by Terry Kreft & Keri Hardwick. 'It is not to be altered or distributed, 'except as part of an application. 'You are free to use it in any application, 'provided the copyright notice is left unchanged. ' 'Code Courtesy of 'Terry Kreft & Keri Hardwick ' Private Type RECT ' 16 Bytes left As Long top As Long right As Long bottom As Long End Type Private Declare Function apiGetWindowLong Lib "User32" _ Alias "GetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long) _ As Long Private Declare Function apiSetWindowLong Lib "User32" _ Alias "SetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) _ As Long Private Declare Function apiGetWindowRect Lib "User32" _ Alias "GetWindowRect" _ (ByVal hwnd As Long, _ lpRect As RECT) _ As Long Private Declare Function apiGetSystemMetrics Lib "User32" _ Alias "GetSystemMetrics" _ (ByVal nIndex&) _ As Long Private Declare Function apiReleaseDC Lib "User32" _ Alias "ReleaseDC" _ (ByVal hwnd As Long, _ ByVal hDC As Long) _ As Long Private Declare Function apiGetDeviceCaps Lib "Gdi32" _ Alias "GetDeviceCaps" _ (ByVal hDC As Long, _ ByVal nIndex As Long) _ As Long Private Declare Function apiGetDC Lib "User32" _ Alias "GetDC" _ (ByVal hwnd 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 'Use following instead of GetWindowRect Private Declare Function GetClientRect Lib "User32" _ (ByVal hwnd As Long, _ lpRect As RECT) As Long Public Const SW_MAXIMIZE = 3 Public Const SW_SHOWNORMAL = 1 Private Const GWL_EXSTYLE = -20 Private Const GWL_HINSTANCE = -6 Private Const GWL_HWNDPARENT = -8 Private Const GWL_ID = -12 Private Const GWL_STYLE = -16 Private Const GWL_USERDATA = -21 Private Const GWL_WNDPROC = -4 Private Const WS_CAPTION = &HC00000 Private Const WS_SYSMENU = &H80000 Private Const SM_CYCAPTION = 4 ' Height of caption or title Private Const TWIPSPERINCH = 1440 '** Window Style Constants Private Const WS_DLGFRAME& = &H400000 Private Const WS_THICKFRAME& = &H40000 Sub aTest() |
翻译: 朱亦文
来 源 于:MVPS: The access Web
(责任编辑:admin)
- ·解决Access在页面设置中设置边距无法保
- ·Access通用报表打印设置
- ·在Access中使用自动化打印报告
- ·报表奇偶分页打印
- ·access输出资料到word用于打印
- ·支票打印的日期大写问题Access2007
- ·[报表]报表跨节垂直居中例子
- ·ACCESS-VBA编程 第八章 报表
- ·用Access2007解决支票打印的日期大写问
- ·自由设置页码打印报表
- ·ACCESS和EXECL结合的简单说明
- ·每页打印一定行数后自动分页(报表分页
- ·在VB中用代码打印ACCESS报表
- ·[原创]在 Access 2000中变通实现弹出式
- ·在Access 2002中打印报表的关系图
- ·Access轻松实现多数据批量打印