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

Prevent minimising application. Possible?

P: n/a
Hi all,
Is the above possible?
I guess I need an API call for this ? How and where to find this?

One of my new apps is used as a sort of 'dedicated' thing.
Users see an empty desktop with *only* two buttons. They only click a button to start the app.
(They have two apps they need to work with)
When they minimise the app (and some do this accidently...) the app is NOT visible anymore in a taskbar or so.
In fact there is NO taskbar...
I can check for the app not to be started two times (they do !!)
I am preventing them to kill the app other than by clicking on the 'close' button.
They ask me now: "Can you prevent the minimise ..."

Thanks,
Arno R

Dec 1 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On Thu, 1 Dec 2005 20:29:03 +0100, "Arno R" <ar***********@tiscali.nl> wrote:
Hi all,
Is the above possible?
I guess I need an API call for this ? How and where to find this?

One of my new apps is used as a sort of 'dedicated' thing.
Users see an empty desktop with *only* two buttons. They only click a button to start the app.
(They have two apps they need to work with)
When they minimise the app (and some do this accidently...) the app is NOT visible anymore in a taskbar or so.
In fact there is NO taskbar...
I can check for the app not to be started two times (they do !!)
I am preventing them to kill the app other than by clicking on the 'close' button.
They ask me now: "Can you prevent the minimise ..."

Thanks,
Arno R


I'm not sure where I got this code, so if anyone wants to claim ownership be my guest.

Option Compare Database

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

Dec 2 '05 #2

P: n/a
first place I check for anything like this is at Randy Birch's website.
http://vbnet.mvps.org/

Dec 2 '05 #3

P: n/a
Many thanks Wayne,

but... I simply don't see (yet) how exactly to use this code.

I would like to do one of the following:
-- Hide the minimise option
-- Prevent users to minimise the app (similar like I prevent them to shut down) or
-- Maximise the app again when it is minimised.

Anybody cares to give some specific info on this ?

Arno R

"Wayne Gillespie" <be*****@NOhotmailSPAM.com.au> schreef in bericht news:m9********************************@4ax.com...
On Thu, 1 Dec 2005 20:29:03 +0100, "Arno R" <ar***********@tiscali.nl> wrote:
Hi all,
Is the above possible?
I guess I need an API call for this ? How and where to find this?

One of my new apps is used as a sort of 'dedicated' thing.
Users see an empty desktop with *only* two buttons. They only click a button to start the app.
(They have two apps they need to work with)
When they minimise the app (and some do this accidently...) the app is NOT visible anymore in a taskbar or so.
In fact there is NO taskbar...
I can check for the app not to be started two times (they do !!)
I am preventing them to kill the app other than by clicking on the 'close' button.
They ask me now: "Can you prevent the minimise ..."

Thanks,
Arno R


I'm not sure where I got this code, so if anyone wants to claim ownership be my guest.

Option Compare Database

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

Dec 2 '05 #4

P: n/a
Thanks Piet,

Did not find what I am looking for yet, but the website is 'to be reminded'.

Arno R

<pi********@hotmail.com> schreef in bericht news:11*********************@g43g2000cwa.googlegro ups.com...
first place I check for anything like this is at Randy Birch's website.
http://vbnet.mvps.org/

Dec 2 '05 #5

P: n/a
On Fri, 2 Dec 2005 14:21:32 +0100, "Arno R" <ar***********@tiscali.nl> wrote:

Paste all the code into a standard module.

Calling fActivateMinimizeBox(False) will disable the minimize button of the Access MDI window title bar.
Calling fActivateMaximizeBox(False) will disable the maximise button of the Access MDI window title bar.
Calling fActivateCloseBox(False) will disable the close button of the Access MDI window title bar.
Calling fActivateControlBox(False) will remove the control box AND all buttons from the Access MDI window title bar.

Use a startup routine to call whichever options you want.
The settings apply only to the current database and do not persist between sessions.

You can use the immediate window to test each function by typing (eg) ? fActivateMinimizeBox(False)
Many thanks Wayne,

but... I simply don't see (yet) how exactly to use this code.

I would like to do one of the following:
-- Hide the minimise option
-- Prevent users to minimise the app (similar like I prevent them to shut down) or
-- Maximise the app again when it is minimised.

Anybody cares to give some specific info on this ?

Arno R

