|
W32DLib
|
The base Window class. More...
#include <w32dlib/window.h>
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 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. | |
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. | |
The base Window class.
| W32DLib::Window::Window | ( | ) |
Constructor.
|
virtual |
Destructor.
| 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.
| enable | Set true to enable, false to disable. |
| 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.
| W32String 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.
| 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.
|
protectedvirtual |
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.
| 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. |
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.
| 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. |
| 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.
| 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. |
| 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.
| msg | The message to send. |
| wp | The WPARAM for that message type. |
| lp | The LPARAM for that message type. |
| 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.
| menu | The menu to set. |
| void W32DLib::Window::SetText | ( | const TCHAR * | 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.
| text | The text |
| void W32DLib::Window::SetText | ( | const W32String & | 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.
| text | The text |
|
staticprotected |
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.
| 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. |
|
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()).