00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _BASICVIEWER_ // Avoids multiple inclusions
00019 #define _BASICVIEWER_
00020
00021 class cBasicViewer;
00022
00023 #ifdef _MSC_VER
00024 #ifndef _MT // Requires the multi-thread version
00025 #define _MT // of the run-time library
00026 #endif // (only under microsoft c)
00027 #endif
00028
00029 #include <windows.h>
00030
00031
00032 #define TH_MESSAGE 0xC100
00033
00034 // value of uParam:
00035 #define TH_CHECK 0x0000
00036 #define TH_DIE 0x0012
00037 #define TH_SHOW 0x0013
00038 #define TH_HIDE 0x0014
00039 #define TH_UPDATE 0x0015
00040
00041
00042 #define VIEWER_ICON() LoadIcon((HINSTANCE)NULL, IDI_WINLOGO)
00043 #define VIEWER_CURSOR() LoadCursor((HINSTANCE)NULL, IDC_ARROW)
00044
00045
00046 #define BV_WNDSTYLE WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX
00047 #ifdef BV_NOCLOSE
00048 #define BV_CLASSSTYLE CS_NOCLOSE
00049 #else
00050 #define BV_CLASSSTYLE 0
00051 #endif
00052
00053 class cBasicViewer;
00054
00056 namespace BVThread {
00061 void ViewerThreadProcess(cBasicViewer *pViewer);
00062
00065 LRESULT WINAPI ViewerWndProc(HWND hWnd, UINT uMsg,\
00066 UINT uParam, LONG lParam);
00067 }
00068
00069
00070
00071
00072
00073
00079
00080 class cBasicViewer {
00081
00082 private:
00083
00085 HWND hwnd;
00086 HDC hMemDC;
00087
00088
00089 const static LPCTSTR ClassName;
00090
00091 int width, height;
00092 char title[60];
00093
00095 DWORD ThreadID;
00096
00098 HANDLE RunMutex;
00099
00100
00101 HANDLE DCMutex;
00102
00103
00105 static bool Registered;
00106
00107
00108 static HINSTANCE ModuleInstance;
00109
00110
00111 static void RegisterViewerClass(void);
00112
00113 protected:
00114
00115
00116
00117 HWND GetWindow(void) const { return hwnd; };
00118 DWORD GetThreadID(void) const { return ThreadID; };
00119
00120 public:
00121
00123 cBasicViewer(int Width, int Height, char *title);
00125 ~cBasicViewer();
00126
00127 HDC BeginDraw(void);
00128
00129
00130
00131
00132 void EndDraw(void);
00133
00134
00135
00136 void Show(void);
00137 void Hide(void);
00138 void Update(void);
00139
00140
00141 friend void BVThread::ViewerThreadProcess(cBasicViewer *pViewer);
00142 friend LRESULT WINAPI BVThread::ViewerWndProc(HWND hWnd, UINT uMsg,\
00143 UINT uParam, LONG lParam);
00144
00145
00146 int GetWidth(void) { return width; };
00147 int GetHeight(void) { return height; };
00148 };
00149
00150
00151 #endif // _BASICVIEWER_