"Wayne Gillespie" <be*****@NOhotmailSPAM.com.au> schreef in bericht news:m9********************************@4ax.com...
On Thu, 1 Dec 2005 20:29:03 +0100, "Arno R" <ar***********@tiscali.nl> wrote:
Hi all,
Is the above possible?
I guess I need an API call for this ? How and where to find this?

One of my new apps is used as a sort of 'dedicated' thing.
Users see an empty desktop with *only* two buttons. They only click a button to start the app.
(They have two apps they need to work with)
When they minimise the app (and some do this accidently...) the app is NOT visible anymore in a taskbar or so.
In fact there is NO taskbar...
I can check for the app not to be started two times (they do !!)
I am preventing them to kill the app other than by clicking on the 'close' button.
They ask me now: "Can you prevent the minimise ..."

Thanks,
Arno R


I'm not sure where I got this code, so if anyone wants to claim ownership be my guest.

Option Compare Database

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


Dec 2 '05 #6

P: n/a
Works great. Exactly what I (my client) needed.
The settings apply only to the current database and do not persist between sessions. Slight correction here:
The settings seem to apply to the Access-session.
If I switch to another database the settings are the same. No problem! Still exactly what I needed!

Thanks a lot Wayne.

Arno R
"Wayne Gillespie" <be*****@NOhotmailSPAM.com.au> schreef in bericht news:l6********************************@4ax.com... On Fri, 2 Dec 2005 14:21:32 +0100, "Arno R" <ar***********@tiscali.nl> wrote:

Paste all the code into a standard module.

Calling fActivateMinimizeBox(False) will disable the minimize button of the Access MDI window title bar.
Calling fActivateMaximizeBox(False) will disable the maximise button of the Access MDI window title bar.
Calling fActivateCloseBox(False) will disable the close button of the Access MDI window title bar.
Calling fActivateControlBox(False) will remove the control box AND all buttons from the Access MDI window title bar.

Use a startup routine to call whichever options you want.
The settings apply only to the current database and do not persist between sessions.

You can use the immediate window to test each function by typing (eg) ? fActivateMinimizeBox(False)

Dec 2 '05 #7

P: n/a
On Fri, 2 Dec 2005 17:47:09 +0100, "Arno R" <ar***********@tiscali.nl> wrote:
The settings apply only to the current database and do not persist between sessions.

Slight correction here:
The settings seem to apply to the Access-session.
If I switch to another database the settings are the same. No problem! Still exactly what I needed!


You are correct. That is actually what I meant to type ;)

Dec 3 '05 #8

P: n/a

Paste the code below into a module and call RemoveMinimise.

The minimise button stays on the window but doesn't do anything.

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

Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long

Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long

Sub RemoveMinimise()
Dim hMenu 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, 3, _
MF_REMOVE Or MF_BYPOSITION)
Call DrawMenuBar(hWndAccessApp)
End If
End Sub

--
Terry Kreft

"Arno R" <ar***********@tiscali.nl> wrote in message
news:43**********************@text.nova.planet.nl. ..
Many thanks Wayne,

but... I simply don't see (yet) how exactly to use this code.

I would like to do one of the following:
-- Hide the minimise option
-- Prevent users to minimise the app (similar like I prevent them to shut
down) or
-- Maximise the app again when it is minimised.

Anybody cares to give some specific info on this ?

Arno R

"Wayne Gillespie" <be*****@NOhotmailSPAM.com.au> schreef in bericht
news:m9********************************@4ax.com...
On Thu, 1 Dec 2005 20:29:03 +0100, "Arno R" <ar***********@tiscali.nl>
wrote:
Hi all,
Is the above possible?
I guess I need an API call for this ? How and where to find this?

One of my new apps is used as a sort of 'dedicated' thing.
Users see an empty desktop with *only* two buttons. They only click a
button to start the app.
(They have two apps they need to work with)
When they minimise the app (and some do this accidently...) the app is NOT
visible anymore in a taskbar or so.
In fact there is NO taskbar...
I can check for the app not to be started two times (they do !!)
I am preventing them to kill the app other than by clicking on the 'close'
button.
They ask me now: "Can you prevent the minimise ..."

Thanks,
Arno R


I'm not sure where I got this code, so if anyone wants to claim ownership
be my guest.

Option Compare Database

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

Dec 3 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.