mbo::MboWinMsgHandler Class Reference

Windows message handler thread. More...

#include <MboThread.h>

Inheritance diagram for mbo::MboWinMsgHandler:

Inheritance graph
{mbo::MboDrawWin\n|# m_hScrDC\l# m_hMemDC\l- m_nSizeX\l- m_nSizeY\l- m_nMinSizeX\l- m_nMinSizeY\l- m_nMaxSizeX\l- m_nMaxSizeY\l- m_nHeight\l- m_nWidth\l- m_bInSizeMove\l|+ MboDrawWin()\l+ MboDrawWin()\l+ ~MboDrawWin()\l+ IsWindowVisible()\l+ IsWindow()\l+ IsWndSizeable()\l+ IsWndSizingOrMoving()\l+ WndShow()\l+ WndHide()\l+ WndRestore()\l+ WndSetSize()\l+ WndSetPosition()\l+ WndDraw()\l+ OnWndSized()\l+ DrawRect()\l+ DrawRect()\l+ DrawLine()\l+ DrawLine()\l+ DrawEllipse()\l+ DrawCircle()\l+ DrawCircle()\l+ DrawPolygon()\l+ CalcTextRect()\l+ DrawText()\l+ DrawText()\l+ DrawBitmap()\l+ DrawBitmap()\l+ DrawBitmap()\l+ DrawIcon()\l+ DrawIcon()\l+ DrawIcon()\l+ WndSetIconBig()\l+ WndSetIconSmall()\l+ WndSetIconBoth()\l+ DrawSetMode()\l+ WndCreate()\l+ WndClear()\l+ OnWindowCreated()\l+ OnButtonDown()\l+ OnButtonDblClk()\l+ OnButtonUp()\l+ WndDestroy()\l+ WndUpdate()\l+ ProcessMessage()\l+ WndSetTitle()\l+ GetPositionX()\l+ GetPositionY()\l+ GetSizeX()\l+ GetSizeY()\l+ GetMinSizeX()\l+ GetMinSizeY()\l+ GetMaxSizeX()\l+ GetMaxSizeY()\l+ GetWidth()\l+ GetHeight()\l+ GetScreenSizeX()\l+ GetScreenSizeY()\l+ WndLoadExtent()\l+ WndSaveExtent()\l# WndCalcMetrics()\l# WndRegisterHandle()\l}{mbo::MboThread\n|# m_hThread\l# m_hIsStopping\l# m_dwThreadId\l# m_mxStartStop\l- m_szThreadName\l|+ MboThread()\l+ MboThread()\l+ ~MboThread()\l+ IsRunning()\l+ IsStopping()\l+ WaitFor()\l+ KillThread()\l+ GetThreadId()\l+ SetThreadPriority()\l+ GetThreadName()\l+ Action()\l+ OnActionException()\l+ Start()\l+ Stop()\l+ OnThreadStart()\l+ OnThreadStop()\l+ SetThreadName()\l# ThreadProc()\l- ThreadProcCaller()\l- ThreadNamer()\l- ThreadProcRunner()\l- ForceThreadName()\l- operator=()\l}
[legend]
Collaboration diagram for mbo::MboWinMsgHandler:

Collaboration graph
{mbo::MboThread\n|# m_hThread\l# m_hIsStopping\l# m_dwThreadId\l# m_mxStartStop\l- m_szThreadName\l|+ MboThread()\l+ MboThread()\l+ ~MboThread()\l+ IsRunning()\l+ IsStopping()\l+ WaitFor()\l+ KillThread()\l+ GetThreadId()\l+ SetThreadPriority()\l+ GetThreadName()\l+ Action()\l+ OnActionException()\l+ Start()\l+ Stop()\l+ OnThreadStart()\l+ OnThreadStop()\l+ SetThreadName()\l# ThreadProc()\l- ThreadProcCaller()\l- ThreadNamer()\l- ThreadProcRunner()\l- ForceThreadName()\l- operator=()\l}{mbo::CCriticalSectionImpl\n|- m_cs\l|+ CCriticalSectionImpl()\l+ ~CCriticalSectionImpl()\l+ Enter()\l+ Leave()\l+ GetLock()\l+ GetLevel()\l}{mbo::ICriticalSection\n||+ ~ICriticalSection()\l+ Enter()\l+ Leave()\l+ GetLock()\l+ GetLevel()\l}
[legend]

List of all members.

Public Member Functions

 MboWinMsgHandler (const MboString &strWndClassName="MboWinMsgHandler", bool bStart=true)
virtual ~MboWinMsgHandler ()
virtual HWND GetHWND () const
virtual void Stop ()
virtual LRESULT ProcessMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual LRESULT ProcessDefault (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual bool PostMessage (UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual bool PostMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
virtual HINSTANCE GetModuleHandle () const

Protected Member Functions

virtual const MboStringWndClassName () const
virtual const MboStringWndTitleText () const
virtual void Action ()
virtual void OnWindowCreated ()
virtual void MessageHandler (MSG &msg)
virtual bool WndCreate ()
virtual bool WndCalcMetrics ()
virtual void WndDestroy ()
virtual bool WndRegister ()
void AddHWND ()

Protected Attributes

HWND m_hwnd
const MboString m_strWndClassName

Static Protected Attributes

static WndClassList g_vWndClassList

Friends

LRESULT CALLBACK MboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)


Detailed Description

Windows message handler thread.

This class implementns a windows message handling facility to be used when working in shell or other applications where no message handler and/or message loop is accessible.

When you need to work with visible windows you must register your own class by overriding WndRegister() and most likely WndCreate().

Definition at line 537 of file MboThread.h.


Constructor & Destructor Documentation

mbo::MboWinMsgHandler::MboWinMsgHandler ( const MboString strWndClassName = "MboWinMsgHandler",
bool  bStart = true 
) [explicit]

The constructor will automatically start the message thread. However it has to wait a small amount of time before it can return.

If you need to need to define your own WndRegister() or WndCreate() methods in a derived class you must call the constructor with param bStart being false and directly call Start().

Parameters:
strWndClassName name of message handler
bStart create the class and window and start the message handler thread.

virtual mbo::MboWinMsgHandler::~MboWinMsgHandler (  )  [virtual]

Destroy/Release all resources registered and/or created.


Member Function Documentation

virtual HWND mbo::MboWinMsgHandler::GetHWND (  )  const [virtual]

Returns:
handle used internally (usefule for message passing).

virtual void mbo::MboWinMsgHandler::Stop (  )  [virtual]

Generates an WM_DESTROY message for the message handler which triggers a call to the inherited Stop and hence stops the thread. However the method also calls inherited Stop() direct to force message loop termination on next message.

Reimplemented from mbo::MboThread.

virtual LRESULT mbo::MboWinMsgHandler::ProcessMessage ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
) [virtual]

Overwrite this handler if you want to handle any message.

Note:
You should call ProcessDefault() from ProcessMessage() for any message not handled yourself.
Parameters:
hwnd Handle to the window procedure that received the message. This normally matches m_hwnd.
uMsg Specifies the message received.
wParam Specifies additional message information. The content of this parameter depends on the value of the Msg parameter.
lParam Specifies additional message information. The content of this parameter depends on the value of the Msg parameter.
Returns:
The return value is the result of the message processing and depends on the message.

Reimplemented in mbo::MboDrawWin.

virtual LRESULT mbo::MboWinMsgHandler::ProcessDefault ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
) [virtual]

Handles default messages not handled by ProcessMessage.

Note:
You should call ProcessDefault() from ProcessMessage() for any message not handled yourself.
Parameters:
hwnd Handle to the window procedure that received the message. This normally matches m_hwnd.
uMsg Specifies the message received.
wParam Specifies additional message information. The content of this parameter depends on the value of the Msg parameter.
lParam Specifies additional message information. The content of this parameter depends on the value of the Msg parameter.
Returns:
The return value is the result of the message processing and depends on the message.

virtual bool mbo::MboWinMsgHandler::PostMessage ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
) [virtual]

