28 #ifndef WS_OVERLAPPEDWINDOW
29 #define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
85 virtual bool OnWindowMessage(LRESULT& _result, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) = 0;
95 m_brush =
static_cast<HBRUSH
>(::GetStockObject(NULL_BRUSH));
109 operator HWND(
void)
const
139 if ( m_hWnd != NULL )
141 ::DestroyWindow(m_hWnd);
175 bool Create(
CDummyWindow::IListener* I, LPCTSTR lpszTitle = NULL, LPCTSTR lpszClassName = NULL, DWORD dwStyle = WS_OVERLAPPEDWINDOW, HMENU hMenu = NULL, HWND hParent = NULL)
180 if ( lpszTitle == NULL )
184 m_className = lpszClassName;
187 m_className.
Format(_T(
"TnbLib:%d:%d"), ::GetCurrentProcessId(),
this);
191 m_hWnd = ::CreateWindow(m_className, lpszTitle, dwStyle, 100, 0, 100, 0, hParent, hMenu, hInst, NULL);
192 if ( m_hWnd != NULL )
194 (*s_pmapDmyWndHwndProc)[m_hWnd] = I;
218 HANDLE h = ::GetCurrentThread();
219 (*s_pmapDmyWndHwndProc)[h] = I;
220 m_hWnd = ::CreateDialog(hInst, MAKEINTRESOURCE(templateId), hParent, ms_DlgProc);
221 if ( m_hWnd != NULL )
223 (*s_pmapDmyWndHwndProc)[m_hWnd] = I;
224 s_pmapDmyWndHwndProc->RemoveKey(h);
237 return ::GetWindowLong(m_hWnd, GWL_STYLE);
246 return ::GetWindowLong(m_hWnd, GWL_EXSTYLE);
259 return m_ModifyStyle(GWL_STYLE, dwRemove, dwAdd, nFlags);
272 return m_ModifyStyle(GWL_EXSTYLE, dwRemove, dwAdd, nFlags);
284 if ( s_pmapDmyWndHwndProc != NULL )
286 s_pmapDmyWndHwndProc->RemoveAll();
287 delete s_pmapDmyWndHwndProc;
288 s_pmapDmyWndHwndProc = NULL;
290 if ( s_psyncDmyWnd != NULL )
292 delete s_psyncDmyWnd;
293 s_psyncDmyWnd = NULL;
299 void m_CreateSub(
void)
301 if ( s_pmapDmyWndHwndProc == NULL )
310 bool m_ModifyStyle(
int nStyleOffset, DWORD dwRemove, DWORD dwAdd, UINT nFlags)
312 DWORD dwStyle = ::GetWindowLong(m_hWnd, nStyleOffset);
313 DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
314 if ( dwStyle == dwNewStyle )
318 ::SetWindowLong(m_hWnd, nStyleOffset, dwNewStyle);
321 ::SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
326 static bool CALLBACK ms_CmnProc(LRESULT& _result, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
328 if ( s_pmapDmyWndHwndProc == NULL )
332 s_psyncDmyWnd->Lock();
334 if ( s_pmapDmyWndHwndProc->HasKey(hWnd) )
336 LPVOID P = (*s_pmapDmyWndHwndProc)[hWnd];
337 I =
static_cast<IListener*
>(P);
341 HANDLE h = ::GetCurrentThread();
342 if ( s_pmapDmyWndHwndProc->HasKey(h) )
344 LPVOID P = (*s_pmapDmyWndHwndProc)[h];
345 I =
static_cast<IListener*
>(P);
351 r = I->OnWindowMessage(_result, hWnd, uMsg, wParam, lParam);
353 if ( uMsg == WM_DESTROY )
355 s_pmapDmyWndHwndProc->RemoveKey(hWnd);
356 if ( s_pmapDmyWndHwndProc->GetSize() == 0 )
358 if ( s_pmapDmyWndHwndProc != NULL )
360 delete s_pmapDmyWndHwndProc;
361 s_pmapDmyWndHwndProc = NULL;
363 if ( s_psyncDmyWnd != NULL )
365 s_psyncDmyWnd->Unlock();
366 delete s_psyncDmyWnd;
367 s_psyncDmyWnd = NULL;
371 if ( s_psyncDmyWnd != NULL )
373 s_psyncDmyWnd->Unlock();
377 static LRESULT CALLBACK ms_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
380 if ( ms_CmnProc(r, hWnd, uMsg, wParam, lParam) )
384 return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
387 static INT_PTR CALLBACK ms_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
390 if ( ms_CmnProc(r, hWnd, uMsg, wParam, lParam) )
398 case WM_CTLCOLOREDIT:
399 case WM_CTLCOLORLISTBOX:
400 case WM_CTLCOLORSCROLLBAR:
401 case WM_CTLCOLORSTATIC:
402 case WM_CTLCOLORMSGBOX:
404 case WM_QUERYDRAGICON:
409 ::SetWindowLong(hWnd, DWL_MSGRESULT, r);
411 ::SetWindowLongPtr(hWnd, DWLP_MSGRESULT, r);
418 ATOM m_RegisterClass(
void)
421 WNDCLASSEX wc = {
sizeof(WNDCLASSEX) };
423 WNDCLASS wc = {
sizeof(WNDCLASS) };
425 wc.style = CS_HREDRAW | CS_VREDRAW;
426 wc.lpfnWndProc = ms_WndProc;
428 wc.hbrBackground = m_brush;
429 wc.lpszClassName = m_className;
431 return ::RegisterClassEx(&wc);
433 return ::RegisterClass(&wc);
437 void m_UnregisterClass(
void)
DWORD GetStyle(void) const
[取得] スタイル取得.
~CDummyWindow(void)
デストラクタ
CDummyWindow(void)
コンストラクタ
bool ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
[設定] 拡張スタイル変更.
bool IsWindow(void) const
[確認] ウィンドウの有無.
DWORD GetStyleEx(void) const
[取得] 拡張スタイル取得.
void Destroy(void)
[操作] ウィンドウの破棄.
bool ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
[設定] スタイル変更.
void SetBrush(HBRUSH b)
[設定] 背景ブラシ設定.
bool Create(CDummyWindow::IListener *I, LPCTSTR lpszTitle=NULL, LPCTSTR lpszClassName=NULL, DWORD dwStyle=WS_OVERLAPPEDWINDOW, HMENU hMenu=NULL, HWND hParent=NULL)
[操作] ウィンドウの作成.
HWND GetSafeHwnd(void) const
[取得] ウィンドウハンドル.
bool CreateByTemplate(CDummyWindow::IListener *I, UINT templateId, HWND hParent=NULL)
[操作] ウィンドウの作成(テンプレート使用).
bool IsEmpty(void) const
[確認] 空チェック
void Format(const TYP *lpszFormat,...)
[代入] 書式付き文字列代入.
HINSTANCE GetInstanceHandleByTnb(EInstanceType type=EI_Process)
[取得] インスタンスハンドル取得.
virtual ~IListener(void)
デストラクタ
virtual bool OnWindowMessage(LRESULT &_result, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)=0
[通知] 受信メッセージ通知.