473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Hide Access Close buton but show Min/Max

I use the code below to hide the MS Access Close button and the
minimize and maximize buttons.

What I want to do is to hide the close button but not the min/max
buttons.

Is this possible?

lq
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_SYSMENU = &H80000
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_FRAMECHANGED = &H20

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 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

Function Buttons(Show As Boolean) As Long
Dim hwnd As Long, nIndex As Long, dwNewLong As Long, dwLong As Long

hwnd = hWndAccessApp
nIndex = GWL_STYLE

Const wFlags = SWP_NOSIZE + SWP_NOZORDER + SWP_FRAMECHANGED +
SWP_NOMOVE
Const FLAGS_COMBI = WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_SYSMENU

dwLong = GetWindowLong(hwnd, nIndex)

If Show Then
dwNewLong = (dwLong Or FLAGS_COMBI)
Else
dwNewLong = (dwLong And Not FLAGS_COMBI)
End If

Call SetWindowLong(hwnd, nIndex, dwNewLong)
Call SetWindowPos(hwnd, 0&, 0&, 0&, 0&, 0&, wFlags)
End Function

Nov 13 '05 #1
1 3709
The following code should do as you want

' **********************************************
Option Explicit

Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000

Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" _
(ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long

Sub RemoveAccClose()
Dim hMenu As Long
Dim hwnd As Long
Dim menuItemCount As Long
'Obtain the handle to the form's system menu
hMenu = GetSystemMenu(hWndAccessApp, 0)

If hMenu Then
Call RemoveMenu(hMenu, 6, _
MF_REMOVE Or MF_BYPOSITION)

Call RemoveMenu(hMenu, 5, _
MF_REMOVE Or MF_BYPOSITION)

'Force a redraw of the menu. This
'refreshes the titlebar, dimming the X
Call DrawMenuBar(hWndAccessApp)

End If
End Sub
' **********************************************
--
Terry Kreft
MVP Microsoft Access
"Lauren Quantrell" <la*************@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I use the code below to hide the MS Access Close button and the
minimize and maximize buttons.

What I want to do is to hide the close button but not the min/max
buttons.

Is this possible?

lq
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_SYSMENU = &H80000
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_FRAMECHANGED = &H20

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 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

Function Buttons(Show As Boolean) As Long
Dim hwnd As Long, nIndex As Long, dwNewLong As Long, dwLong As Long

hwnd = hWndAccessApp
nIndex = GWL_STYLE

Const wFlags = SWP_NOSIZE + SWP_NOZORDER + SWP_FRAMECHANGED +
SWP_NOMOVE
Const FLAGS_COMBI = WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_SYSMENU

dwLong = GetWindowLong(hwnd, nIndex)

If Show Then
dwNewLong = (dwLong Or FLAGS_COMBI)
Else
dwNewLong = (dwLong And Not FLAGS_COMBI)
End If

Call SetWindowLong(hwnd, nIndex, dwNewLong)
Call SetWindowPos(hwnd, 0&, 0&, 0&, 0&, 0&, wFlags)
End Function

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
1
by: lauren quantrell | last post by:
Before getting pistol whipped, I know this is a well-worn topic but I don't see the answer... I know how to hide the Access window, I know how to disable the Access application's close button, but...
0
by: Lauren Quantrell | last post by:
I use the code below to hide the MS Access Close button and the minimize and maximize buttons. What I want to do is to hide the close button but not the min/max buttons. Is this possible? ...
4
by: Blaine | last post by:
Does anyone know how I can hide a form from the TaskManager? I've set the ShowInTaskbar to False, but when using Alt-TAB to switch between applications, it appears as a blank icon. I can set it...
4
by: BrianDH | last post by:
Hi I have an application with 3 windows forms. One of which I load at startup but hide, then show/hide based on users click. How can I test to see if the windows is hidden, or is at the moment...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
13
by: jeff | last post by:
I am attempting to be able to show and hide a form called viewAllForm. I declared an instance of the form in a module. Public viewAllForm As New frmViewAll However I keep getting runtime errors...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.