LRESULT CSubclassWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { ASSERT(m_hWnd); ASSERT(m_hWndAfter); ASSERT(m_oldWndProc); #if 0 if(uMsg == WM_CLOSE) /*有时侯窗口处理完WM_CLOSE就没有WM_NCDESTROY了*/ { WNDPROC hOld = Unsubclass(); LRESULT lr = ::CallWindowProc(hOld, m_hWndAfter, uMsg, wParam, lParam); return lr; } #endif if(uMsg == WM_NCDESTROY)// { LRESULT lr; if(m_hWnd != NULL) { WNDPROC hOld = Unsubclass(); lr = ::CallWindowProc(hOld, m_hWndAfter, uMsg, wParam, lParam); } else { lr = ::DefWindowProc(m_hWndAfter, uMsg, wParam, lParam); } PostNcDestroy(); return lr; } return ::CallWindowProc(m_oldWndProc, m_hWnd, uMsg, wParam, lParam); }
static LRESULT CALLBACK TreeProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { UNUSED(uIdSubclass); TreeCtrl* w = (TreeCtrl*)dwRefData; CrashIf(w->hwnd != (HWND)hwnd); if (w->preFilter) { bool discard = false; auto res = w->preFilter(hwnd, msg, wp, lp, discard); if (discard) { return res; } } if (WM_ERASEBKGND == msg) { return FALSE; } if (WM_KEYDOWN == msg) { if (HandleKey(hwnd, wp)) { return 0; } } if (WM_NCDESTROY == msg) { Unsubclass(w); return DefSubclassProc(hwnd, msg, wp, lp); } return DefSubclassProc(hwnd, msg, wp, lp); }
CSubclassWnd::~CSubclassWnd() { Unsubclass(); if(CSubclassWnd::m_SubclassWndMap.GetSize() <= 0) { delete CSubclassWnd::m_CS; CSubclassWnd::m_CS = NULL; CSubclassWnd::m_bCSinit = false; } }
bool CWndScroller::Close(void) { bool result = true; if (!Unsubclass()) //detach window result = false; mp_origWnd = NULL; return result; }
HWND CSiWindow::Detach() { if(m_timerId != 0) { ::KillTimer(m_hWnd, PW_TIMER_ID); m_timerId = 0; } m_powerMode.Detach(); HWND hTmp = m_hWnd; Unsubclass(); return hTmp; }
void BalloonMsg::SubclassWnd(HWND wnd) { if (g_balloon) g_balloon->Close(); Unsubclass(); ::GetWindowRect(wnd, &g_child_window_rect_rect); g_sentry = wnd; g_balloon = this; g_pfnOldWindowProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(wnd, GWLP_WNDPROC, LONG_PTR(SentryWindowProc))); g_parent = ::GetParent(wnd); if (g_parent) g_pfnOldWindowProc2 = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(g_parent, GWLP_WNDPROC, LONG_PTR(ParentWindowProc))); }
void BalloonMsg::Close() { if (closing_) return; closing_ = true; // AFX_MANAGE_STATE(AfxGetStaticModuleState()) UninstallMouseHook(); ShowWindow(SW_HIDE); TOOLINFO ti; ti.cbSize = sizeof ti; ti.uFlags = TTF_TRACK | TTF_IDISHWND; ti.hwnd = g_sentry; ti.uId = 1; ti.hinst = NULL; ti.lpszText = 0; ti.rect.left = 0; ti.rect.top = 0; ti.rect.right = 0; ti.rect.bottom = 0; ti.lParam = 0; SendMessage(TTM_TRACKACTIVATE, false, LPARAM(&ti)); HWND wnd= g_sentry; Unsubclass(); KillTimer(1); DestroyWindow(); if (wnd && ::IsWindow(wnd)) { // this multiple invalidate rect takes care of proper // redrawing of MSFlexGrid control (at least usually); // when the scrollbar is on even that doesn't help ::InvalidateRect(wnd, 0, true); ::UpdateWindow(wnd); ::InvalidateRect(wnd, 0, true); ::RedrawWindow(wnd, 0, 0, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); } delete this; }
HWND CSubclassWnd::Detach() { Unsubclass(); return m_hWndAfter; }
TreeCtrl::~TreeCtrl() { Unsubclass(this); // DeleteObject(w->bgBrush); }