Game Development Reference
In-Depth Information
struct AppMsg
{
HWND m_hWnd;
UINT m_uMsg;
WPARAM m_wParam;
LPARAM m_lParam;
};
A Custom MessageBox Dialog
The best way to show you how this works is by example. Let ' s create a simple mes-
sage box that your game can call instead of the MessageBox API. The code for this
uses the DirectX GUI framework that is defined in DXUTgui.h . Word to the wise:
The DirectX GUI framework is a great start for a game interface, but it does make
some assumptions about how you want to load textures and some other quirks. On
the other hand, it sure keeps you from having to write a text edit control from
scratch. If you simply hate DirectX, and you are sufficiently motivated, just surgically
remove the DirectX components and roll your own.
This message box class conforms pretty well with the Windows MessageBox API.
You send in a text message and what kind of buttons you want, and the dialog will
store the ID of the control that was pressed:
class BaseUI : public IScreenElement
{
protected:
int m_PosX, m_PosY;
int m_Width, m_Height;
optional<int> m_Result;
bool m_bIsVisible;
public:
BaseUI()
{ m_bIsVisible = true; m_PosX = m_PosY = 0; m_Width = 100; m_Height = 100; }
virtual void VOnUpdate(int) { };
virtual bool VIsVisible() const { return m_bIsVisible; }
virtual void VSetVisible(bool visible) { m_bIsVisible = visible; }
};
class CMessageBox : public BaseUI
{
protected:
CDXUTDialog m_UI; // DirectX dialog
int m_ButtonId;
 
 
Search WWH ::




Custom Search