Пример #1
0
BOOL CControlBar::PreTranslateMessage( MSG *pMsg )
/************************************************/
{
    if( CWnd::PreTranslateMessage( pMsg ) ) {
        return( TRUE );
    }

    if( m_dwStyle & CBRS_FLYBY ) {
        if( (pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) ) {
            CPoint point( ::GetMessagePos() );
            ScreenToClient( &point );

            AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
            ASSERT( pState != NULL );
            
            INT_PTR nID = OnToolHitTest( point, NULL );
            if( pState->m_nLastStatus != nID || pState->m_pLastStatus != this ) {
                CWnd    *pOwner = GetOwner();
                ASSERT( pOwner != NULL );
                if( nID > 0 ) {
                    pState->m_nLastStatus = nID;
                    pState->m_pLastStatus = this;
                    pOwner->SendMessage( WM_SETMESSAGESTRING, nID );
                    SetTimer( TIMER_ID, 100, NULL );
                } else {
                    pState->m_nLastStatus = -1;
                    pState->m_pLastStatus = NULL;
                    pOwner->SendMessage( WM_POPMESSAGESTRING, AFX_IDS_IDLEMESSAGE );
                }
            }
        }
    }
    return( FALSE );
}
Пример #2
0
void CControlBar::OnLButtonDblClk( UINT nFlags, CPoint point )
/************************************************************/
{
    CWnd::OnLButtonDblClk( nFlags, point );
    if( m_pDockContext != NULL && OnToolHitTest( point, NULL ) < 0 ) {
        ClientToScreen( &point );
        m_pDockContext->ToggleDocking();
    }
}
Пример #3
0
void CControlBar::OnLButtonDown( UINT nFlags, CPoint point )
/**********************************************************/
{
    CWnd::OnLButtonDown( nFlags, point );
    if( m_pDockContext != NULL && OnToolHitTest( point, NULL ) < 0 ) {
        ClientToScreen( &point );
        m_pDockContext->StartDrag( point );
    }
}
Пример #4
0
LRESULT CControlBar::OnHelpHitTest(WPARAM, LPARAM lParam)
{
	ASSERT_VALID(this);

	INT_PTR nID = OnToolHitTest((DWORD)lParam, NULL);
	if (nID != -1)
		return HID_BASE_COMMAND+nID;

	nID = _AfxGetDlgCtrlID(m_hWnd);
	return nID != 0 ? HID_BASE_CONTROL+nID : 0;
}
Пример #5
0
LRESULT CControlBar::OnHelpHitTest( WPARAM wParam, LPARAM lParam )
/****************************************************************/
{
    UNUSED_ALWAYS( wParam );
    
    CPoint point( lParam );
    INT_PTR nID = OnToolHitTest( point, NULL );
    if( nID <= 0 ) {
        return( 0L );
    }
    return( nID );
}
Пример #6
0
void CControlBar::OnTimer( UINT_PTR nIDEvent )
/********************************************/
{
    if( nIDEvent == TIMER_ID ) {
        CPoint point( ::GetMessagePos() );
        ::ScreenToClient( m_hWnd, &point );
        if( OnToolHitTest( point, NULL ) <= 0 ) {
            CWnd *pOwner = GetOwner();
            ASSERT( pOwner != NULL );
            pOwner->SendMessage( WM_POPMESSAGESTRING, AFX_IDS_IDLEMESSAGE );
            KillTimer( TIMER_ID );
        }
    }
}
Пример #7
0
void CControlBar::OnLButtonDblClk(UINT nFlags, CPoint pt)
{
	// only toggle docking if clicked in "void" space
	if (m_pDockBar != NULL && OnToolHitTest(pt, NULL) == -1)
	{
		// start the drag
		ASSERT(m_pDockContext != NULL);
		m_pDockContext->ToggleDocking();
	}
	else
	{
		CWnd::OnLButtonDblClk(nFlags, pt);
	}
}
Пример #8
0
void CControlBar::OnLButtonDown(UINT nFlags, CPoint pt)
{
	// only start dragging if clicked in "void" space
	if (m_pDockBar != NULL && OnToolHitTest(pt, NULL) == -1)
	{
		// start the drag
		ASSERT(m_pDockContext != NULL);
		ClientToScreen(&pt);
		m_pDockContext->StartDrag(pt);
	}
	else
	{
		CWnd::OnLButtonDown(nFlags, pt);
	}
}
Пример #9
0
void COXSizeControlBar::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// only toggle docking if clicked in "void" space
	if (m_pDockBar != NULL && OnToolHitTest(point, NULL) == -1)
	{
		COXSizeDockBar* pSzDockBar = DYNAMIC_DOWNCAST(COXSizeDockBar, m_pDockBar);
		if (pSzDockBar != NULL && AfxGetMainWnd()->SendMessage(WM_QUERYSNAPPING))
		{
			// If this was tabbed we need to untab it and select something else
			int iOldIndex = pSzDockBar->m_wndDockTabCtrl.FindTab(this);
			if (iOldIndex != -1)
				pSzDockBar->m_wndDockTabCtrl.RemoveTab(this);			
		}

		// start the drag
		ASSERT(m_pDockContext != NULL);
		m_pDockContext->ToggleDocking();	
	}
	else
	{
		CWnd::OnLButtonDblClk(nFlags, point);
	}
}
Пример #10
0
void CWnd::FilterToolTipMessage(MSG* pMsg)
{
    // this CWnd has tooltips enabled
    UINT message = pMsg->message;
    if ((message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE ||
            message == WM_LBUTTONUP || message == WM_RBUTTONUP ||
            message == WM_MBUTTONUP) &&
            (GetKeyState(VK_LBUTTON) >= 0 && GetKeyState(VK_RBUTTON) >= 0 &&
             GetKeyState(VK_MBUTTON) >= 0))
    {
        AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();

        // make sure that tooltips are not already being handled
        CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd);
        while (pWnd != NULL && !(pWnd->m_nFlags & (WF_TOOLTIPS|WF_TRACKINGTOOLTIPS)))
        {
            pWnd = pWnd->GetParent();
        }
        if (pWnd != this)
        {
            if (pWnd == NULL)
            {
                // tooltips not enabled on this CWnd, clear last state data
                pModuleThreadState->m_pLastHit = NULL;
                pModuleThreadState->m_nLastHit = static_cast<INT_PTR>(-1);
            }
            return;
        }

        CToolTipCtrl* pToolTip = pModuleThreadState->m_pToolTip;
        CWnd* pOwner = GetParentOwner();
        if (pToolTip != NULL && pToolTip->GetOwner() != pOwner)
        {
            pToolTip->DestroyWindow();
            delete pToolTip;
            pModuleThreadState->m_pToolTip = NULL;
            pToolTip = NULL;
        }
        if (pToolTip == NULL)
        {
            pToolTip = new CToolTipCtrl;
            if (!pToolTip->Create(pOwner, TTS_ALWAYSTIP))
            {
                delete pToolTip;
                return;
            }
            pToolTip->SendMessage(TTM_ACTIVATE, FALSE);
            pModuleThreadState->m_pToolTip = pToolTip;
        }

        ASSERT_VALID(pToolTip);
        ASSERT(::IsWindow(pToolTip->m_hWnd));

        TOOLINFO ti;
        memset(&ti, 0, sizeof(TOOLINFO));

        // determine which tool was hit
        CPoint point = pMsg->pt;
        ::ScreenToClient(m_hWnd, &point);
        TOOLINFO tiHit;
        memset(&tiHit, 0, sizeof(TOOLINFO));
        tiHit.cbSize = sizeof(AFX_OLDTOOLINFO);
        INT_PTR nHit = OnToolHitTest(point, &tiHit);

        // build new toolinfo and if different than current, register it
        CWnd* pHitWnd = nHit == -1 ? NULL : this;
        if (pModuleThreadState->m_nLastHit != nHit || pModuleThreadState->m_pLastHit != pHitWnd)
        {
            if (nHit != -1)
            {
                // add new tool and activate the tip
                ti = tiHit;
                ti.uFlags &= ~(TTF_NOTBUTTON|TTF_ALWAYSTIP);
                if (m_nFlags & WF_TRACKINGTOOLTIPS)
                    ti.uFlags |= TTF_TRACK;
                VERIFY(pToolTip->SendMessage(TTM_ADDTOOL, 0, (LPARAM)&ti));
                if ((tiHit.uFlags & TTF_ALWAYSTIP) || IsTopParentActive())
                {
                    // allow the tooltip to popup when it should
                    pToolTip->SendMessage(TTM_ACTIVATE, TRUE);
                    if (m_nFlags & WF_TRACKINGTOOLTIPS)
                        pToolTip->SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);

                    // bring the tooltip window above other popup windows
                    ::SetWindowPos(pToolTip->m_hWnd, HWND_TOP, 0, 0, 0, 0,
                                   SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
                }
            }
            else
            {
                pToolTip->SendMessage(TTM_ACTIVATE, FALSE);
            }

            // relay mouse event before deleting old tool
            _AfxRelayToolTipMessage(pToolTip, pMsg);

            // now safe to delete the old tool
            if (pModuleThreadState->m_pLastInfo != NULL &&
                    pModuleThreadState->m_pLastInfo->cbSize >= sizeof(AFX_OLDTOOLINFO))
                pToolTip->SendMessage(TTM_DELTOOL, 0, (LPARAM)pModuleThreadState->m_pLastInfo);

            pModuleThreadState->m_pLastHit = pHitWnd;
            pModuleThreadState->m_nLastHit = nHit;
            if (pModuleThreadState->m_pLastInfo == NULL)
            {
                pModuleThreadState->m_pLastInfo = new TOOLINFO;
                memset(pModuleThreadState->m_pLastInfo, 0, sizeof(TOOLINFO));
            }
            *pModuleThreadState->m_pLastInfo = tiHit;
        }
        else
        {
            if (m_nFlags & WF_TRACKINGTOOLTIPS)
            {
                POINT pt;

                ::GetCursorPos( &pt );
                pToolTip->SendMessage(TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y));
            }
            else
            {
                // relay mouse events through the tooltip
                if (nHit != -1)
                    _AfxRelayToolTipMessage(pToolTip, pMsg);
            }
        }

        if ((tiHit.lpszText != LPSTR_TEXTCALLBACK) && (tiHit.hinst == 0))
            free(tiHit.lpszText);
    }
    else if (m_nFlags & (WF_TOOLTIPS|WF_TRACKINGTOOLTIPS))
    {
        // make sure that tooltips are not already being handled
        CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd);
        while (pWnd != NULL && pWnd != this && !(pWnd->m_nFlags & (WF_TOOLTIPS|WF_TRACKINGTOOLTIPS)))
            pWnd = pWnd->GetParent();
        if (pWnd != this)
            return;

        BOOL bKeys = (message >= WM_KEYFIRST && message <= WM_KEYLAST) ||
                     (message >= WM_SYSKEYFIRST && message <= WM_SYSKEYLAST);
        if ((m_nFlags & WF_TRACKINGTOOLTIPS) == 0 &&
                (bKeys ||
                 (message == WM_LBUTTONDOWN || message == WM_LBUTTONDBLCLK) ||
                 (message == WM_RBUTTONDOWN || message == WM_RBUTTONDBLCLK) ||
                 (message == WM_MBUTTONDOWN || message == WM_MBUTTONDBLCLK) ||
                 (message == WM_NCLBUTTONDOWN || message == WM_NCLBUTTONDBLCLK) ||
                 (message == WM_NCRBUTTONDOWN || message == WM_NCRBUTTONDBLCLK) ||
                 (message == WM_NCMBUTTONDOWN || message == WM_NCMBUTTONDBLCLK)))
        {
            CWnd::CancelToolTips(bKeys);
        }
    }
}
Пример #11
0
BOOL CControlBar::PreTranslateMessage(MSG* pMsg)
{
	ASSERT_VALID(this);
	ASSERT(m_hWnd != NULL);

	// allow tooltip messages to be filtered
	if (CWnd::PreTranslateMessage(pMsg))
		return TRUE;

	UINT message = pMsg->message;
	CWnd* pOwner = GetOwner();

	// handle CBRS_FLYBY style (status bar flyby help)
	if (((m_dwStyle & CBRS_FLYBY) ||
		message == WM_LBUTTONDOWN || message == WM_LBUTTONUP) &&
		((message >= WM_MOUSEFIRST && message <= AFX_WM_MOUSELAST) ||
		 (message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST)))
	{
	AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();

		// gather information about current mouse position
		CPoint point = pMsg->pt;
		ScreenToClient(&point);
		TOOLINFO ti; memset(&ti, 0, sizeof(TOOLINFO));
		ti.cbSize = sizeof(AFX_OLDTOOLINFO);
		INT_PTR nHit = OnToolHitTest(point, &ti);
		if (ti.lpszText != LPSTR_TEXTCALLBACK)
			free(ti.lpszText);
		BOOL bNotButton =
			message == WM_LBUTTONDOWN && (ti.uFlags & TTF_NOTBUTTON);
		if (message != WM_LBUTTONDOWN && GetKeyState(VK_LBUTTON) < 0)
			nHit = pModuleThreadState->m_nLastStatus;

		// update state of status bar
		if (nHit < 0 || bNotButton)
		{
			if (GetKeyState(VK_LBUTTON) >= 0 || bNotButton)
			{
				SetStatusText(static_cast<INT_PTR>(-1));
				KillTimer(ID_TIMER_CHECK);
			}
		}
		else
		{
			if (message == WM_LBUTTONUP)
			{
				SetStatusText(static_cast<INT_PTR>(-1));
				ResetTimer(ID_TIMER_CHECK, 200);
			}
			else
			{
				if ((m_nStateFlags & statusSet) || GetKeyState(VK_LBUTTON) < 0)
					SetStatusText(nHit);
				else if (nHit != pModuleThreadState->m_nLastStatus)
					ResetTimer(ID_TIMER_WAIT, 300);
			}
		}
		pModuleThreadState->m_nLastStatus = nHit;
	}

	// don't translate dialog messages when in Shift+F1 help mode
	CFrameWnd* pFrameWnd = GetTopLevelFrame();
	if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
		return FALSE;

	// since 'IsDialogMessage' will eat frame window accelerators,
	//   we call all frame windows' PreTranslateMessage first
	while (pOwner != NULL)
	{
		// allow owner & frames to translate before IsDialogMessage does
		if (pOwner->PreTranslateMessage(pMsg))
			return TRUE;

		// try parent frames until there are no parent frames
		pOwner = pOwner->GetParentFrame();
	}

	// filter both messages to dialog and from children
	if (::IsWindow(m_hWnd))
		return PreTranslateInput(pMsg);
	return FALSE;
}
Пример #12
0
void CControlBar::OnTimer(UINT_PTR nIDEvent)
{
	if (GetKeyState(VK_LBUTTON) < 0)
		return;

	AFX_MODULE_THREAD_STATE* pModuleThreadState = AfxGetModuleThreadState();

	// get current mouse position for hit test
	CPoint point; GetCursorPos(&point);
	ScreenToClient(&point);
	INT_PTR nHit = OnToolHitTest(point, NULL);
	if (nHit >= 0)
	{
		CWnd *pParent=GetTopLevelParent();
		// determine if status bar help should go away
        if(!IsTopParentActive())
        {
            nHit=-1;
        }
        else
        {
			ENSURE(pParent);
		    if(!pParent->IsWindowEnabled())
            {
			    nHit = -1;
            }
        }

		// remove status help if capture is set
		HWND hWndTip = pModuleThreadState->m_pToolTip->GetSafeHwnd();
		CWnd* pCapture = GetCapture();
		if (pCapture != this && pCapture->GetSafeHwnd() != hWndTip &&
			pCapture->GetTopLevelParent() == pParent)
		{
			nHit = -1;
		}
	}
	else
	{
		pModuleThreadState->m_nLastStatus = static_cast<INT_PTR>(-1);
	}

	// make sure it isn't over some other app's window
	if (nHit >= 0)
	{
		ClientToScreen(&point);
		HWND hWnd = ::WindowFromPoint(point);
		if (hWnd == NULL || (hWnd != m_hWnd && !::IsChild(m_hWnd, hWnd) &&
			pModuleThreadState->m_pToolTip->GetSafeHwnd() != hWnd))
		{
			nHit = -1;
			pModuleThreadState->m_nLastStatus = static_cast<INT_PTR>(-1);
		}
	}

	// handle the result
	if (nHit < 0)
	{
		if (pModuleThreadState->m_nLastStatus == static_cast<INT_PTR>(-1))
			KillTimer(ID_TIMER_CHECK);
		SetStatusText(static_cast<INT_PTR>(-1));
	}

	// set status text after initial timeout
	if (nIDEvent == ID_TIMER_WAIT)
	{
		KillTimer(ID_TIMER_WAIT);
		if (nHit >= 0)
			SetStatusText(nHit);
	}
}