Game Development Reference
In-Depth Information
public:
MessageBox(std::wstring msg, std::wstring title, int buttonFlags=MB_OK);
˜
MessageBox();
// IScreenElement Implementation
virtual HRESULT VOnRestore();
virtual HRESULT VOnRender(double fTime, float fElapsedTime);
virtual int VGetZOrder() const { return 99; }
virtual void VSetZOrder(int const zOrder) { }
virtual bool VIsVisible() const { return true; }
virtual void VSetVisible(bool visible) { }
virtual LRESULT CALLBACK VOnMsgProc( AppMsg msg );
static void CALLBACK OnGUIEvent(
UINT nEvent, int nControlID, CDXUTControl* pControl );
static int Ask(MessageBox_Questions question);
};
The class design is pretty simple. It inherits from a base implementation of the
IScreenElement interface, which has a few member variables to keep track of the
size, position, and dialog result. The MessageBox class adds a DXUT member, CDXUT-
Dialog, to manage the rendering and messaging for the dialog box. The constructor sets
the callback routine and creates controls for the static text message and the buttons:
MessageBox::MessageBox(std::wstring msg, std::wstring title, int buttonFlags)
{
// Initialize dialogs
m_UI.Init( &DirectXHumanView::g_DialogResourceManager );
m_UI.SetCallback( OnGUIEvent );
// Find the dimensions of the message
RECT rc;
SetRect( &rc, 0,0,0,0);
m_UI.CalcTextRect( msg.c_str(),
m_UI.GetDefaultElement(DXUT_CONTROL_STATIC,0), &rc );
int msgWidth = rc.right - rc.left;
int msgHeight = rc.bottom - rc.top;
int numButtons = 2;
if ( (buttonFlags == MB_ABORTRETRYIGNORE) ||
(buttonFlags == MB_CANCELTRYCONTINUE) ||
(buttonFlags == MB_CANCELTRYCONTINUE) )
{
numButtons = 3;
}
Search WWH ::




Custom Search