Pass a message to the handler. Internally this method calls PostMessage with hwnd set to m_hwnd.

Parameters:
uMsg Specifies the message to be posted.
wParam Specifies additional message-specific information.
lParam Specifies additional message-specific information.
Returns:
If the function succeeds, the return value is true.

virtual bool mbo::MboWinMsgHandler::PostMessage ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
) [virtual]

Pass a message to the handler.

Parameters:
hwnd Handle to the window whose window procedure is to receive the message. Two values have special meanings: Value Meaning
  • HWND_BROADCAST The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows. The message is not posted to child windows.
  • NULL The function behaves like a call to PostThreadMessage with the dwThreadId parameter set to the identifier of the current thread.
uMsg Specifies the message to be posted.
wParam Specifies additional message-specific information.
lParam Specifies additional message-specific information.
Returns:
If the function succeeds, the return value is true.

virtual HINSTANCE mbo::MboWinMsgHandler::GetModuleHandle (  )  const [virtual]

Returns:
instance of EXE or DLL, used with resources.

virtual const MboString& mbo::MboWinMsgHandler::WndClassName (  )  const [protected, virtual]

Returns:
the (window) class name which is used to create the window. This name will be used in RegisterWin() and CreateWin().
If you need to overload this function you must ensure that the returned value is a const string which must not be freed by the caller. Also you need to set bStart parameter of the constructor to false.

