00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _CIvfMfcApplication_h_
00026 #define _CIvfMfcApplication_h_
00027
00028 #include <afxwin.h>
00029
00030 #include <ivfdef/IvfPointer.h>
00031
00038 class CIvfMfcApplicationBase {
00039 private:
00040 int m_idleProcessing;
00041 public:
00043 virtual BOOL InitInstance()
00044 {
00045 m_idleProcessing = 0;
00046 return true;
00047 }
00048
00050 void disableIdleProcessing()
00051 {
00052 if (m_idleProcessing>0)
00053 m_idleProcessing--;
00054 }
00055
00057 void enableIdleProcessing()
00058 {
00059 m_idleProcessing++;
00060 }
00061
00063 bool isIdleProcessing()
00064 {
00065 return m_idleProcessing>0;
00066 }
00067 };
00068
00075 template<class T>
00076 class CIvfMfcApplication: public CIvfMfcApplicationBase, public CWinApp {
00077 private:
00078 T* m_mfcWindow;
00079 public:
00085 virtual BOOL InitInstance()
00086 {
00087 CWinApp::InitInstance();
00088 m_mfcWindow = new T(0,0,640,480);
00089 m_mfcWindow->setApplication(this);
00090 m_pMainWnd = m_mfcWindow;
00091 m_pMainWnd -> ShowWindow(m_nCmdShow);
00092 m_pMainWnd -> UpdateWindow();
00093 return true;
00094 }
00095
00097 virtual int Run()
00098 {
00099 MSG msg;
00100 BOOL bRet;
00101 bool running = true;
00102 while (running)
00103 {
00104 if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
00105 {
00106 if ((bRet = GetMessage(&msg, NULL, 0, 0)) == 0)
00107 return 0;
00108 else
00109 {
00110 TranslateMessage(&msg);
00111 DispatchMessage(&msg);
00112 }
00113 }
00114 else
00115 {
00116 if (isIdleProcessing())
00117 {
00118 if (m_mfcWindow->isIdleProcessing())
00119 m_mfcWindow->doIdle();
00120 }
00121 else
00122 {
00123 WaitMessage();
00124 }
00125 }
00126 }
00127 return 0;
00128 }
00129 };
00136 #endif