Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: Removing the cross from a form Pin
exhaulted21-Sep-04 6:27
exhaulted21-Sep-04 6:27 
GeneralRe: Removing the cross from a form Pin
Stefan Troschuetz21-Sep-04 8:16
Stefan Troschuetz21-Sep-04 8:16 
GeneralRe: Removing the cross from a form Pin
exhaulted21-Sep-04 21:44
exhaulted21-Sep-04 21:44 
GeneralRe: Removing the cross from a form Pin
Stefan Troschuetz21-Sep-04 22:02
Stefan Troschuetz21-Sep-04 22:02 
GeneralRe: Removing the cross from a form Pin
exhaulted22-Sep-04 1:40
exhaulted22-Sep-04 1:40 
GeneralRe: Removing the cross from a form Pin
Stefan Troschuetz22-Sep-04 3:40
Stefan Troschuetz22-Sep-04 3:40 
GeneralRe: Removing the cross from a form Pin
exhaulted22-Sep-04 4:06
exhaulted22-Sep-04 4:06 
GeneralRe: Removing the cross from a form Pin
Stefan Troschuetz22-Sep-04 4:35
Stefan Troschuetz22-Sep-04 4:35 
I see the point.

exhaulted wrote:
To be able to do that however i need to do 2 things.

1. Disable the cross on the form.
2. Disabel the Alt + F4 shortcut.


I hope number 1 can be solved nice with the answer given in thread I linked to. If not we solve it the same as number 2.
As I already said the easiest way would be declaring a private bool in your form which then will be checked inside the event handler for the closing event.
For example the bool is initialized false and in this case the event handler cancels the Closing event. The only way to set this bool true is clicking the button, you mentioned, and entering the right password.

class YourForm
{
private bool shutDown = false;

void button_click(...)
{
// Prompting for password and evaluate.
if (passwordCorrect == true)
{
shutDown = true;
this.Close;
}
}

void form_Closing(...)
{
if (!shutDown)
e.Cancel = true;
}
}


This leaves us with the problem of shutting down / logging off. Don't know a exact solution for this one. Maybe you could use the sender object, you receive with the form_Closing event handler, to determine whether the close event was triggered by one of those events.

P.S: The code snippet should only concretize what I'm talking about. Doesn't spend much time to bring it into right syntax.







www.troschuetz.de
GeneralRe: Removing the cross from a form Pin
exhaulted22-Sep-04 4:48
exhaulted22-Sep-04 4:48 
GeneralRe: Removing the cross from a form Pin
Stefan Troschuetz22-Sep-04 4:59
Stefan Troschuetz22-Sep-04 4:59 
AnswerRe: Removing the cross from a form Pin
walterhuang29-May-06 20:42
walterhuang29-May-06 20:42 
QuestionBest Practice - Webservice, Stored Procedure, both? Pin
KoalaCowboy21-Sep-04 3:32
KoalaCowboy21-Sep-04 3:32 
AnswerRe: Best Practice - Webservice, Stored Procedure, both? Pin
Heath Stewart21-Sep-04 6:52
protectorHeath Stewart21-Sep-04 6:52 
GeneralRe: Best Practice - Webservice, Stored Procedure, both? Pin
KoalaCowboy21-Sep-04 8:29
KoalaCowboy21-Sep-04 8:29 
GeneralRe: Best Practice - Webservice, Stored Procedure, both? Pin
Heath Stewart21-Sep-04 10:52
protectorHeath Stewart21-Sep-04 10:52 
GeneralRe: Best Practice - Webservice, Stored Procedure, both? Pin
KoalaCowboy21-Sep-04 10:56
KoalaCowboy21-Sep-04 10:56 
GeneralInsert a frequency time delay into a ThreadPool Pin
Fahad sarwar21-Sep-04 2:50
Fahad sarwar21-Sep-04 2:50 
Generalcatching control.name change Pin
ShakerWD20-Sep-04 23:55
ShakerWD20-Sep-04 23:55 
GeneralRe: catching control.name change Pin
sreejith ss nair21-Sep-04 0:20
sreejith ss nair21-Sep-04 0:20 
GeneralRe: catching control.name change Pin
ShakerWD21-Sep-04 1:26
ShakerWD21-Sep-04 1:26 
GeneralRe: catching control.name change Pin
ShakerWD21-Sep-04 9:11
ShakerWD21-Sep-04 9:11 
GeneralRe: catching control.name change Pin
Dave Kreskowiak21-Sep-04 9:44
mveDave Kreskowiak21-Sep-04 9:44 
GeneralRe: catching control.name change Pin
ShakerWD21-Sep-04 9:55
ShakerWD21-Sep-04 9:55 
Generalchanging RowState of DataRow Pin
TehMedic20-Sep-04 23:31
TehMedic20-Sep-04 23:31 
GeneralRe: changing RowState of DataRow Pin
Sendilkumar.M21-Sep-04 0:24
Sendilkumar.M21-Sep-04 0:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.