virtual const MboString& mbo::MboWinMsgHandler::WndTitleText (  )  const [protected, virtual]

Returns:
title of window (defaults to WndClassName())

virtual void mbo::MboWinMsgHandler::Action (  )  [protected, virtual]

Message handler

Do this:

Implements mbo::MboThread.

virtual void mbo::MboWinMsgHandler::OnWindowCreated (  )  [protected, virtual]

Called after the window has been created by WndCreate(). This method may be overwritten in derived GUI classes to perform initial drawing.

Note:
You cannot use OnThreadStart() method to draw because it is called before the window has been created.

Reimplemented in mbo::MboDrawWin.

virtual void mbo::MboWinMsgHandler::MessageHandler ( MSG &  msg  )  [protected, virtual]

Handle a message by first translating it and then dispatching it.

Parameters:
msg Message to handle.

virtual bool mbo::MboWinMsgHandler::WndCreate (  )  [protected, virtual]

Create an unvisible message window. Called during handler startup.

Reimplemented in mbo::MboDrawWin.

virtual bool mbo::MboWinMsgHandler::WndCalcMetrics (  )  [protected, virtual]

Register the window and calculate its metrics in case of visible windows of derived classes.

Reimplemented in mbo::MboDrawWin.

virtual void mbo::MboWinMsgHandler::WndDestroy (  )  [protected, virtual]

Destroy the message window.

Reimplemented in mbo::MboDrawWin.

virtual bool mbo::MboWinMsgHandler::WndRegister (  )  [protected, virtual]

Register the class used to specify the internally used message handler.

void mbo::MboWinMsgHandler::AddHWND (  )  [protected]

Add the instance with its identifying HWND to the list of registered windows.

Actually this does:

     g_mhwndList[m_hwnd] = this;
Note:
non virtual


Friends And Related Function Documentation

LRESULT CALLBACK MboWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
) [friend]


Member Data Documentation

HWND mbo::MboWinMsgHandler::m_hwnd [protected]

Definition at line 709 of file MboThread.h.

const MboString mbo::MboWinMsgHandler::m_strWndClassName [protected]

window handle

Definition at line 711 of file MboThread.h.

WndClassList mbo::MboWinMsgHandler::g_vWndClassList [static, protected]

the window class name as returned by WndClassName()

Definition at line 713 of file MboThread.h.


The documentation for this class was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:13 2008 for MBO-lib by doxygen 1.5.4