大家好,欢迎来到IT知识分享网。
在日常工作中,我们希望程序有提示功能。在某个时间点或者预设值提示信息
在Windows操作系统中,我们常常可以看到某软件会在右下角自动弹出消息供参考阅读
在access中,我们也可以通过API函数来判断系统状态栏的位置,让窗体在右下角任务栏向上滑动弹出
API函数:
Option Compare Database '调用API取得除任务栏外的屏幕高度 Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long Public Const SPI_GETWORKAREA = 48 Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type '调用API得到整个屏幕高度 Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Private Const SM_CXSCREEN = 0 Private Const SM_CYSCREEN = 1 Public Function GetSystemHeight() As Integer '取得屏幕高度 GetSystemHeight = GetSystemMetrics(SM_CYSCREEN) End Function Public Function GetTaskbarHeight() As Integer '取得任务栏高度 Dim lRes As Long Dim rectVal As RECT lRes = SystemParametersInfo(SPI_GETWORKAREA, 0, rectVal, 0) GetTaskbarHeight = GetSystemMetrics(SM_CYSCREEN) - rectVal.Bottom End Function
窗体中代码:
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long Dim mywidth As Long, myheight As Long '设置窗口总在最前 Const SWP_NOSIZE = &H1 Const SWP_NOMOVE = &H2 Const HWND_TOP = 0 Const HWND_NOTOPMOST = -2 Const HWND_BOTTOM = 1 Const HWND_TOPMOST = -1 Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Sub Form_Load() '在任务栏中不显示 hdc = GetDC(0) mywidth = GetDeviceCaps(hdc, 8) myheight = GetDeviceCaps(hdc, 10) DoCmd.MoveSize (mywidth * 15 - Me.WindowWidth),GetSystemHeight * 15 '窗口总在最前 SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Me.TimerInterval = 200 End Sub Private Sub Form_Timer() Dim I As Integer For I = GetSystemHeight * 15 To (myheight * 15 - Me.WindowHeight) - GetTaskbarHeight * 15 Step -1 DoCmd.MoveSize (mywidth * 15 - Me.WindowWidth), I Next I Me.TimerInterval = 0 End Sub
滑出过程:
学习更多的access技巧源码,请关注office交流网:http://www.office-cn.net
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/51962.html