W32DLib
W32DLib::Dialog Class Referenceabstract

The base Dialog class. More...

#include <w32dlib/dialog.h>

Inheritance diagram for W32DLib::Dialog:
W32DLib::Window

Public Member Functions

 Dialog ()
 Constructor.
 
virtual ~Dialog ()
 Destructor.
 
virtual int ResourceID ()=0
 Returns the Resource ID for the dialog.
 
virtual void CreateControls ()=0
 Create the controls attached to the dialog.
 
virtual void OnInit ()
 Called when the dialog is displaying.
 
virtual void OnClose ()
 Called when the dialog is closing.
 
void Enable (bool enable)
 Enables or disables all Controls in the dialog.
 
INT_PTR ShowModal (HINSTANCE instance, HWND parent)
 Displays a modal dialog.
 
void Close (INT_PTR result)
 Closes the dialog.
 
void AddControl (Control *control)
 Adds a control to the dialog.
 
void SetMenuProc (Window *owner, W32DLibCallback callback)
 Sets a callback for handling menu commands.
 
void SetData ()
 Request data exchange with all controls.
 
void GetData ()
 Request data exchange with all controls.
 
- Public Member Functions inherited from W32DLib::Window
 Window ()
 Constructor.
 
virtual ~Window ()
 Destructor.
 
bool HasMutex ()
 Whether the Window() constructor could create a mutex.
 
HWND GetHWND ()
 Returns the HWND for the window.
 
HMENU GetHMENU ()
 Returns the HMENU associated with this window.
 
bool SetHMENU (HMENU menu)
 Sets the HMENU associated with this window.
 
bool Move (int x, int y, int width, int height, bool repaint=true)
 Sets a Window's position and size.
 
bool MoveBase (Window *w, int x, int y, int width, int height, bool repaint=true)
 Sets a Window's position and size using Dialog base units.
 
LRESULT SendMsg (UINT msg, WPARAM wp, LPARAM lp)
 Send a message to the window.
 
void SetText (const TCHAR *text)
 Sets the window text.
 
void SetText (const W32String &text)
 Sets the window text.
 
W32String GetText ()
 Gets the window text.
 
void Enable (bool enable)
 Enables or disables the window.
 

Protected Member Functions

virtual BOOL InstanceProc (HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
 Handles windows messages.
 

Additional Inherited Members

- Static Protected Member Functions inherited from W32DLib::Window
static BOOL CALLBACK WindowProc (HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
 The base WindProc.
 
- Protected Attributes inherited from W32DLib::Window
HWND m_wnd
 The window handle for this window.
 

Detailed Description

The base Dialog class.

Constructor & Destructor Documentation

W32DLib::Dialog::Dialog ( )

Constructor.

Do not add controls in a derived Dialog. Use CreateControls instead.

See Also
CreateControls
virtual W32DLib::Dialog::~Dialog ( )
virtual

Destructor.

Member Function Documentation

void W32DLib::Dialog::AddControl ( Control control)

Adds a control to the dialog.

Note that the pointer to the control is stored, so the control must exist as long as the dialog is in use.

Parameters
controlThe control the add.
void W32DLib::Dialog::Close ( INT_PTR  result)

Closes the dialog.

Closes the dialog. Silently ignored if the dialog is not open.

Parameters
resultThe result to return.
See Also
ShowModal()
virtual void W32DLib::Dialog::CreateControls ( )
pure virtual

Create the controls attached to the dialog.

All derived classes must implement this. This should create the controls for the dialog.

void W32DLib::Dialog::Enable ( bool  enable)

Enables or disables all Controls in the dialog.

Overrides Window::Enable.

void W32DLib::Dialog::GetData ( )

Request data exchange with all controls.

Values will be stored in the DataX objects registered with the controls.

This shouldn't be called any earlier than when OnInit() is invoked.

virtual BOOL W32DLib::Dialog::InstanceProc ( HWND  wnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
protectedvirtual

Handles windows messages.

Parameters
wndThe window handle
msgThe message
wpAdditional parameters. Depends on the value of msg.
lpAdditional parameters. Depends on the value of msg.
Returns
TRUE if the message has been handled.
See Also
Window::InstanceProc

Reimplemented from W32DLib::Window.

virtual void W32DLib::Dialog::OnClose ( )
virtual

Called when the dialog is closing.

Override this call to pick up this event.

virtual void W32DLib::Dialog::OnInit ( )
virtual

Called when the dialog is displaying.

Override this call to initialise dialog controls.

virtual int W32DLib::Dialog::ResourceID ( )
pure virtual

Returns the Resource ID for the dialog.

All derived classes must implement this. This should return the ID of the dialog in the resource file.

void W32DLib::Dialog::SetData ( )

Request data exchange with all controls.

Values will be set from DataX objects registered with the controls.

This shouldn't be called any earlier than when OnInit() is invoked.

void W32DLib::Dialog::SetMenuProc ( Window owner,
W32DLibCallback  callback 
)

Sets a callback for handling menu commands.

This call simply passes on all WM_COMMAND messages that were not for any registered control's resource ID.

Due to this, the callback should take care to ensure it only actions recognised menu commands.

Parameters
ownerThe class (generally a Dialog derived one) in which the callback resides. The class must be derived from Window.
callbackThe callback.
INT_PTR W32DLib::Dialog::ShowModal ( HINSTANCE  instance,
HWND  parent 
)

Displays a modal dialog.

Call this to display the dialog.

Parameters
instanceThe HINSTANCE. Call Common::GetInstance() to get an instance (from a DLL, for example) if all else fails.
parentThe parent window of the dialog (NULL for none).
Returns
The result from Close().
See Also
Close()
Common::GetInstance()

The documentation for this class was generated from the following file: