BOOL CSSEditCtrls::SubclassCtrls(CWnd *pParent, int nIDEdit, int nIDSpinner, int nIDSlider) { ASSERT(!m_nLockCnt); m_nLockCnt = 1; ASSERT(nIDEdit && nIDEdit != -1); ASSERT(!nIDSpinner || nIDSpinner != -1 && nIDSpinner != nIDEdit); ASSERT(!nIDSlider || nIDSlider != -1 && nIDSlider != nIDEdit && (!nIDSlider || nIDSlider != nIDSpinner)); ASSERT(!m_hWnd); if (!SubclassDlgItem(nIDEdit, pParent)) return FALSE; ASSERT(!m_Spinner.m_hWnd); if (nIDSpinner && !m_Spinner.SubclassDlgItem(nIDSpinner, pParent)) { UnsubclassWindow(); return FALSE; } ASSERT(!m_Slider.m_hWnd); if (nIDSlider && !m_Slider.SubclassDlgItem(nIDSlider, pParent)) { if (nIDSpinner) m_Spinner.UnsubclassWindow(); UnsubclassWindow(); return FALSE; } ASSERT(m_hWnd && GetDlgCtrlID() == nIDEdit); ASSERT(!nIDSpinner || m_Spinner.m_hWnd && m_Spinner.GetDlgCtrlID() == nIDSpinner); ASSERT(!nIDSlider || m_Slider.m_hWnd && m_Slider.GetDlgCtrlID() == nIDSlider); --m_nLockCnt; return TRUE; }
BOOL CGetFilenameControl::Reset (void) { // test our inputs ASSERT(this); if (!IsWindow(m_Edit.GetSafeHwnd())) { ASSERT(FALSE); TRACE0("CGetFilenameControl::Reset -- EditButton window handle is invalid!\n"); return FALSE; } // remove the button if (!RemoveEditButton()) { TRACE0("CGetFilenameControl::Reset -- Failure to remove button control!\n"); ASSERT(FALSE); return FALSE; } // subclass the control HWND hWnd = UnsubclassWindow(); if (NULL == hWnd) { TRACE0("CGetFilenameControl::Reset -- Failure to Unsubclass edit control!\n"); ASSERT(FALSE); return FALSE; } m_sDir.Empty(); return TRUE; }
//----------------------------------------------------------------------------- void CWindowMinMaxSubclass::SubclassWindow() { #ifdef XP_WIN if (m_prevWndProc != NULL) UnsubclassWindow(); m_prevWndProc = (WNDPROC)GetWindowLong(m_hwnd, GWL_WNDPROC); SetWindowLong(m_hwnd, GWL_USERDATA, (LONG)this); SetWindowLong(m_hwnd, GWL_WNDPROC, (LONG)WindowMinMaxSubclassProc); { DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; char szMsg[80]; ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) ); NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; NotificationFilter.dbcc_classguid = GUID_NULL; HDEVNOTIFY hDevNotify = RegisterDeviceNotification( m_hwnd, &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES ); if(!hDevNotify) { ::wsprintfA(szMsg, "RegisterDeviceNotification failed: %d\n", ::GetLastError()); ::MessageBoxA(m_hwnd, szMsg, "Registration", MB_OK); } else { m_hDevNotify = hDevNotify; } } #endif }
// Unsubclasses MDIClient window and destroys the COXTabWorkspace control // that was used to manage MDIChild window BOOL COXTabClientWnd::Detach() { // Check if any attached if(!IsAttached()) { TRACE(_T("COXTabClientWnd::Attach: there is nothing to detach! Window hasn't been attached!\n")); return FALSE; } // Destroy tab control if(::IsWindow(m_tab.GetSafeHwnd())) m_tab.DestroyWindow(); m_tab.m_pTabClientWnd=NULL; // Unsubclass MDIClient window UnsubclassWindow(); // Update the size and position of the MDIClient window if(::IsWindow(m_pParentFrame->GetSafeHwnd())) m_pParentFrame->RecalcLayout(); m_pParentFrame=NULL; return TRUE; }
void CySplitterWnd::Unbind(void) { if (!::IsWindow(m_hWnd)) return; DetachAllCtrls(); UnsubclassWindow(); }
//----------------------------------------------------------------------------- CWindowMinMaxSubclass::~CWindowMinMaxSubclass() { #ifdef XP_WIN UnsubclassWindow(); NS_RELEASE(m_callback); #endif } // dtor
//============================================================================= // Process window message from list view. Call default to bypass MFC // entirely because MFC has all sorts of ASSERT checks that will bomb. // The only message I care about is WM_DESTROY, to re-initialize myself. // // The original version in MSDN only overrode OnCommand; it's necessary to // override WindowProc to completely bypass MFC. // LRESULT CXFileOpenListView::WindowProc(UINT msg, WPARAM, LPARAM) //============================================================================= { if (msg == WM_DESTROY) { m_lastViewMode = GetViewMode(); // save current view mode UnsubclassWindow(); // unsubclass myself } return Default(); // all message: pass to default WndProc, avoid MFC/CWnd }
void CXTPTabCtrlButtons::UnSubclassTabButtons() { if (m_hWnd) { HWND hWnd = UnsubclassWindow(); if (hWnd == m_hwndPrimary) { ::DestroyWindow(hWnd); } } m_hwndSubclassed = NULL; }
void CEditLog::SetEditCtrl( HWND hEdit ) { if( hEdit != GetHandle() && GetHandle() != NULL ) UnsubclassWindow(); if( SubclassWindow( hEdit ) ) { // We want to support a lot of text... // Note that Win9x supports no more than 64kb of text! - just too bad... // Tip: Use NT/2k :-) ::SendMessage( hEdit, EM_LIMITTEXT, 0, 0 ); } }
BOOL CResizablePageEx::OnInitDialog() { CPropertyPageEx::OnInitDialog(); // set the initial size as the min track size CRect rc; GetWindowRect(&rc); SetMinTrackSize(rc.Size()); // HACK: temporarily abandon subclassing // CAUSE: system subclasses this window after this message // ISSUE: our WindowProc is not the first to be called // and we miss some painting related messages if (Attach(UnsubclassWindow())) { CWnd* pParent = GetParent(); pParent->LockWindowUpdate(); Post_SheetPageExHack(pParent->GetSafeHwnd(), m_hWnd); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CySplitterWnd::Unbind(void) { DetachAllPanes(); UnsubclassWindow(); }
CXRefreshToolbar::~CXRefreshToolbar() { DT(TRACE_I(FS(_T("Toolbar[%08X]: destructor"), this))); m_Toolbar.DestroyWindow(); UnsubclassWindow(); }
CUpgradrToolbar::~CUpgradrToolbar() { DT(TRACE_I(FS(_T("Toolbar[%08X]: destructor"), this))); m_kToolbar.DestroyWindow(); UnsubclassWindow(); }
CEditLog::~CEditLog( ) { UnsubclassWindow(); ::DeleteCriticalSection( &m_csLock ); }
void CEditLog::OnDestroy( ) { UnsubclassWindow(); }
CSubclassWnd::~CSubclassWnd() { if (m_hWnd != NULL) UnsubclassWindow(); }
void CToolWindow::DetachFromIE() { if (!m_hWnd) return; ::DestroyWindow(UnsubclassWindow(TRUE)); // HACK: i shouldn't destroy IE's windows }
CMainWindow::~CMainWindow() { if (IsWindow()) UnsubclassWindow(TRUE); }