Click here to Skip to main content
15,916,042 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: How to intercept Console Window Close Event Pin
Programm3r14-Mar-07 0:49
Programm3r14-Mar-07 0:49 
Question[Message Deleted] Pin
kakan14-Mar-07 0:56
professionalkakan14-Mar-07 0:56 
AnswerRe: How to intercept Console Window Close Event Pin
Cedric Moonen14-Mar-07 1:08
Cedric Moonen14-Mar-07 1:08 
GeneralRe: How to intercept Console Window Close Event Pin
kakan14-Mar-07 1:11
professionalkakan14-Mar-07 1:11 
AnswerRe: How to intercept Console Window Close Event Pin
Stephen Hewitt14-Mar-07 3:47
Stephen Hewitt14-Mar-07 3:47 
AnswerRe: How to intercept Console Window Close Event Pin
Stephen Hewitt14-Mar-07 3:53
Stephen Hewitt14-Mar-07 3:53 
GeneralRe: How to intercept Console Window Close Event Pin
Programm3r15-Mar-07 19:49
Programm3r15-Mar-07 19:49 
AnswerRe: How to intercept Console Window Close Event Pin
prasad_som14-Mar-07 7:49
prasad_som14-Mar-07 7:49 
Use HandlerRoutine and SetConsoleCtrlHandler.
Following is example from MSDN,
#include <windows.h> 
#include <stdio.h> 
 
BOOL CtrlHandler( DWORD fdwCtrlType ) 
{ 
  switch( fdwCtrlType ) 
  { 
    // Handle the CTRL-C signal. 
    case CTRL_C_EVENT: 
      printf( "Ctrl-C event\n\n" );
      Beep( 750, 300 ); 
      return( TRUE );
 
    // CTRL-CLOSE: confirm that the user wants to exit. 
    case CTRL_CLOSE_EVENT: 
      Beep( 600, 200 ); 
      printf( "Ctrl-Close event\n\n" );
      return( TRUE ); 
 
    // Pass other signals to the next handler. 
    case CTRL_BREAK_EVENT: 
      Beep( 900, 200 ); 
      printf( "Ctrl-Break event\n\n" );
      return FALSE; 
 
    case CTRL_LOGOFF_EVENT: 
      Beep( 1000, 200 ); 
      printf( "Ctrl-Logoff event\n\n" );
      return FALSE; 
 
    case CTRL_SHUTDOWN_EVENT: 
      Beep( 750, 500 ); 
      printf( "Ctrl-Shutdown event\n\n" );
      return FALSE; 
 
    default: 
      return FALSE; 
  } 
} 
 
void main( void ) 
{ 
  if( SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ) ) 
  { 
    printf( "\nThe Control Handler is installed.\n" ); 
    printf( "\n -- Now try pressing Ctrl+C or Ctrl+Break, or" ); 
    printf( "\n    try logging off or closing the console...\n" ); 
    printf( "\n(...waiting in a loop for events...)\n\n" ); 
 
    while( 1 ){ } 
  } 
  else 
    printf( "\nERROR: Could not set control handler"); 
}



GeneralRe: How to intercept Console Window Close Event Pin
Stephen Hewitt14-Mar-07 12:54
Stephen Hewitt14-Mar-07 12:54 
GeneralRe: How to intercept Console Window Close Event Pin
prasad_som14-Mar-07 18:08
prasad_som14-Mar-07 18:08 
GeneralRe: How to intercept Console Window Close Event Pin
Programm3r15-Mar-07 19:49
Programm3r15-Mar-07 19:49 
GeneralRe: How to intercept Console Window Close Event Pin
prasad_som15-Mar-07 19:56
prasad_som15-Mar-07 19:56 
QuestionCursor help Pin
rushiraj.jhala13-Mar-07 23:28
rushiraj.jhala13-Mar-07 23:28 
AnswerRe: Cursor help Pin
Parthi_Appu14-Mar-07 0:36
Parthi_Appu14-Mar-07 0:36 
GeneralRe: Cursor help Pin
rushiraj.jhala14-Mar-07 0:58
rushiraj.jhala14-Mar-07 0:58 
GeneralRe: Cursor help Pin
_AnsHUMAN_ 14-Mar-07 1:10
_AnsHUMAN_ 14-Mar-07 1:10 
GeneralRe: Cursor help Pin
rushiraj.jhala14-Mar-07 1:56
rushiraj.jhala14-Mar-07 1:56 
AnswerRe: Cursor help Pin
Parthi_Appu14-Mar-07 2:30
Parthi_Appu14-Mar-07 2:30 
GeneralRe: Cursor help Pin
_AnsHUMAN_ 14-Mar-07 2:48
_AnsHUMAN_ 14-Mar-07 2:48 
GeneralRe: Cursor help Pin
Parthi_Appu14-Mar-07 3:01
Parthi_Appu14-Mar-07 3:01 
GeneralRe: Cursor help Pin
rushiraj.jhala14-Mar-07 2:52
rushiraj.jhala14-Mar-07 2:52 
QuestionProblem with Release version Pin
ilgale13-Mar-07 22:54
ilgale13-Mar-07 22:54 
AnswerRe: Problem with Release version Pin
Paresh Chitte13-Mar-07 23:00
Paresh Chitte13-Mar-07 23:00 
AnswerRe: Problem with Release version [modified] Pin
Roger Stoltz13-Mar-07 23:01
Roger Stoltz13-Mar-07 23:01 
GeneralRe: Problem with Release version Pin
Cedric Moonen13-Mar-07 23:04
Cedric Moonen13-Mar-07 23:04 

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.