ACCESS窗口置顶的函数

有时候需要把某些窗体置顶到屏幕的最前面,方便的编辑或输入数据,所以网上查了窗口置顶的函数,找到了红尘如烟的窗口置顶自定义函数,只要在模块中申明一下的函数,再到需要置顶的窗体的Load下调用就可以了,不需要的时候再调用取消置顶,具体如下:


Option Compare Database
Option Explicit

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

Const API_SWP_NOSIZE = &H1

Const API_SWP_NOMOVE = &H2

Const API_HWND_TOPMOST = -1

Const API_HWND_NOTOPMOST = -2

Public Type POINTAPI

X As Long

Y As Long

End Type
‘====================================================================
Function setFormPos(frm As Form, Optional bln As Boolean = True) As Boolean

If bln = True Then

SetWindowPos frm.hwnd, -1, 0, 0, 0, 0, 3 ‘置顶

Else

SetWindowPos frm.hwnd, -2, 0, 0, 0, 0, 3 ‘正常

End If

If Err.Number = 0 Then

setFormPos = True

Else

setFormPos = False

End If

End Function



//实际使用
Private Sub Form_Load()

setFormPos Me      ‘调用函数,置顶

Private Sub Form_Load()

setFormPos Me, False         ‘调用函数,取消置顶

版权声明:
作者:水东柳
链接:https://shuidl.com/1572.html
来源:水东柳博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>