Click here to Skip to main content
16,004,924 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to control page number when printing Pin
David Crow1-May-03 3:54
David Crow1-May-03 3:54 
GeneralRe: how to control page number when printing Pin
hu_jia1-May-03 5:36
hu_jia1-May-03 5:36 
GeneralRe: how to control page number when printing Pin
David Crow1-May-03 5:42
David Crow1-May-03 5:42 
GeneralRe: how to control page number when printing Pin
hu_jia1-May-03 5:48
hu_jia1-May-03 5:48 
GeneralConsole App Pin
John L. DeVito30-Apr-03 6:15
professionalJohn L. DeVito30-Apr-03 6:15 
GeneralRe: Console App Pin
David Crow30-Apr-03 6:26
David Crow30-Apr-03 6:26 
GeneralRe: Console App Pin
John L. DeVito30-Apr-03 8:38
professionalJohn L. DeVito30-Apr-03 8:38 
GeneralRe: Console App Pin
Chris Richardson30-Apr-03 22:24
Chris Richardson30-Apr-03 22:24 
Here's one solution for disabling the Close button:

#include <tchar.h>

BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam )
{
   TCHAR a_szClass[64] = {0};
   ::GetClassName( hwnd, a_szClass, 63 );
   // Check if the passed in window is a console window.
   if( !_tcsicmp( a_szClass, _T("ConsoleWindowClass") ) )
   {
      DWORD a_dwWindowThread = ::GetWindowThreadProcessId( hwnd, NULL );
      
      // Check if the console window is the one we are running in...wouldn't want to remove another console's close button.
      if( a_dwWindowThread == ::GetCurrentThreadId() )
      {
         // We found our console window.
         *((HWND*)lParam) = hwnd;
         
         // We are done searching.
         return FALSE;
      }
   }

   // Continue the search.
   return TRUE;
}

void RemoveYourConsoleCloseButton()
{
   // Search for our console window.  We could do this using GetConsoleWindow, but that function is supported only
   // on Win2K and later, and not at all on 9X systems.
   HWND a_hThisConsoleWindow = NULL;
   ::EnumWindows( EnumWindowsProc, (LPARAM)&a_hThisConsoleWindow );

   if( a_hThisConsoleWindow )
   {
      // We found the console window...now disable the close button.
      HMENU a_hMenu = ::GetSystemMenu( a_hThisConsoleWindow, FALSE );
      if( a_hMenu )
      {
         // Removing the SC_CLOSE system menu item will disable the Close button.
         ::RemoveMenu( a_hMenu, SC_CLOSE, MF_BYCOMMAND );
         
         // Redraw the frame so the X button is redrawn.
         ::SetWindowPos( a_hThisConsoleWindow, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_DRAWFRAME );
      }
   }
}


When you want to disable the close button, call RemoveYourConsoleCloseButton().

Chris Richardson

You can stash and you can seize
In dreams begin, responsibilities

U2 - Acrobat[^]


Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your Beer | [beer] - Rohit Sinha in the content-challenged thread
GeneralWindows Network API Question Pin
rpace30-Apr-03 5:45
sussrpace30-Apr-03 5:45 
GeneralRe: Windows Network API Question Pin
Baris Kurtlutepe30-Apr-03 12:03
Baris Kurtlutepe30-Apr-03 12:03 
GeneralCCheckListBox Pin
Michael P Butler30-Apr-03 5:33
Michael P Butler30-Apr-03 5:33 
GeneralRe: CCheckListBox Pin
Rage30-Apr-03 5:37
professionalRage30-Apr-03 5:37 
GeneralGetActiveObject fails with IE. Pin
rdautel30-Apr-03 5:17
rdautel30-Apr-03 5:17 
GeneralRe: GetActiveObject fails with IE. Pin
Chris Richardson30-Apr-03 22:29
Chris Richardson30-Apr-03 22:29 
GeneralQuestion mark icon in title bar Pin
JensB30-Apr-03 4:18
JensB30-Apr-03 4:18 
GeneralRe: Question mark icon in title bar Pin
David Crow30-Apr-03 4:48
David Crow30-Apr-03 4:48 
GeneralRe: Question mark icon in title bar Pin
JensB30-Apr-03 4:53
JensB30-Apr-03 4:53 
GeneralRe: Question mark icon in title bar Pin
David Crow30-Apr-03 4:57
David Crow30-Apr-03 4:57 
GeneralRe: Question mark icon in title bar Pin
JensB30-Apr-03 6:28
JensB30-Apr-03 6:28 
GeneralRe: Question mark icon in title bar Pin
David Crow30-Apr-03 8:52
David Crow30-Apr-03 8:52 
GeneralRe: Question mark icon in title bar Pin
Michael Dunn1-May-03 0:29
sitebuilderMichael Dunn1-May-03 0:29 
GeneralRe: Question mark icon in title bar Pin
JensB1-May-03 23:34
JensB1-May-03 23:34 
General3 Tier Question Pin
nlecren30-Apr-03 3:14
nlecren30-Apr-03 3:14 
GeneralRe: 3 Tier Question Pin
David Crow30-Apr-03 3:26
David Crow30-Apr-03 3:26 
GeneralRe: 3 Tier Question Pin
nlecren30-Apr-03 3:42
nlecren30-Apr-03 3:42 

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.