access在繫統右下角任務欄彈齣消息提示窗體

2019-02-20 10:39:00
dffew
原創
908

在日常工作中,我們希望程序有提示功能。在某箇時間點或者預設值提示信息

在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


滑齣過程:


    分享