Solved

Disable x-box (exit) on Property Sheet?

Posted on 1998-10-07
4
192 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

11 Experts available now in Live!

Get 1:1 Help Now