Solved

Disable x-box (exit) on Property Sheet?

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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