On 08 Oct 2006 23:12:56 GMT, x taol <to******@yahoo .comwrote:
>
Private Declare Function GetSystemMenu Lib "user32.dll " (ByVal Hwnd As
Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32.dll " (ByVal hMenu As
Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Const SC_MAXIMIZE = &HF030
Public Const MF_BYCOMMAND = &H0&
Public Const SC_RESTORE = &HF120
Public Sub RemoveMaxMenu(H wnd As Long)
Dim hMenu As Long
hMenu = GetSystemMenu(H wnd, False)
DeleteMenu hMenu, SC_RESTORE, MF_BYCOMMAND
DeleteMenu hMenu, SC_MAXIMIZE, MF_BYCOMMAND
End Sub
Function InitApplication ()
DoCmd.RunComma nd Access.acCmdApp Maximize
Call RemoveMaxMenu(A ccess.hWndAcces sApp)
End Function
this code not work.
i want to maximize the access window in runtime and then the
maximizebox(ri ght top of access window(system button)) is disabled.
*** Sent via Developersdex http://www.developersdex.com ***
This works for me.
I don't know where I got this code and there is no copyright notice, so if
anyone wants to claim ownership feel free.
Private Declare Function GetWindowLong Lib "User32" _
Alias "GetWindowLongA " _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
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 GetSystemMenu _
Lib "User32" _
(ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function DrawMenuBar _
Lib "User32" _
(ByVal hWnd As Long) As Long
Private Declare Function DeleteMenu _
Lib "User32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Const MF_BYCOMMAND = &H0&
Private Const SC_CLOSE = &HF060
Private Const WS_SYSMENU = &H80000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const GWL_STYLE = (-16)
Public Function fActivateContro lBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
hWnd = Access.hWndAcce ssApp
CurStyle = GetWindowLong(h Wnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_SYSMENU) Then
CurStyle = CurStyle Or WS_SYSMENU
End If
Else
If (CurStyle And WS_SYSMENU) = WS_SYSMENU Then
CurStyle = CurStyle - WS_SYSMENU
End If
End If
Call SetWindowLong(h Wnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWn d)
End Function
Public Function fActivateCloseB ox(Enable As Boolean)
Dim hMenu As Long
Dim hWnd As Long
hWnd = Access.hWndAcce ssApp
If Enable Then
Call GetSystemMenu(h Wnd, True)
Else
hMenu = GetSystemMenu(h Wnd, False)
If hMenu Then
Call DeleteMenu(hMen u, SC_CLOSE, MF_BYCOMMAND)
End If
End If
Call DrawMenuBar(hWn d)
End Function
Public Function fActivateMaximi zeBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
hWnd = Access.hWndAcce ssApp
CurStyle = GetWindowLong(h Wnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_MAXIMIZEBOX) Then
CurStyle = CurStyle Or WS_MAXIMIZEBOX
End If
Else
If (CurStyle And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX Then
CurStyle = CurStyle - WS_MAXIMIZEBOX
End If
End If
Call SetWindowLong(h Wnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWn d)
End Function
Public Function fActivateMinimi zeBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
hWnd = Access.hWndAcce ssApp
CurStyle = GetWindowLong(h Wnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_MINIMIZEBOX) Then
CurStyle = CurStyle Or WS_MINIMIZEBOX
End If
Else
If (CurStyle And WS_MINIMIZEBOX) = WS_MINIMIZEBOX Then
CurStyle = CurStyle - WS_MINIMIZEBOX
End If
End If
Call SetWindowLong(h Wnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWn d)
End Function
Wayne Gillespie
Gosford NSW Australia