TNB Library
TnbMfcDebugStringDialog.h
[詳解]
1#pragma once
12#include "TnbApiHooker.h"
13
14
15
16//TNB Library
17namespace TNB {
18namespace MFC {
19
20
21
22#ifndef _TnbDOXYGEN //Document作成用シンボル
23namespace DSD {
24 typedef VOID (WINAPI* P_OutputDebugStringA)(LPCSTR lpOutputString);
25 typedef VOID (WINAPI* P_OutputDebugStringW)(LPCWSTR lpOutputString);
26 _SELECTANY CApiHookerT<P_OutputDebugStringA>* s_pHookerA = NULL;
27 _SELECTANY CApiHookerT<P_OutputDebugStringW>* s_pHookerW = NULL;
28 _SELECTANY CTinyListDialog* s_pListDialog = NULL;
29};
30#endif
31
32
33
62{
63 DEFSUPER(CTinyListDialog);
64public:
65
67 CDebugStringDialog(void) : _super(false)
68 {
69 }
70
71protected:
72
77 virtual void OnCreate(void)
78 {
79 if ( DSD::s_pListDialog == this || DSD::s_pListDialog != NULL )
80 {
81 return;
82 }
83 DSD::s_pHookerA = new CApiHookerT<DSD::P_OutputDebugStringA>;
84 if ( DSD::s_pHookerA->Hook(NULL, "OutputDebugStringA", ms_MyOutputDebugStringA) )
85 {
86 DSD::s_pHookerW = new CApiHookerT<DSD::P_OutputDebugStringW>;
87 if ( DSD::s_pHookerW->Hook(NULL, "OutputDebugStringW", ms_MyOutputDebugStringW) )
88 {
89 DSD::s_pListDialog = this;
90 return;
91 }
92 }
93 OnDestroy();
94 }
95
100 virtual void OnDestroy(void)
101 {
102 DSD::s_pListDialog = NULL;
103 if ( DSD::s_pHookerA != NULL )
104 {
105 DSD::s_pHookerA->Unhook();
106 delete DSD::s_pHookerA;
107 DSD::s_pHookerA = NULL;
108 }
109 if ( DSD::s_pHookerW != NULL )
110 {
111 DSD::s_pHookerW->Unhook();
112 delete DSD::s_pHookerW;
113 DSD::s_pHookerW = NULL;
114 }
115 }
116
117private:
118
122 static void ms_PumpMessage(void)
123 {
124 HWND h = *DSD::s_pListDialog;
125 MSG msg;
126 while ( ::PeekMessage(&msg, h, NULL, NULL, PM_NOREMOVE) )
127 {
128 if ( ::GetMessage(&msg, h, NULL, NULL) )
129 {
130 ::TranslateMessage(&msg);
131 ::DispatchMessage(&msg);
132 }
133 }
134 }
135
141 static VOID WINAPI ms_MyOutputDebugStringA(LPCSTR lpszOutputString)
142 {
143 if ( DSD::s_pListDialog != NULL )
144 {
145 DSD::s_pListDialog->PostString(CStr(lpszOutputString));
146 ms_PumpMessage();
147 }
148 (*DSD::s_pHookerA)()(lpszOutputString);
149 }
150
156 static VOID WINAPI ms_MyOutputDebugStringW(LPCWSTR lpszOutputString)
157 {
158 if ( DSD::s_pListDialog != NULL )
159 {
160 DSD::s_pListDialog->PostString(CStr(lpszOutputString));
161 ms_PumpMessage();
162 }
163 (*DSD::s_pHookerW)()(lpszOutputString);
164 }
165};
166
167
168
169}; // MFC
170}; // TNB
171
APIフック関係のヘッダ
Listウィンドウ関係のヘッダ
APIフック管理
Definition: TnbApiHooker.h:80
DebugString ウィンドウ
virtual void OnCreate(void)
[通知] 作成完了通知.
virtual void OnDestroy(void)
[通知] 破棄通知.
CDebugStringDialog(void)
コンストラクタ
簡易リストウィンドウ
TNB::CStrT< TCHAR > CStr
文字列クラス
Definition: TnbStr.h:1785
TNB Library
Definition: TnbDoxyTitle.txt:2