Game Development Reference
In-Depth Information
LRESULT CALLBACK MessageBox::VOnMsgProc( AppMsg msg )
{
return m_UI.MsgProc( msg.m_hWnd, msg.m_uMsg, msg.m_wParam, msg.m_lParam );
}
The only thing left to handle is the processing of the control messages. In the case of
a message box, the only thing you need to do is send the button result back to a place
so that you can grab it later. We
'
ll do that by posting a custom Windows message
into the message pump:
void CALLBACK CMessageBox::OnGUIEvent( UINT nEvent, int nControlID,
CDXUTControl* pControl )
{
PostMessage(g_pApp->GetHwnd(), G_MSGENDMODAL, 0, nControlID);
}
This might seem confusing at first. Why not just set the member variable in the dialog
box class that holds the last button the player selected? The answer lies in how you have
to go about creating a modal dialog box in games, which is our very next subject.
Modal Dialog Boxes
Modal dialog boxes usually present the player with a question, such as Do you really
want to quit?
In most cases, the game stops while the dialog box is displayed so the
player can answer the question (see Figure 10.2). The answer is usually immediately
accepted by the game.
Figure 10.2
A modal dialog box.
 
 
Search WWH ::




Custom Search