2008-09-18 03:15:49 +00:00
|
|
|
template <class T>
|
|
|
|
class CDebugDialog :
|
|
|
|
public CDialogImpl<T>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
CDebugger * m_Debugger;
|
|
|
|
HANDLE m_CreatedEvent;
|
|
|
|
HANDLE m_DialogThread;
|
|
|
|
|
|
|
|
static DWORD CreateDebuggerWindow (CDebugDialog<T> * pThis)
|
|
|
|
{
|
|
|
|
pThis->DoModal(NULL);
|
|
|
|
pThis->WindowCreated();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowCreated ( void )
|
|
|
|
{
|
|
|
|
SetEvent(m_CreatedEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2010-05-22 04:47:15 +00:00
|
|
|
CDebugDialog (CDebugger * debugger) :
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Debugger(debugger),
|
|
|
|
m_CreatedEvent(CreateEvent(NULL,true,false,NULL)),
|
|
|
|
m_DialogThread(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual ~CDebugDialog (void)
|
|
|
|
{
|
|
|
|
HideWindow();
|
|
|
|
CloseHandle(m_CreatedEvent);
|
|
|
|
if (m_DialogThread)
|
|
|
|
{
|
|
|
|
CloseHandle(m_DialogThread);
|
|
|
|
m_DialogThread = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HideWindow ( void )
|
|
|
|
{
|
|
|
|
if (m_hWnd && ::IsWindow(m_hWnd))
|
|
|
|
{
|
|
|
|
::EndDialog(m_hWnd, 0);
|
|
|
|
}
|
|
|
|
if (m_DialogThread)
|
|
|
|
{
|
|
|
|
if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceError,"CDebugDialog - time out on close");
|
|
|
|
|
|
|
|
TerminateThread(m_DialogThread, 1);
|
|
|
|
}
|
|
|
|
CloseHandle(m_DialogThread);
|
|
|
|
m_DialogThread = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowWindow ( void )
|
|
|
|
{
|
|
|
|
if (m_hWnd)
|
|
|
|
{
|
|
|
|
SetForegroundWindow((HWND)m_hWnd);
|
|
|
|
} else {
|
|
|
|
DWORD ThreadID;
|
|
|
|
ResetEvent(m_CreatedEvent);
|
|
|
|
m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID);
|
|
|
|
if (WaitForSingleObject(m_CreatedEvent,20000) == WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceError,"Failed to get window create notification");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|