Solved

Disable x-box (exit) on Property Sheet?

Posted on 1998-10-07
4
193 Views
Last Modified: 2013-12-03
Is there a way to disable the functionality of the little "X-Box" on the top right of the dialog? This X-Box is the button that acts identical to the CANCEL button.
I am using Visual C++ (although all my code is written in C - so I'm not using any classes (e.g. MFC))!

Thanx in advance
0
Comment
Question by:nweiher
4 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1415053
Do you mean your own dialog box (should be easy) or do you mean the dialog box of another process (a little bit more difficult).

Regards, Madshi.
0
 

Author Comment

by:nweiher
ID: 1415054
My own dialog box ...
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 1415055
1. To hide and disable the button make sure the WS_SYSMENU style isn't set for the property sheet

2. If you want to handle the user clicking on this button and do something different (e.g. do nothing) process the WM_SYSCOMMAND message.

There is no disabled appearance for this button built-in to Windows (you could simulate it by handling the WM_NCPAINT message and paiting non-client areas of the property sheet, but I wouldn't advise it).  The normal convention in Windows is not have this button (solution #1) if you don't need it.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1415056
Answer2000, It seems you are wrong. I've prepared the answer, submit it, but you was the first :(

LONG oldstyle;

. DialogProc(HWND dlg,UINT hMsg,...)
{
  ...
case WM_INITDIALOG:
  oldstyle=GetClassLong(dlg,GCL_STYLE);
  SetClassLong(dlg,GCL_STYLE,oldstyle | CS_NOCLOSE);
  ...
case WM_DESTROY:
  SetClassLong(dlg,GCL_STYLE,oldstyle);
  ...
}

Keep in mind, we are modifying the dialog class, so it can affect all dialogs in your app.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now