WinapiExtension
 All Classes Files Functions Variables Typedefs Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Window Class Reference

Object oriented WINAPI window. More...

#include <Window.h>

Inheritance diagram for Window:
WindowMessageHandler IWindow WindowModal

Public Member Functions

 Window ()
 
virtual ~Window ()
 
HWND _InternalGetHandle ()
 
void AttachFontRecursive (HFONT font)
 
bool Create (const WindowParams &params)
 
HWND GetHandle () const
 
HINSTANCE GetInstance () const
 
WindowGetParent () const
 
 operator HWND () const
 
void SetClientSize (int w, int h)
 
- Public Member Functions inherited from WindowMessageHandler
template<typename MESSAGE >
void Bind (UINT message, void(*function)(MESSAGE &))
 
template<typename MESSAGE , typename FUNCTOR >
void Bind (UINT message, FUNCTOR function)
 
template<typename CLASS , typename MESSAGE , typename HANDLER >
void Bind (UINT message, void(CLASS::*function)(MESSAGE &), HANDLER *handler)
 
template<typename FUNCTOR >
void BindCommand (WORD id, FUNCTOR function, WORD notifyCode=0)
 
template<typename FUNCTOR >
void BindCommand (HWND hwnd, FUNCTOR function, WORD notifyCode=0)
 
template<typename CLASS , typename HANDLER >
void BindCommand (WORD id, void(CLASS::*function)(msgCommand &), HANDLER *handler, WORD notifyCode=0)
 
template<typename CLASS , typename HANDLER >
void BindCommand (HWND hwnd, void(CLASS::*function)(msgCommand &), HANDLER *handler, WORD notifyCode=0)
 
template<typename FUNCTOR >
void BindNotify (UINT_PTR id, UINT notifyCode, FUNCTOR function)
 
template<typename FUNCTOR >
void BindNotify (HWND hwnd, UINT notifyCode, FUNCTOR function)
 
template<typename CLASS , typename HANDLER >
void BindNotify (UINT_PTR id, UINT notifyCode, void(CLASS::*function)(msgNotify &), HANDLER *handler)
 
template<typename CLASS , typename HANDLER >
void BindNotify (HWND hwnd, UINT notifyCode, void(CLASS::*function)(msgNotify &), HANDLER *handler)
 
bool PassMessageToHandlerFunction (HWND hwnd, UINT message, WPARAM wp, LPARAM lp, LRESULT &result)
 
void UnBind (UINT message)
 
void UnBindCommand (WORD id, WORD notifyCode=0)
 
void UnBindCommand (HWND hwnd, WORD notifyCode=0)
 
void UnBindNotify (UINT_PTR id, UINT notifyCode=0)
 
void UnBindNotify (HWND hwnd, UINT notifyCode=0)
 
- Public Member Functions inherited from IWindow
Rect ClientRect ()
 
void Destroy ()
 
void DragAcceptFiles (BOOL accept=TRUE)
 
void Enable (BOOL enable)
 
DWORD GetExStyle ()
 
HFONT GetFont ()
 
HICON GetIcon (BOOL bigIcon)
 
DWORD GetID ()
 
DWORD GetStyle ()
 
tstring GetText ()
 
BOOL Invalidate (const RECT *rect=NULL, BOOL eraseBkgnd=TRUE)
 
BOOL IsEnabled ()
 
BOOL IsVisible ()
 
void KillTimer (UINT_PTR timerID)
 
void ModifyStyle (DWORD add, DWORD remove)
 
void Move (int x, int y, BOOL redraw=TRUE)
 
void Move (const POINT &p, BOOL redraw=TRUE)
 
void Move (int x, int y, int width, int height, BOOL redraw=TRUE)
 
void Move (const POINT &p, const SIZE &s, BOOL redraw=TRUE)
 
void Move (const RECT &r, BOOL redraw=TRUE)
 
HWND ParentHandle ()
 
Rect RectOnParent ()
 
BOOL Redraw (const RECT *rect=NULL, HRGN region=NULL, UINT flags=RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE)
 
