东流西上
故在柳溪,水东有柳

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         ‘调用函数,取消置顶
赞(0) 打赏
转载请注明出处:水东柳博客 » ACCESS窗口置顶的函数
分享到: 更多 (0)

评论 抢沙发

3 + 1 =
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