Disabling WM_Close

This is a discussion on Disabling WM_Close within the Windows Programming forums, part of the Platform Specific Boards category; Hi, first i would like to thank everyone who helped me solve my compiler problem. Second, i would like to ...

  1. #1

    Disabling WM_Close

    Hi, first i would like to thank everyone who helped me solve my compiler problem. Second, i would like to know how to disable closing the dialog box by pressing the X (close icon). I know that when i select how to handle WM_Close is when to disable it, but i'm wondering how. If i ignore it will it just do the default and close the program? Thanks in advance for your help.

  2. #2
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    just do

    case WM_CLOSE:
    return TRUE;

    or something like that

  3. #3
    Registered User WayTooHigh's Avatar
    Join Date
    Aug 2001
    this should work! dont process WM_CLOSE in WndProc. the only problem is your program wont close unless use a menu item or something.
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    	case WM_COMMAND:
    		// menu item
    		case IDM_EXIT:
    		return TRUE;
    	// try doing this for your default
    		if(Message != WM_CLOSE)
    			return DefWindowProc(hwnd, Message, wParam, lParam);
    	return 0;
    Sometimes, the farthest point from the center is the center itself.

    Your life is your canvas, it's only as beautiful as you paint it.

  4. #4
    Programming is fun, mkay?
    Join Date
    Oct 2001

    Lightbulb It's simple!

    In your WndProc, just add this to your WM_CREATE:

    SetWindowLong(hwnd, GCL_STYLE, CS_NOCLOSE);
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Why would you want to disable closing.

  6. #6
    i want to disable it because i'm creating a login program, i want the only way for the dialog to be closed is through normal termination, ie:entering the correct password and clicking ok.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. disabling ALL keys?
    By elfjuice in forum C++ Programming
    Replies: 2
    Last Post: 04-30-2005, 02:58 PM
  2. Disabling Some Autoscroll Functionality
    By McClamm in forum C# Programming
    Replies: 3
    Last Post: 09-10-2004, 01:36 PM
  3. Disabling a listitem
    By knutso in forum Windows Programming
    Replies: 3
    Last Post: 02-21-2004, 09:39 PM
  4. disabling system keys in a windows console
    By Shadow in forum Windows Programming
    Replies: 3
    Last Post: 06-23-2002, 07:06 PM
  5. MFC Radio-Buttons Disabling
    By The Dog in forum Windows Programming
    Replies: 0
    Last Post: 06-09-2002, 02:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21