Message box close icon
- Hi,How can I enable my close icon on message box..I'm using the following code for which my close icon is disabled....if(IDNO == MessageBox("Are you sure you want to exit?","Confirm",MB_YESNO | MB_ICONQUESTION)){return;}I want to enable my close icon or close box ..When am using MB_YESNOCANCEL am getting three push buttons ...Is there anyway to solve this??Thanks in advance,Hari.
harish
全部回复
- I don't believe there is any way to create a MessageBox with the close box enabled when using MB_YESNO. In order for the close box to be enabled, you must be using a MessageBox with a "Cancel" button (MB_OK, MB_OKCANCEL, MB_YESNOCANCEL), because clicking on the close button is equivalent to clicking "Cancel". If you want to have only "Yes" and "No" buttons but with an enabled close box, you could simulate it yourself with a modal dialog.
Hope that helps,
Nick
- 已建议为答案Nikita Leontiev 2009年11月4日 11:56
- It's pretty simple:
if (IDYES != MessageBox(...))
return;
Hans Passant. - no,
buddy it still the same..
anyway thanx for the reply..
harish - Hi Harish,
Did you find any solution to this problem. Even I want to create a messagebox with yes/no buttons, with the close button enabled and no cancel button.
Thanks in advance
~alka You can use
MessageBox("Are you sure you want to exit?","Confirm",MB_DEFBUTTON1 | MB_ICONQUESTION);
It shows only OK button and enables System menu's Cancel button on Title bar
If you want to have YES NO with cancel button enabled on System menu, design your own dialog to do so. Since option 'NO' is not equal to Cancel.
Knowledge is like light; It spreads only when you have clear and transparent mind. - Sreedhar Dv- Nick Meyer already gave correct answer.
If you want to use Yes and No buttons and want X button to be enabled, you should use MB_YESNOCANCEL or create your custom dialog.
If Yes and No buttons are not required, use MB_OKCANCEL.