HWND SetFocus ()
 
void SetFont (HFONT font, BOOL redraw=TRUE)
 
HICON SetIcon (HICON icon, BOOL bigIcon)
 
void SetRedraw (BOOL allowRedraw)
 
void SetText (const tstring &text)
 
UINT_PTR SetTimer (UINT_PTR timerID, UINT interval, TIMERPROC proc=NULL)
 
BOOL Show (int cmdShow)
 
Rect WindowRect ()
 

Static Public Member Functions

static HBRUSH GetDefaultBackground ()
 
static HCURSOR GetDefaultCursor ()
 
static HFONT GetDefaultFont ()
 
static HICON GetDefaultIcon ()
 
static WindowGetObjectFromWindow (HWND hwnd)
 
static void SetDefaultBackground (HBRUSH bg)
 
static void SetDefaultCursor (HCURSOR cursor)
 
static void SetDefaultFont (HFONT font)
 
static void SetDefaultIcon (HICON icon)
 
static LRESULT CALLBACK StaticWndProc (HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 

Protected Member Functions

virtual LRESULT OnMessage (HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 

Detailed Description

Object oriented WINAPI window.

To do anything serious with it, a subclass must be created and some of the virtual message handlers (WndProc(), ...) should be overridden.

Constructor & Destructor Documentation

Window::Window ( )
inline

Empty ctor, call Create() to create the window.

Window::~Window ( )
inlinevirtual

The window handle will be destroyed, if it wasn't destroyed before.

Member Function Documentation

HWND Window::_InternalGetHandle ( )
inlinevirtual

Subclasses must override this function to make this interface work.

Returns
Handle of the window that implements this interface.

Implements IWindow.

void Window::AttachFontRecursive ( HFONT  font)
inline

Attach a font to this window and all children. The font must remain because Window does not take ownership of it.

bool Window::Create ( const WindowParams params)
inline

Creates the window.

Parameters
paramsCollection of creation parameters.
Returns
true if the window was created.
static HBRUSH Window::GetDefaultBackground ( )
inlinestatic
static HCURSOR Window::GetDefaultCursor ( )
inlinestatic
static HFONT Window::GetDefaultFont ( )
inlinestatic

Get default font.

static HICON Window::GetDefaultIcon ( )
inlinestatic
HWND Window::GetHandle ( ) const
inline

Convert to HWND.

HINSTANCE Window::GetInstance ( ) const
inline
Returns
HINSTANCE that the window is associated to.
Window * Window::GetObjectFromWindow ( HWND  hwnd)
inlinestatic

This only works if hwnd was created by this class.

Window * Window::GetParent ( ) const
inline
Returns
Parent of this window.
virtual LRESULT Window::OnMessage ( HWND  hwnd,
UINT  message,
WPARAM  wp,
LPARAM  lp 
)
inlineprotectedvirtual

Old style message handling, everything in one big virtual function

Implements WindowMessageHandler.

Window::operator HWND ( ) const
inline

Automatically convert to HWND when needed.

void Window::SetClientSize ( int  w,
int  h 
)
inline

Set the size of the client area. The top-left position of the window will be preserved.

static void Window::SetDefaultBackground ( HBRUSH  bg)
inlinestatic

Set a background brush for all subsequently created windows. WindowParams::Background() has a higher priority.

static void Window::SetDefaultCursor ( HCURSOR  cursor)
inlinestatic

Set a cursor for all subsequently created windows. WindowParams::Cursor() has a higher priority.

static void Window::SetDefaultFont ( HFONT  font)
inlinestatic

Sets a default font for all windows of this library.

static void Window::SetDefaultIcon ( HICON  icon)
inlinestatic

Set an icon for all subsequently created windows. WindowParams::Icon() has a higher priority.

LRESULT CALLBACK Window::StaticWndProc ( HWND  hwnd,
UINT  message,
WPARAM  wp,
LPARAM  lp 
)
inlinestatic

Static WindowProc to be used by the WindowClass.


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