Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

W32DLib::Window Class Reference

The base Window class. More...

#include <w32dlib/window.h>

Inheritance diagram for W32DLib::Window:

W32DLib::Control W32DLib::Dialog W32DLib::AutoCheck W32DLib::Button W32DLib::ComboBox W32DLib::RadioButton W32DLib::StaticText W32DLib::Text List of all members.

Public Member Functions

 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 char *text)
 Sets the window text.
void SetText (const std::string &text)
 Sets the window text.
std::string 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.

Static Protected Member Functions

static BOOL CALLBACK WindowProc (HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
 The base WindProc.

Protected Attributes

HWND m_wnd
 The window handle for this window.

Detailed Description

The base Window class.


Constructor & Destructor Documentation

W32DLib::Window::Window  ) 
 

Constructor.

virtual W32DLib::Window::~Window  )  [virtual]
 

Destructor.


Member Function Documentation

void W32DLib::Window::Enable bool  enable  ) 
 

Enables or disables the window.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

Parameters:
enable Set true to enable, false to disable.

Reimplemented in W32DLib::Dialog.

HMENU W32DLib::Window::GetHMENU  ) 
 

Returns the HMENU associated with this window.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

HWND W32DLib::Window::GetHWND  ) 
 

Returns the HWND for the window.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

std::string W32DLib::Window::GetText  ) 
 

Gets the window text.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

Returns:
The control's text
See also:
SetText()

bool W32DLib::Window::HasMutex  ) 
 

Whether the Window() constructor could create a mutex.

Window will create a mutex when constructed to ensure that behaviour is correct if there are multiple threads in the application with their own windows (note that none of the classes are thread-safe in themselves -- two threads cannot share a Window instance).

As I'm not overly fond of exceptions, this call means you can detect whether this worked or not if your program requires it. It also means that single-threaded applications aren't stopped by the failure to create a mutex.

Returns:
True if this Window can be used safely in a thread.

virtual BOOL W32DLib::Window::InstanceProc HWND  wnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp
[protected, virtual]
 

Handles windows messages.

If the window handles messages (like Dialog), then this must be overwridden so that Window::WindowProc will pass on the messages.

If the message has not been handled, or is WM_DESTROY, then the base version should be called.

Note that the reason it should be called for WM_DESTROY is so that the internal mapping of windows to Window class instances can be tidied up.

Parameters:
wnd The window handle
msg The message
wp Additional parameters. Depends on the value of msg.
lp Additional parameters. Depends on the value of msg.
Returns:
TRUE if the message has been handled.

Reimplemented in W32DLib::Dialog.

bool W32DLib::Window::Move int  x,
int  y,
int  width,
int  height,
bool  repaint = true
 

Sets a Window's position and size.

Parameters:
x The X Co-ord in pixels.
y The Y Co-ord in pixels.
width The width in pixels.
height The height in pixels.
repaint Cause a repaint of the window and exposed areas.
Returns:
True if the call succeeds.

bool W32DLib::Window::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.

Parameters:
w The dialog.
x The X Co-ord in dialog base units.
y The Y Co-ord in dialog base units.
width The width in dialog base units.
height The height in dialog base units.
repaint Cause a repaint of the window and exposed areas.
Returns:
True if the call succeeds.

LRESULT W32DLib::Window::SendMsg UINT  msg,
WPARAM  wp,
LPARAM  lp
 

Send a message to the window.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

Parameters:
msg The message to send.
wp The WPARAM for that message type.
lp The LPARAM for that message type.
Returns:
The LRESULT from sending the message.

bool W32DLib::Window::SetHMENU HMENU  menu  ) 
 

Sets the HMENU associated with this window.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

Parameters:
menu The menu to set.
Returns:
True if the call succeeds.

void W32DLib::Window::SetText const std::string &  text  ) 
 

Sets the window text.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

Parameters:
text The text
See also:
GetText()

void W32DLib::Window::SetText const char *  text  ) 
 

Sets the window text.

This call will only work while the window is on display. The behaviour is undefined if it is called at any other time.

Parameters:
text The text
See also:
GetText()

static BOOL CALLBACK W32DLib::Window::WindowProc HWND  wnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp
[static, protected]
 

The base WindProc.

This is the WindProc/DialogProc that should be used. Note that it expects a pointer to a Window in lp when called with WM_INITDIALOG or WM_CREATE.

Parameters:
wnd The window handle
msg The message
wp Additional parameters. Depends on the value of msg.
lp Additional parameters. Depends on the value of msg.
Returns:
TRUE if the message has been handled.


Member Data Documentation

HWND W32DLib::Window::m_wnd [protected]
 

The window handle for this window.

The base Window::InstanceProc will set this from the wnd parameter for WM_INITDIALOG or WM_CREATE.

Other derived classes should set the window as appropriate (for instance controls from GetDlgItem()).


The documentation for this class was generated from the following file:
Generated on Fri May 6 01:22:34 2005 for W32DLib by  doxygen 1.4.1