Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Disable the 'X' button on the titlebar of a dialog box

Posted on 1999-07-22
Medium Priority
Last Modified: 2010-04-16
    In a VC++ application, the 'X' button of the Dialog's titlebar is required to be disabled. This cannot be set directly in the dialog's property. Is there any othere programmatical way of disabling it??
Please reply me as soon as possible as it is very urgent.
Question by:bmuralimohan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Laminamia063099 earned 20 total points
ID: 1200802
Yes, you need to hook the dialog box's WM_NCHITEST messages, send them through the DefWindowProc, which will return where the mouse hit.  The return value of the DefWindowProc (call it from your switch statement on WM_NCHITTEST) will be the position of the mouse action.  You need to check to see if it's HT_SYSMENU, and if so, take no action and return, disabling this message.  

If this is unsatisfactory, say so and there are other ways of doing it, but this is easy to code and quick. :)

LVL 22

Expert Comment

ID: 1200803
There is a better way

This is done through a round-about means.  You must disable the close menu option of the window's system menu, then the button will be disabled. Use

HMENU SysMen = GetSystemMenu(WndHnd,false); // >> window's system menu.


Expert Comment

ID: 1200804
I stand corrected.  There is a better way :)

Thanks nietod.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question