I need to disable the exit button in the form .
However, the min. and max. button need to keep it
How ?
Thanks a lot
From Agnes 24 4813
* "Agnes" <ag***@dynamictech.com.hk> scripsit: I need to disable the exit button in the form . However, the min. and max. button need to keep it
\\\
Private Declare Auto Function GetSystemMenu Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal bRevert As Int32 _
) As IntPtr
Private Declare Auto Function GetMenuItemCount Lib "user32.dll" ( _
ByVal hMenu As IntPtr _
) As Int32
Private Declare Auto Function DrawMenuBar Lib "user32.dll" ( _
ByVal hWnd As IntPtr _
) As Int32
Private Declare Auto Function RemoveMenu Lib "user32.dll" ( _
ByVal hMenu As IntPtr, _
ByVal nPosition As Int32, _
ByVal wFlags As Int32 _
) As Int32
Private Const MF_BYPOSITION As Int32 = &H400
Private Const MF_REMOVE As Int32 = &H1000
Private Sub RemoveCloseButton(ByVal frmForm As Form)
Dim hMenu As IntPtr, n As Int32
hMenu = GetSystemMenu(frmForm.Handle, 0)
If Not hMenu.Equals(IntPtr.Zero) Then
n = GetMenuItemCount(hMenu)
If n > 0 Then
RemoveMenu(hMenu, n - 1, MF_BYPOSITION Or MF_REMOVE)
RemoveMenu(hMenu, n - 2, MF_BYPOSITION Or MF_REMOVE)
DrawMenuBar(frmForm.Handle)
End If
End If
End Sub
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Agnes wrote: I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about
the same as mounting a brick under a car's brake pedal to make
sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a
window). Most VB applications do exit indeed when their last
window is closed.
When you click it, the "Closing" event is fired in the code
belonging to that form. You can cancel it through the event
arguments: set e.cancel = true; but *NEVER* do so without asking
the user for confirmation.
If not handled properly (i.e. a plain dumb "e.cancel=true"), it
will effectively make it impossible for a user to log off or to
shut down his system without first killing your app through task
manager. Most of them will just reach for the power or reset
button instead.
In either case, your app won't be able to exit cleanly.
* "Agnes" <ag***@dynamictech.com.hk> scripsit: I need to disable the exit button in the form . However, the min. and max. button need to keep it
\\\
Private Declare Auto Function GetSystemMenu Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal bRevert As Int32 _
) As IntPtr
Private Declare Auto Function GetMenuItemCount Lib "user32.dll" ( _
ByVal hMenu As IntPtr _
) As Int32
Private Declare Auto Function DrawMenuBar Lib "user32.dll" ( _
ByVal hWnd As IntPtr _
) As Int32
Private Declare Auto Function RemoveMenu Lib "user32.dll" ( _
ByVal hMenu As IntPtr, _
ByVal nPosition As Int32, _
ByVal wFlags As Int32 _
) As Int32
Private Const MF_BYPOSITION As Int32 = &H400
Private Const MF_REMOVE As Int32 = &H1000
Private Sub RemoveCloseButton(ByVal frmForm As Form)
Dim hMenu As IntPtr, n As Int32
hMenu = GetSystemMenu(frmForm.Handle, 0)
If Not hMenu.Equals(IntPtr.Zero) Then
n = GetMenuItemCount(hMenu)
If n > 0 Then
RemoveMenu(hMenu, n - 1, MF_BYPOSITION Or MF_REMOVE)
RemoveMenu(hMenu, n - 2, MF_BYPOSITION Or MF_REMOVE)
DrawMenuBar(frmForm.Handle)
End If
End If
End Sub
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
* lucvdv <na**@null.net> scripsit: I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed.
Did you ever install MSDN? I remember, for some seconds, even the close
button is disabled. There are certain cases where this makes sense.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
* lucvdv <na**@null.net> scripsit: I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed.
Did you ever install MSDN? I remember, for some seconds, even the close
button is disabled. There are certain cases where this makes sense.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Hi Herfried, I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed.
Did you ever install MSDN? I remember, for some seconds, even the close button is disabled. There are certain cases where this makes sense.
What is the addition in this message from you, you write the same as lucvdv?
Cor
Hi Herfried, I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed.
Did you ever install MSDN? I remember, for some seconds, even the close button is disabled. There are certain cases where this makes sense.
What is the addition in this message from you, you write the same as lucvdv?
Cor
On 02 May 2004 21:17:56 +0200, hi***************@gmx.at (Herfried K.
Wagner [MVP]) wrote: * lucvdv <na**@null.net> scripsit: I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed.
Did you ever install MSDN? I remember, for some seconds, even the close button is disabled. There are certain cases where this makes sense.
I was just trying to warn Agnes that overzealous use of it can have
undesired side effects, especially users inventing their own way to
exit the application without giving it an opportunity to shut down
cleanly.
Also keep in mind that removing or disabling the close button doesn't
prevent the user from stopping it. If an application really should
run all the time, it can be better to split it up into a worker core
and a user interface, and let the core run as service.
As always there are exceptions - you just don't want to interrupt some
things (such as flashing new firmware into a piece of hardware).
Some of my own projects run as shell on XP Embedded, exiting them at
any time would be quite undesirable, but still I built in a hidden way
to do it.
Even the shell instance of Windows Explorer has always had an exit
mechanism. At first sight it has little or no use, but it used to
provide the fastest way to repair the damage if the ShellIconCache got
corrupted.
On 02 May 2004 21:17:56 +0200, hi***************@gmx.at (Herfried K.
Wagner [MVP]) wrote: * lucvdv <na**@null.net> scripsit: I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed.
Did you ever install MSDN? I remember, for some seconds, even the close button is disabled. There are certain cases where this makes sense.
I was just trying to warn Agnes that overzealous use of it can have
undesired side effects, especially users inventing their own way to
exit the application without giving it an opportunity to shut down
cleanly.
Also keep in mind that removing or disabling the close button doesn't
prevent the user from stopping it. If an application really should
run all the time, it can be better to split it up into a worker core
and a user interface, and let the core run as service.
As always there are exceptions - you just don't want to interrupt some
things (such as flashing new firmware into a piece of hardware).
Some of my own projects run as shell on XP Embedded, exiting them at
any time would be quite undesirable, but still I built in a hidden way
to do it.
Even the shell instance of Windows Explorer has always had an exit
mechanism. At first sight it has little or no use, but it used to
provide the fastest way to repair the damage if the ShellIconCache got
corrupted.
* "Cor Ligthert" <no**********@planet.nl> scripsit: I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed.
Did you ever install MSDN? I remember, for some seconds, even the close button is disabled. There are certain cases where this makes sense.
What is the addition in this message from you, you write the same as lucvdv?
It's a real-world example.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
* Lucvdv <re**********@null.net> scripsit: I need to disable the exit button in the form .
You can, but in 99% of applications you shouldn't. It's about the same as mounting a brick under a car's brake pedal to make sure it always goes fast enough.
That X isn't an exit button, it's a close button (it closes a window). Most VB applications do exit indeed when their last window is closed. Did you ever install MSDN? I remember, for some seconds, even the close button is disabled. There are certain cases where this makes sense.
I was just trying to warn Agnes that overzealous use of it can have undesired side effects, especially users inventing their own way to exit the application without giving it an opportunity to shut down cleanly.
OK.
Also keep in mind that removing or disabling the close button doesn't prevent the user from stopping it. If an application really should run all the time, it can be better to split it up into a worker core and a user interface, and let the core run as service.
A service for some simple work that should not be cancelled by the user?
As always there are exceptions - you just don't want to interrupt some things (such as flashing new firmware into a piece of hardware). Some of my own projects run as shell on XP Embedded, exiting them at any time would be quite undesirable, but still I built in a hidden way to do it.
;-)
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Herfried K. Wagner [MVP] wrote: A service for some simple work that should not be cancelled by the user?
It depends on the application.
All through this thread, a similar question that someome once
asked in one of the MS newsgroups kept coming back to memory: his
boss had asked him to write a program to log all applications
that were used on a system, and he needed a way to prevent users
from shutting down the logger.
* lucvdv <na**@null.net> scripsit: A service for some simple work that should not be cancelled by the user?
It depends on the application.
All through this thread, a similar question that someome once asked in one of the MS newsgroups kept coming back to memory: his boss had asked him to write a program to log all applications that were used on a system, and he needed a way to prevent users from shutting down the logger.
In this case, I would write a service ;-).
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Hi Lucvdv
That cannot be done in this way.
You can use the cancel in the taskmanager.
This kind of things have a simpler approach.
You set the start date and the end date in the log.
And tell that you check that with the payment system.
Cor
* "Cor Ligthert" <no**********@planet.nl> scripsit: That cannot be done in this way. You can use the cancel in the taskmanager.
You can start the service in the admin account, so the simple user
doesn't have the rights to stop it.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
> You can start the service in the admin account, so the simple user doesn't have the rights to stop it.
In windows W98 or in windows ME?
Cor
* "Cor Ligthert" <no**********@planet.nl> scripsit: You can start the service in the admin account, so the simple user doesn't have the rights to stop it.
In windows W98 or in windows ME?
Both of them are history...
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
> >> You can start the service in the admin account, so the simple user doesn't have the rights to stop it.
In windows W98 or in windows ME?
Both of them are history...
Full supported as far as it are no W2000 classes by the NET the same as VB
History?
Cor
* "Cor Ligthert" <no**********@planet.nl> scripsit: You can start the service in the admin account, so the simple user doesn't have the rights to stop it.
In windows W98 or in windows ME?
Both of them are history...
Full supported as far as it are no W2000 classes by the NET the same as VB
History?
Mhm... I don't know anybody who is still using Windows 98 and Windows Me.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
> >>> In windows W98 or in windows ME? Both of them are history...
Full supported as far as it are no W2000 classes by the NET the same as
VB History?
Mhm... I don't know anybody who is still using Windows 98 and Windows Me.
And you could not say that to Microsoft, they still are supporting W98 and
Windows Me and you do not know anybody who is still using it.
:-))))
Cor
My fiance uses WinME...
Just because I'm too broke to buy another license of XP =(
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c7***********@ID-208219.news.uni-berlin.de... * "Cor Ligthert" <no**********@planet.nl> scripsit:> You can start the service in the admin account, so the simple user > doesn't have the rights to stop it.
In windows W98 or in windows ME?
Both of them are history...
Full supported as far as it are no W2000 classes by the NET the same as
VB History?
Mhm... I don't know anybody who is still using Windows 98 and Windows Me.
-- Herfried K. Wagner [MVP] <URL:http://dotnet.mvps.org/>
* "Cor Ligthert" <no**********@planet.nl> scripsit: > In windows W98 or in windows ME?
Both of them are history...
Full supported as far as it are no W2000 classes by the NET the same as VB
History?
Mhm... I don't know anybody who is still using Windows 98 and Windows Me.
And you could not say that to Microsoft, they still are supporting W98 and Windows Me and you do not know anybody who is still using it.
If my customers don't use it, why design applications for it?
;-)))
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: s-galit |
last post by:
im using "Error Provider" in my form ,
the problem is that when im trying to exit the program by the exit button on
the title bar im getting disturbed by the error provider so i cant exit the...
|
by: Brett |
last post by:
What is the C# equivalent of VB.NET's Exit Sub?
Thanks,
Brett
|
by: Agnes |
last post by:
I need to disable the exit button in the form .
However, the min. and max. button need to keep it
How ?
Thanks a lot
From Agnes
|
by: ern |
last post by:
Right now I'm using exit(0) to terminate my program. My
program is a console .exe application. After the "exit(0)" line of
code is encountered, the console application waits for an enter press,...
|
by: Serious_Practitioner |
last post by:
Good day, and thank you in advance for any assistance. I'm having trouble
with something that I'm trying for the first time.
Using Access 2000 - I want to run a function either on the click of a...
|
by: Pete |
last post by:
Hi All,
I'm new to this so please correct me if I'm wrong. I have written a
small program which holds details for task information. the program
holds an email address, i created a button which...
|
by: Vincent Delporte |
last post by:
Hi
I'm a Python newbie, and would like to rewrite this Perl scrip
to be run with the Asterisk PBX:
http://www.voip-info.org/wiki/view/Asterisk+NetCID
Anyone knows if those lines are...
|
by: JEJE |
last post by:
To All,
What is the difference between the following Exit code??
Exit (0)??
Exit(1)??
Exit (2)??
|
by: dstork |
last post by:
Anyone know how to rename the "Exit Access" command at the bottom of
the Office menu. I'd like to rename it to "Exit" as I had done in
previous versions of Access. I know I can disable it with
...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |