访问隐藏Windows,但在窗口的任务栏中显示

时间:2017-11-15 10:04:38

标签: vba ms-access access-vba

像标题所说的那样,我想隐藏访问的Windows应用程序,但在我的Windows任务栏中查看表单项。

我已经发现使用此API隐藏访问窗口:

Const SW_HIDE = 0
Const SW_NORMAL = 1

Private Declare PtrSafe Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal FHCmdShow As Long) As Long

而且:ShowWindow Application.hWndAccessApp, 0用于隐藏窗口。

我在任务栏中找到了这个项目:

Public Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
 ByVal nIndex As Long) As Long

Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
 ByVal nIndex As Long, _
 ByVal dwNewLong As Long) As Long

Public 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

Public Sub AppTasklist(frmHwnd)
Dim WStyle  As Long
Dim Result  As Long

WStyle = GetWindowLong(frmHwnd, GWL_EXSTYLE)

WStyle = WStyle Or WS_EX_APPWINDOW

Result = SetWindowPos(frmHwnd, HWND_TOP, 0, 0, 0, 0, _
                      SWP_NOMOVE Or _
                      SWP_NOSIZE Or _
                      SWP_NOACTIVATE Or _
                      SWP_HIDEWINDOW)

Result = SetWindowLong(frmHwnd, GWL_EXSTYLE, WStyle)
Debug.Print Result

Result = SetWindowPos(frmHwnd, HWND_TOP, 0, 0, 0, 0, _
                      SWP_NOMOVE Or _
                      SWP_NOSIZE Or _
                      SWP_NOACTIVATE Or _
                      SWP_SHOWWINDOW)


End Sub

但是我不知道如何做这项工作,我尝试过很少的东西,但没有任何效果。 有人已经使用过它还是可以帮助我?

0 个答案:

没有答案