cBasicViewer Class Reference

#include <cBasicViewer.h>

List of all members.

Public Member Functions

 cBasicViewer (int Width, int Height, char *title)
 Constructor.
 ~cBasicViewer ()
 Destructor.
HDC BeginDraw (void)
void EndDraw (void)
void Show (void)
 This method asks the thread to show his window.
void Hide (void)
 Shows the window.
void Update (void)
 Hides the window.
int GetWidth (void)
int GetHeight (void)

Protected Member Functions

HWND GetWindow (void) const
 the window class
DWORD GetThreadID (void) const

Static Private Member Functions

static void RegisterViewerClass (void)
 instance.

Private Attributes

HWND hwnd
 Window related atributes.
HDC hMemDC
 Handle of the window.
int width
 Keeps the window's class name.
int height
char title [60]
 Size of the window's client area.
DWORD ThreadID
 Keeps the title of the window.
HANDLE RunMutex
 Keeps the thread ID.
HANDLE DCMutex
 Signals the running state of the thread.

Static Private Attributes

static const LPCTSTR ClassName = "cBasicViewerWindow"
 store the window's client area.
static bool Registered = false
 the memory device context
static HINSTANCE ModuleInstance = NULL
 been registered.

Friends

void ViewerThreadProcess (cBasicViewer *pViewer)
 Repaints the client area of the window.
LRESULT WINAPI ViewerWndProc (HWND hWnd, UINT uMsg, UINT uParam, LONG lParam)


Detailed Description

cBasicViewer is a class that encapsulates the Win32 API that creates a graphic window and manages it. The window is created inside a new thread. All the messages to the window are handled by the thread, in order to prevent the main program to be 'locked' into a message loop.

Definition at line 80 of file cBasicViewer.h.


Constructor & Destructor Documentation

cBasicViewer::cBasicViewer ( int  Width,
int  Height,
char *  title 
)

Constructor.

Creates a multi-thread viewer. This method only creates the thread. All the window creation stuff is actually made by the thread.

Definition at line 31 of file cBasicViewer.cpp.

References DCMutex, height, RunMutex, TH_CHECK, TH_MESSAGE, ThreadID, ViewerThreadProcess, and width.

cBasicViewer::~cBasicViewer (  ) 

Destructor.

Delete the viewer. This method only sends TH_DIE to the thread and waits his death. All the clean-up is made by the thread.

Definition at line 66 of file cBasicViewer.cpp.

References RunMutex, TH_DIE, TH_MESSAGE, and ThreadID.


Member Function Documentation

void cBasicViewer::RegisterViewerClass ( void   )  [static, private]

instance.

This method registers the Viewer window class.

Keeps the current module

Definition at line 150 of file cBasicViewer.cpp.

References BV_CLASSSTYLE, ClassName, ModuleInstance, Registered, VIEWER_CURSOR, VIEWER_ICON, and ViewerWndProc.

Referenced by BVThread::ViewerThreadProcess().

HWND cBasicViewer::GetWindow ( void   )  const [inline, protected]

the window class

This method registers

Definition at line 117 of file cBasicViewer.h.

References hwnd.

DWORD cBasicViewer::GetThreadID ( void   )  const [inline, protected]

Definition at line 118 of file cBasicViewer.h.

References ThreadID.

HDC cBasicViewer::BeginDraw ( void   ) 

This method locks the memory device context in order to receive GDI calls from the user. Each call to BeginDraw must have a corresponding call to EndDraw.

Definition at line 84 of file cBasicViewer.cpp.

References DCMutex, and hMemDC.

void cBasicViewer::EndDraw ( void   ) 

Locks the memory device context in order to receive GDI calls. Each call to BeginDraw must have a corresponding call to EndDraw.

This method Unlocks the memory device context that was locked by BeginPaint. it must ALWAYS be called after BeginPaint

Definition at line 101 of file cBasicViewer.cpp.

References DCMutex.

void cBasicViewer::Show ( void   ) 

This method asks the thread to show his window.

Releases the memory device context. This method must ALWAYS be called after BeginDraw.

Definition at line 114 of file cBasicViewer.cpp.

References TH_MESSAGE, TH_SHOW, and ThreadID.

void cBasicViewer::Hide ( void   ) 

Shows the window.

This method asks the thread to hide his window.

Definition at line 126 of file cBasicViewer.cpp.

References TH_HIDE, TH_MESSAGE, and ThreadID.

