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

x
?
Solved

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

Posted on 1999-07-22
3
Medium Priority
?
262 Views
Last Modified: 2010-04-16
Hi,
    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.
Thanks
0
Comment
Question by:bmuralimohan
[X]
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
3 Comments
 
LVL 3

Accepted Solution

by:
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. :)

Laminamia
0
 
LVL 22

Expert Comment

by:nietod
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.

EnableMenuItem(SysMen,SC_CLOSE,MF_BYCOMMAND | MF_DISABLED);
0
 
LVL 3

Expert Comment

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

Thanks nietod.
0

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