질문하기질문하기
 

제안된 답변Message box close icon

  • 2008년 9월 15일 월요일 오후 1: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일 월요일 오후 2: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

    • 답변으로 제안됨Nikita Leontiev 2009년 11월 4일 수요일 오전 11:56
    •  
  • 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.