void cBasicViewer::Update ( void   ) 

Hides the window.

This method asks the thread to repaint his window.

Definition at line 138 of file cBasicViewer.cpp.

References TH_MESSAGE, TH_UPDATE, and ThreadID.

int cBasicViewer::GetWidth ( void   )  [inline]

Definition at line 146 of file cBasicViewer.h.

References width.

int cBasicViewer::GetHeight ( void   )  [inline]

Definition at line 147 of file cBasicViewer.h.

References height.


Friends And Related Function Documentation

void ViewerThreadProcess ( cBasicViewer pViewer  )  [friend]

Repaints the client area of the window.

This is the main function of the thread created by cBasicViewer objects. Take as parameter a pointer to the object that created the thread It creates the viewer window and a memory device contex that receives the user GDI calls

The thread main function. Take as parameter a pointer to the object that created the thread. It creates a graphic window, then enters a message loop. Commands are sent to it by the TH_MESSAGE messages.

Definition at line 26 of file BVThreadFun.cpp.

Referenced by cBasicViewer().

LRESULT WINAPI ViewerWndProc ( HWND  hWnd,
UINT  uMsg,
UINT  uParam,
LONG  lParam 
) [friend]

This is the viewer window function. It handles currently only the WM_PAINT and WM_CLOSE messages. All other messages are repassed to DefWndProc.

On WM_PAINT messages, the function will try to get the DCMutex to lock the memory device context. If it succeeds, the function redraws the client area of the window. If not, the function does nothig. The system will keep sending WM_PAINT until we can repaint the window

On WM_CLOSE messages, the function just hides the window. We don't want to destroy the window now, because a TH_SHOW message to the thread would requires the recreation of the window

The window Procedure. Handles all messages sent to the window.

Definition at line 162 of file BVThreadFun.cpp.

Referenced by RegisterViewerClass().


Member Data Documentation

HWND cBasicViewer::hwnd [private]

Window related atributes.

Definition at line 85 of file cBasicViewer.h.

Referenced by GetWindow(), and BVThread::ViewerThreadProcess().

HDC cBasicViewer::hMemDC [private]

Handle of the window.

Definition at line 86 of file cBasicViewer.h.

Referenced by BeginDraw(), and BVThread::ViewerWndProc().

const LPCTSTR cBasicViewer::ClassName = "cBasicViewerWindow" [static, private]

store the window's client area.

Handle of the memory device context used to

Definition at line 89 of file cBasicViewer.h.

Referenced by RegisterViewerClass(), and BVThread::ViewerThreadProcess().

int cBasicViewer::width [private]

Keeps the window's class name.

Definition at line 91 of file cBasicViewer.h.

Referenced by cBasicViewer(), GetWidth(), BVThread::ViewerThreadProcess(), and BVThread::ViewerWndProc().

int cBasicViewer::height [private]

char cBasicViewer::title[60] [private]

Size of the window's client area.

Definition at line 92 of file cBasicViewer.h.

Referenced by BVThread::ViewerThreadProcess().

DWORD cBasicViewer::ThreadID [private]

Keeps the title of the window.

Thread related atributes

Definition at line 95 of file cBasicViewer.h.

Referenced by cBasicViewer(), GetThreadID(), Hide(), Show(), Update(), BVThread::ViewerThreadProcess(), and ~cBasicViewer().

HANDLE cBasicViewer::RunMutex [private]

Keeps the thread ID.

Synchronisation Mutexes

Definition at line 98 of file cBasicViewer.h.

Referenced by cBasicViewer(), and ~cBasicViewer().

HANDLE cBasicViewer::DCMutex [private]

Signals the running state of the thread.

Used by constructor and destructor.

Definition at line 101 of file cBasicViewer.h.

Referenced by BeginDraw(), cBasicViewer(), EndDraw(), and BVThread::ViewerWndProc().

bool cBasicViewer::Registered = false [static, private]

the memory device context

Synchronizes the access to Misc. private members

Definition at line 105 of file cBasicViewer.h.

Referenced by RegisterViewerClass(), and BVThread::ViewerThreadProcess().

HINSTANCE cBasicViewer::ModuleInstance = NULL [static, private]

been registered.

True if the window class has already

Definition at line 108 of file cBasicViewer.h.

Referenced by RegisterViewerClass().


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

Generated on Tue Feb 26 09:12:54 2008 for USPDesigner by  doxygen 1.5.5