How can i prevent Alt+F4, closing a dialog?

Reply

Join Date: Jul 2007
Posts: 31
Reputation: risa is an unknown quantity at this point 
Solved Threads: 1
risa risa is offline Offline
Light Poster

How can i prevent Alt+F4, closing a dialog?

 
0
  #1
Mar 6th, 2009
How can i prevent a dialog closing by Alt+F4 ?
I am using PreTranslateMessage(),,,,what is the Virtual key #define for Alt+F4 or is there any other way?,,,,thank you
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #2
Mar 6th, 2009
It's a combination of the F4 key code combined with the alt modifiers, you need to check both.

But i'd avoid trying to prevent it if I was you....
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 360
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #3
Mar 6th, 2009
If I remember correctly, Alt+F4 never reaches PreTranslateMessage()
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 476
Reputation: nucleon has a spectacular aura about nucleon has a spectacular aura about 
Solved Threads: 91
nucleon's Avatar
nucleon nucleon is offline Offline
Posting Pro in Training

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #4
Mar 6th, 2009
Here's the list of virtual key codes. jencas makes a good point that I was wondering about myself. Still, give it a try and let us know what happens.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 1,294
Reputation: mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold 
Solved Threads: 267
mitrmkar mitrmkar is offline Offline
Nearly a Posting Virtuoso

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #5
Mar 6th, 2009
Originally Posted by risa View Post
How can i prevent a dialog closing by Alt+F4 ?
I am using PreTranslateMessage()
Instead of PreTranslateMessage(), add a handler for WM_SYSCOMMAND and detect SC_CLOSE.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 212
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #6
Mar 6th, 2009
You sure it's not WM_CLOSE?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 1,294
Reputation: mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold 
Solved Threads: 267
mitrmkar mitrmkar is offline Offline
Nearly a Posting Virtuoso

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #7
Mar 6th, 2009
Originally Posted by Comatose View Post
You sure it's not WM_CLOSE?
Yes, SC_CLOSE comes with WM_SYSCOMMAND.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,522
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 127
William Hemsworth William Hemsworth is offline Offline
Posting Virtuoso

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #8
Mar 6th, 2009
Seems pretty simple to me, add this to the dialog message procedure, and windows shouldn't handle the ALT-F4.
  1. case WM_SYSKEYDOWN: break;
Last edited by William Hemsworth; Mar 6th, 2009 at 11:22 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 1,294
Reputation: mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold mitrmkar is a splendid one to behold 
Solved Threads: 267
mitrmkar mitrmkar is offline Offline
Nearly a Posting Virtuoso

Re: How can i prevent Alt+F4, closing a dialog?

 
0
  #9
Mar 6th, 2009
Originally Posted by William Hemsworth View Post
Seems pretty simple to me, add this to the dialog message procedure, and windows shouldn't handle the ALT-F4.
  1. case WM_SYSKEYDOWN: break;
Hmm .. that renders the system menu completely ineffective, which is probably not what the OP wants.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 985 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC