Пример #1
0
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;
}
Пример #2
0
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
}
Пример #4
0
// 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;
}
Пример #5
0
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
}
Пример #8
0
void CXTPTabCtrlButtons::UnSubclassTabButtons()
{
	if (m_hWnd)
	{
		HWND hWnd = UnsubclassWindow();
		if (hWnd == m_hwndPrimary)
		{
			::DestroyWindow(hWnd);
		}
	}
	m_hwndSubclassed = NULL;
}
Пример #9
0
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 );
	}
}
Пример #10
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
}
Пример #11
0
void CySplitterWnd::Unbind(void)
{
    DetachAllPanes();
    UnsubclassWindow();
}
Пример #12
0
CXRefreshToolbar::~CXRefreshToolbar()
{
	DT(TRACE_I(FS(_T("Toolbar[%08X]: destructor"), this)));
	m_Toolbar.DestroyWindow();
	UnsubclassWindow();
}
Пример #13
0
CUpgradrToolbar::~CUpgradrToolbar()
{
	DT(TRACE_I(FS(_T("Toolbar[%08X]: destructor"), this)));
	m_kToolbar.DestroyWindow();
	UnsubclassWindow();
}
Пример #14
0
CEditLog::~CEditLog(
		)
{
	UnsubclassWindow();
	::DeleteCriticalSection( &m_csLock );
}
Пример #15
0
void CEditLog::OnDestroy(
		)
{
	UnsubclassWindow();
}
Пример #16
0
CSubclassWnd::~CSubclassWnd()
{
	if (m_hWnd != NULL)
		UnsubclassWindow();
}
Пример #17
0
void 
CToolWindow::DetachFromIE()
{
	if (!m_hWnd) return;
	::DestroyWindow(UnsubclassWindow(TRUE)); // HACK: i shouldn't destroy IE's windows
}
Пример #18
0
CMainWindow::~CMainWindow()
{
	if (IsWindow())
		UnsubclassWindow(TRUE);
}