#include <windows.h>
/*--------------------按钮-----------------------------
#define MB_OK              0x00000000L

#define MB_OKCANCEL            0x00000001L
    
#define MB_ABORTRETRYIGNORE        0x00000002L
  
#define MB_YESNOCANCEL          0x00000003L
    
#define MB_YESNO            0x00000004L
    
#define MB_RETRYCANCEL          0x00000005L
------------------------------------------------------*/


/*---------------------默认按钮--------------------------------
#define         MB_DEFBUTTON1                                                                                0x00000000L

#define         MB_DEFBUTTON2                                                                                0x00000100L
    
#define         MB_DEFBUTTON3                                                                                0x00000200L
  
#define         MB_DEFBUTTON4                                                                                0x00000300L
-------------------------------------------------------------*/


/*-----------------------图标---------------------------------------
#define MB_ICONHAND                0x00000010L

#define MB_ICONQUESTION              0x00000020L
    
#define MB_ICONEXCLAMATION            0x00000030L
  
#define MB_ICONASTERISK              0x00000040L

or

#define         MB_ICONWARNING                                MB_ICONEXCLAMATION
    
#define         MB_ICONERROR                                    MB_ICONHAND
  
#define         MB_ICONINFORMATION                        MB_ICONASTERISK
    
#define         MB_ICONSTOP                                     MB_ICONHAND
------------------------------------------------------------------*/


/*-----------------------------------------------------------------
0x00000001                                            00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001    
0x00000002            00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000010
0x00000003            00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000011
0x00000004            00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000100
0x00000005            00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000101
    
0x00000010            00000000 00000000 00000000 00000000 00000000 00000000 00000001 00000000
0x00000020            00000000 00000000 00000000 00000000 00000000 00000000 00000010 00000000
0x00000030            00000000 00000000 00000000 00000000 00000000 00000000 00000011 00000000
0x00000040            00000000 00000000 00000000 00000000 00000000 00000000 00000100 00000000
  
0x00000100            00000000 00000000 00000000 00000000 00000000 00000001 00000000 00000000
0x00000200            00000000 00000000 00000000 00000000 00000000 00000010 00000000 00000000
0x00000300            00000000 00000000 00000000 00000000 00000000 00000011 00000000 00000000
0x00000400            00000000 00000000 00000000 00000000 00000000 00000100 00000000 00000000
-------------------------------------------------------------------*/


#define    MAX_MESSAGEBOX_BUTTON_NUM  6
#define    MAX_MESSAGEBOX_DEFAULT_BUTTOM_NUM  4
#define    MAX_MESSAGEBOX_ICON_NUM    4

UINT MessageBoxButton[] =
{
  MB_OK,
  MB_OKCANCEL,
  MB_ABORTRETRYIGNORE,
  MB_YESNOCANCEL,
  MB_YESNO,
  MB_RETRYCANCEL
};

UINT MessageBoxDefaultButton[] =
{
  MB_DEFBUTTON1,
  MB_DEFBUTTON2,
  MB_DEFBUTTON3,
  MB_DEFBUTTON4
};

UINT MessageBoxIcon[] =
{
  MB_ICONHAND,
  MB_ICONQUESTION,
  MB_ICONEXCLAMATION,
  MB_ICONASTERISK
};

/*共有的情况总数为6*4*4 = 96种*/
int MyMessageBox(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT UType)
{
  UINT myType = 0;
  
  for (int i = 0; i < MAX_MESSAGEBOX_BUTTON_NUM; ++i)
  {
    /*这里判断出来了按钮风格*/
    if (MessageBoxButton[i] == (UType & 0xF))
    {
      myType = MessageBoxButton[i];
      break;
    }
  }

  for (int j = 0; j < MAX_MESSAGEBOX_DEFAULT_BUTTOM_NUM; ++j)
  {
    /*这里判断出来了默认按钮*/
    if (MessageBoxDefaultButton[j] == (UType & 0xF00))
    {
      myType |= MessageBoxDefaultButton[j];
      break;
    }
  }

  for (int k = 0; k < MAX_MESSAGEBOX_ICON_NUM; ++k)
  {
    /*这里判断出来了显示图标*/
    if (MessageBoxIcon[k] == (UType & 0xF0))
    {
      myType |= MessageBoxIcon[k];
      break;
    }
  }

  return  MessageBox(hWnd,lpText,lpCaption,myType);
}

int APIENTRY WinMain(HINSTANCE hInstance,
                                         HINSTANCE hPrevInstance,
                                         LPSTR         lpCmdLine,
                                         int             nCmdShow)
{
    // TODO: Place code here.
  
  MyMessageBox(NULL,("我要努力!!!"), ("ihome"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);
  return 0;
}