提出问题提出问题
 

建议的答复Message box close icon

  • 2008年9月15日 13:59hari4u6 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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

全部回复

  • 2008年9月15日 14:52Nick Meyer 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     建议的答复
    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

  • 2008年9月16日 1:54nobugzMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    It's pretty simple:

      if (IDYES != MessageBox(...))
        return;

    Hans Passant.
  • 2008年9月16日 5:43hari4u6 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    no,
        buddy it still the same..
    anyway thanx for the reply..

    harish
  • 2009年11月4日 11:16Alka Dua 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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
  • 2009年11月4日 11:54.Sreedhar 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    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
  • 2009年11月4日 11:58Nikita Leontiev 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    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.