473,378 Members | 1,133 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,378 software developers and data experts.

Can I disable the "X" for the application?

I am wondering if there is a way to disable the "X" used to close the
Access application window? I know how to disable it for individual
forms, but I would like to disable it for the application in general
and force users to use a button on the switchboard to close (because I
run important code on the close of the database from that button).

Any ideas are always appreciated.
Thanks!

Jun 28 '06 #1
2 2505
"PamelaDV" <pd******@us.ibm.com> wrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
I am wondering if there is a way to disable the "X" used to close the
Access application window? I know how to disable it for individual
forms, but I would like to disable it for the application in general
and force users to use a button on the switchboard to close (because I
run important code on the close of the database from that button).

Any ideas are always appreciated.
Thanks!


You can't do that but what you can do is run your code from the Unload event
of the last form to be closed. That way, no matter how the app is closed
(aside from a crash) the code will run.

HTH - Keith.
www.keithwilby.com
Jun 28 '06 #2
On 28 Jun 2006 07:59:11 -0700, "PamelaDV" <pd******@us.ibm.com> wrote:
I am wondering if there is a way to disable the "X" used to close the
Access application window? I know how to disable it for individual
forms, but I would like to disable it for the application in general
and force users to use a button on the switchboard to close (because I
run important code on the close of the database from that button).

Any ideas are always appreciated.
Thanks!


Paste the following code into a standard module.
In a startup form use -
fActivateCloseBox(False)

You can play around with the other functions to remove max/min buttons and the
control box.

'source unknown
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
Jun 28 '06 #3

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

Similar topics

1
by: Flare | last post by:
In meen. primary keys, NOT NULL, IDENTETIES...et.c I have to do a maunally, one time, building of a database. Sometables has to stay an some are to be exchanged. The foreignkey inforcemnt ill do...
0
by: jinu | last post by:
Hello, Facing a problem where I use a numericupdown control in vb.net for recieving an input. But user can copy a "text" using mouse and paste into the numericupdown control. This will lead to...
2
by: ZubZero | last post by:
Hello, i have to write a utility in c++ for windows 2k/XP. But i have 2 difficult problems. I asked many programmers i know, but none of them was able to tell me how i can do this. 1. I...
5
by: Peng Yu | last post by:
For example, at the beginning of the C++ program, I say "using namespace std;" However, in the middle of the program, I want to disable "using namespace std;". Do you know how to do that? ...
5
by: http://links.i6networks.com | last post by:
I want to force the users to click submit to submit the forms. How do I disable "Enter Key" which will submit the form automatically when they entered the data in text field then pressed "enter key"
3
by: Stan Huff | last post by:
Is there any way to disable the "params" on a particular invocation so that one can pass an array containing the arguments and not have receiver get an array having you argument array stuffed into...
0
by: Alessandro | last post by:
There is a way to "disable" or remove button to go to next month ? I want, for example, that a user can move from 01/01/2003 to 31/12/2003 but not in 2004..... Any idea ?
8
by: Ken Yu | last post by:
Hi, How can i disable "RightClick Menu" in Internet Explorer, when access the frontpage ? tks a lot ! Ken
1
by: Philip Bondi | last post by:
Hello to all SQL Server junkies who work with non-English characters: For people running scripts from the command line using ANSI files with special characters, it is very important to use isql...
1
by: Troy Bull | last post by:
I have a simple application, that I use the built in navigation bar. I set the add and delete buttons enabled property to false, and it looks good, until.. Once I click on the arrow to navigate...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.