By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,155 Members | 2,518 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,155 IT Pros & Developers. It's quick & easy.

disable access application maximizebox

P: n/a


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(Hwnd As Long)
Dim hMenu As Long
hMenu = GetSystemMenu(Hwnd, False)
DeleteMenu hMenu, SC_RESTORE, MF_BYCOMMAND
DeleteMenu hMenu, SC_MAXIMIZE, MF_BYCOMMAND
End Sub

Function InitApplication()
DoCmd.RunCommand Access.acCmdAppMaximize
Call RemoveMaxMenu(Access.hWndAccessApp)
End Function

this code not work.
i want to maximize the access window in runtime and then the
maximizebox(right top of access window(system button)) is disabled.
*** Sent via Developersdex http://www.developersdex.com ***
Oct 8 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 08 Oct 2006 23:12:56 GMT, x taol <to******@yahoo.comwrote:

I reviewed your code and found it to do what it promises: it maximized
the Access main window, and removes two menu items from its system
menu.
If (as it appears) you would want to remove the system buttons as
well, you need to go back to the Windows system documentation and find
out how to do this. I seem to remember Get/SetWindowLong but it's been
a few years since I wanted to mess up the average user's expectations
:-)

-Tom.

>

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(Hwnd As Long)
Dim hMenu As Long
hMenu = GetSystemMenu(Hwnd, False)
DeleteMenu hMenu, SC_RESTORE, MF_BYCOMMAND
DeleteMenu hMenu, SC_MAXIMIZE, MF_BYCOMMAND
End Sub

Function InitApplication()
DoCmd.RunCommand Access.acCmdAppMaximize
Call RemoveMaxMenu(Access.hWndAccessApp)
End Function

this code not work.
i want to maximize the access window in runtime and then the
maximizebox(right top of access window(system button)) is disabled.
*** Sent via Developersdex http://www.developersdex.com ***
Oct 9 '06 #2

P: n/a


setclasslong is not work well.
applying that method and the access window is minimized and then if the
access window restore, end of the window enter down the taskbar, like
the window is fullscreen,

i want to do the other method using api.
*** Sent via Developersdex http://www.developersdex.com ***
Oct 9 '06 #3

P: n/a
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(Hwnd As Long)
Dim hMenu As Long
hMenu = GetSystemMenu(Hwnd, False)
DeleteMenu hMenu, SC_RESTORE, MF_BYCOMMAND
DeleteMenu hMenu, SC_MAXIMIZE, MF_BYCOMMAND
End Sub

Function InitApplication()
DoCmd.RunCommand Access.acCmdAppMaximize
Call RemoveMaxMenu(Access.hWndAccessApp)
End Function

this code not work.
i want to maximize the access window in runtime and then the
maximizebox(right 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 fActivateControlBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long

hWnd = Access.hWndAccessApp

CurStyle = GetWindowLong(hWnd, 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(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)

End Function

Public Function fActivateCloseBox(Enable As Boolean)
Dim hMenu As Long
Dim hWnd As Long

hWnd = Access.hWndAccessApp

If Enable Then
Call GetSystemMenu(hWnd, True)
Else
hMenu = GetSystemMenu(hWnd, False)
If hMenu Then
Call DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
End If
End If
Call DrawMenuBar(hWnd)

End Function

Public Function fActivateMaximizeBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long

hWnd = Access.hWndAccessApp

CurStyle = GetWindowLong(hWnd, 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(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)

End Function

Public Function fActivateMinimizeBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long

hWnd = Access.hWndAccessApp

CurStyle = GetWindowLong(hWnd, 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(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)

End Function

Wayne Gillespie
Gosford NSW Australia
Oct 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.