Mình sưu tầm được đoạn code trên mạng ẩn thanh tiêu đề cửa sổ, ẩn menu của access nhưng khi mình test xong thì menu chính của access bị ẩn luôn.
Các bạn giúp mình khôi phục lại menu của access với.
Option Compare Database
' ----------------------------------------------------------------
' Lấy độ phân giải màn hình
Public TwipResW As Double, TwipResH As Double
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
' ----------------------------------------------------------------
‘Định lại kiểu cửa sổ
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Const HWND_TOP = 0
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H30
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
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
' -------------------------------------------------------------
Sub HideAccessAll()
Dim lngStyle As Long
‘Ẩn thanh tiêu đề cửa sổ
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not &HBF0000
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
‘Định lại kích thước Max
TwipResW = GetSystemMetrics(0)
TwipResH = GetSystemMetrics(1)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, TwipResW, TwipResH, SWP_DRAWFRAME)
End Sub
Sub HideAccessControlBox()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
End Sub
Sub UnHideAccessAll()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle Or WS_SYSMENU
lngStyle = lngStyle Or WS_MINIMIZEBOX
lngStyle = lngStyle Or WS_MAXIMIZEBOX
lngStyle = lngStyle Or &HBF0000
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdAppMaximize
HideAccessAll
CommandBars("menu bar").Enabled = False
CommandBars("database").Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnHideAccessAll
CommandBars("menu bar").Enabled = True
CommandBars("database").Enabled = True
End Sub
Các bạn giúp mình khôi phục lại menu của access với.
Option Compare Database
' ----------------------------------------------------------------
' Lấy độ phân giải màn hình
Public TwipResW As Double, TwipResH As Double
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
' ----------------------------------------------------------------
‘Định lại kiểu cửa sổ
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Const HWND_TOP = 0
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H30
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
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
' -------------------------------------------------------------
Sub HideAccessAll()
Dim lngStyle As Long
‘Ẩn thanh tiêu đề cửa sổ
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not &HBF0000
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
‘Định lại kích thước Max
TwipResW = GetSystemMetrics(0)
TwipResH = GetSystemMetrics(1)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, TwipResW, TwipResH, SWP_DRAWFRAME)
End Sub
Sub HideAccessControlBox()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle And Not WS_SYSMENU
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
End Sub
Sub UnHideAccessAll()
Dim lngStyle As Long
lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
lngStyle = lngStyle Or WS_SYSMENU
lngStyle = lngStyle Or WS_MINIMIZEBOX
lngStyle = lngStyle Or WS_MAXIMIZEBOX
lngStyle = lngStyle Or &HBF0000
Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdAppMaximize
HideAccessAll
CommandBars("menu bar").Enabled = False
CommandBars("database").Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnHideAccessAll
CommandBars("menu bar").Enabled = True
CommandBars("database").Enabled = True
End Sub