1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
| #include "GestImp2Pch.h"
#include <local/GestImp2/CImpressionThread.h>
#include <local/Base/Instrumentation.h>
#include <local/Base/Base_Jrn.h>
#include <local/MfcPlus/MfcPlus.h>
#include "tc.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
HANDLE CImpressionThread::m_hEventImpressionThreadKilled;
IMPLEMENT_DYNCREATE(CImpressionThread, CWinThread)
CImpressionThread::CImpressionThread()
{
INSTRUMENTER(this, "CImpressionThread::CImpressionThread()");
m_pwndParent = NULL;
}
CImpressionThread::CImpressionThread( CWnd* pwndParent, pcTChar pszNomGestionnaireImpression )
: m_pwndParent( pwndParent )
{
INSTRUMENTER(this, "CImpressionThread::CImpressionThread(CWnd* pwndParent)");
m_wndImpression.Nom( pszNomGestionnaireImpression );
}
CImpressionThread::~CImpressionThread()
{
INSTRUMENTER(this, "CImpressionThread::~CImpressionThread()");
}
void CImpressionThread::operator delete(void* p)
{
INSTRUMENTER(this, "void CImpressionThread::operator delete(void * p)");
// The exiting main application thread waits for this event before completely
// terminating in order to avoid a false memory leak detection. See also
// CWnd::OnNcDestroy.
SetEvent( m_hEventImpressionThreadKilled );
CWinThread::operator delete(p);
}
#if defined(_DEBUG) && !defined(_AFX_NO_DEBUG_CRT) && _MSC_VER >= 1200
void CImpressionThread::operator delete(void *p, LPCSTR lpszFileName, int nLine)
{
INSTRUMENTER(this, "void CImpressionThread::operator delete(void *p, LPCSTR lpszFileName, int nLine)");
// The exiting main application thread waits for this event before completely
// terminating in order to avoid a false memory leak detection. See also
// CWnd::OnNcDestroy.
SetEvent( m_hEventImpressionThreadKilled );
CWinThread::operator delete(p, lpszFileName, nLine);
}
#endif
BOOL CImpressionThread::InitInstance()
{
_TC(
OleInitialize( NULL );
CRect rect;
if ( ! m_wndImpression.Create( NULL, _T(""), WS_CHILD, rect, m_pwndParent, 1 ) )
return FALSE;
m_pMainWnd = &m_wndImpression;
)
if ( bExceptionSurvenue )
return FALSE;
return TRUE;
}
int CImpressionThread::ExitInstance()
{
INSTRUMENTER(this, "int CImpressionThread::ExitInstance()");
OleUninitialize();
return CWinThread::ExitInstance();
}
int CImpressionThread::Run()
{
ASSERT_VALID(this);
_AFX_THREAD_STATE* pState = AfxGetThreadState();
// for tracking the idle time state
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
// acquire and dispatch messages until a WM_QUIT message is received.
for (;;)
{
// phase1: check to see if we can do idle work
while (bIdle &&
!::PeekMessage(&(pState->m_msgCur), NULL, NULL, NULL, PM_NOREMOVE))
{
// call OnIdle while in bIdle state
if (!OnIdle(lIdleCount++))
bIdle = FALSE; // assume "no idle" state
}
// phase2: pump messages while available
do
{
// pump message, but quit on WM_QUIT
if (!PumpMessage())
return ExitInstance();
// reset "no idle" state after pumping "normal" message
//if (IsIdleMessage(&m_msgCur))
if (IsIdleMessage(&(pState->m_msgCur)))
{
bIdle = TRUE;
lIdleCount = 0;
}
} while (::PeekMessage(&(pState->m_msgCur), NULL, NULL, NULL, PM_NOREMOVE));
}
if ( bExceptionSurvenue ) //<=== Erreur C2065.
{
bIdle = TRUE;
lIdleCount = 0;
}
}
ASSERT( 0 ); //<=== Erreur C2062.
BEGIN_MESSAGE_MAP(CImpressionThread, CWinThread)
//{{AFX_MSG_MAP(CImpressionThread)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP() |
Partager