void CHapticMouse::ShowMouseCursor(BOOL bShowCursor)
{
    // Set or hide the mouse pointer
    if (IsTopParentActive())
        if (bShowCursor)
            ::SetCursor(::LoadCursor(NULL, IDC_ARROW));
        else
            ::SetCursor(NULL);
}
void CHapticMouse::OnPhantomEntry()
{
    if (m_bInitialized)
        EnterHaptics();

    // bring this application to the foreground and give it the focus
    if (!IsTopParentActive()) {
        SetForegroundWindow();
        SetActiveWindow();
    }
}
示例#3
0
void CView::OnActivateView(BOOL bActivate, CView* pActivateView, CView*)
{
	UNUSED pActivateView;   // unused in release builds

	if (bActivate)
	{
		ASSERT(pActivateView == this);

		// take the focus if this frame/view/pane is now active
		if (IsTopParentActive())
			SetFocus();
	}
}
示例#4
0
void CGuiToolButton::OnMouseMove(UINT nFlags, CPoint 
								 point)
{
	// TODO: Add your message handler code here and/or call default
	if (m_bMouserOver) return;
	if (!IsTopParentActive() || !GetTopLevelParent()->IsWindowEnabled())
		return;
	CRect rc;
	GetClientRect(rc);
	if (rc.PtInRect(point))
	{
		m_bMouserOver=TRUE;
		SetTimer(1,50,0);
		UPDATEWIN 		
	}
void CDockButton::OnMouseMove(UINT nFlags, CPoint point)
{
    // TODO: Add your message handler code here and/or call default
    if (m_bMouseOver) return;

    if (!IsTopParentActive() || !GetTopLevelParent()->IsWindowEnabled())
        return;
    CRect m_rect;
    GetClientRect(m_rect);
    if (m_rect.PtInRect(point))
    {

        CGuiControlBar* m_tb=GetBar(m_hWnd);
        if 	((m_tb->IsVisible() && m_tb->IsAutoHide()) )
        {

            m_tb->ScrollOff();
            GetParentFrame()->ShowControlBar(m_tb, FALSE, FALSE);
        }
        else
        {
            if 	(!m_tb->IsVisible())
            {
                CGuiControlBar* m_tb1=IsControlVisible(m_tb);
                if (m_tb1!= NULL)
                {
                    if (m_tb1 != m_tb)
                    {
                        GetParentFrame()->ShowControlBar(m_tb1, FALSE, TRUE);
                    }
                }
                m_tb->ScrollOn();
                m_bMouseOver=TRUE;  //numero de ventana a activar
                SetTimer(1,500,0);
            }
        }
    }


    CWnd::OnMouseMove(nFlags, point);
}
示例#6
0
int CControlBar::HitTestToolTip(CPoint point, UINT* pHit)
{
	if (pHit != NULL)
		*pHit = (UINT)-1;   // assume it won't hit anything

	// make sure this app is active
	if (!IsTopParentActive())
		return HITTYPE_INACTIVE;

	// make sure the toolbar itself is active
	CWnd* pParent = GetTopLevelParent();
	if (!pParent->IsWindowEnabled())
		return HITTYPE_DISABLED;

	// check for this application tracking (capture set)
	CWnd* pCapture = GetCapture();
	CWnd* pCaptureParent = pCapture->GetTopLevelParent();
	if (pCaptureParent == pParent)
		return HITTYPE_TRACKING;

	// check for the bar having focus
	HWND hWnd = ::GetFocus();
	if (hWnd != NULL && (hWnd == m_hWnd || ::IsChild(m_hWnd, hWnd)))
		return HITTYPE_FOCUS;

	// see if the mouse point is actually in the control bar window
	hWnd = ::WindowFromPoint(point);
	if (hWnd == NULL || (hWnd != m_hWnd && !::IsChild(m_hWnd, hWnd)))
		return HITTYPE_OUTSIDE;

	// finally do the hit test on the items within the control bar
	ScreenToClient(&point);
	UINT nHit = OnCmdHitTest(point, NULL);
	if (pHit != NULL)
		*pHit = nHit;
	return nHit != (UINT)-1 ? HITTYPE_SUCCESS : HITTYPE_NOTHING;
}
示例#7
0
void CClosableTabCtrl::OnPaint(){
	//CTabCtrl::OnPaint();
	ModifyStyle(0, WS_CLIPCHILDREN);
	if( !m_pSpinCtrl )
    {
      CWnd * pWnd = FindWindowEx( GetSafeHwnd(), 0, _T("msctls_updown32"), 0 );
      if( pWnd )
      {
        m_pSpinCtrl = new CSpinButtonCtrl;
        m_pSpinCtrl->Attach(pWnd->GetSafeHwnd());
      }
    }

	BOOL aero=false;
	HMODULE hm=LoadLibrary(L"dwmapi.dll");
	if(hm){
		DWMISCOMPOSITIONENABLED* ic=(DWMISCOMPOSITIONENABLED*)GetProcAddress(hm, "DwmIsCompositionEnabled");
		(ic)(&aero);
		FreeLibrary(hm);
	}

	RECT wrect;
	GetWindowRect(&wrect);
	int w=wrect.right-wrect.left;
	int h=TAB_HEIGHT+TAB_TOP_MARGIN;
	CPaintDC _dc(this);
	if(!_dc.m_hDC)return;
	CDC dc;
	dc.CreateCompatibleDC(&_dc);
	if(!dc.m_hDC){
		ReleaseDC(&_dc);
		return;
	}
	CBitmap bmp;
	bmp.CreateCompatibleBitmap(&_dc, w, h);
	if(!bmp.m_hObject){
		ReleaseDC(&_dc);
		ReleaseDC(&dc);
		return;
	}
	CBitmap* obmp=dc.SelectObject(&bmp);

	
	CFont fnt;
	fnt.CreateFontW(-11, 0, 0, 0, 0, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, L"Tahoma"); 
	CFont* ofnt=dc.SelectObject(&fnt);
	
	

	dc.SetBkMode(TRANSPARENT);

	//skin.tabbarBG.bmp.DrawStretched(&dc, 0, 0, w, 20, 0, 0, 0, 0);
	if(!aero){
		COLORREF bgcol=IsTopParentActive()?GetSysColor(COLOR_ACTIVECAPTION):GetSysColor(COLOR_INACTIVECAPTION);
		dc.FillSolidRect(0, 0, w, h, bgcol);
	}

	int offset=5;

	if(m_pSpinCtrl){
		int p=LOWORD(m_pSpinCtrl->GetPos());
		for(int i=0;i<p;i++){
			offset-=itemWidths[i];
		}
	}

	itemWidths.clear();
	int totalWidth=5;

	for(int i=0;i<GetItemCount();i++){
		TC_ITEM item;
		memset(&item, 0, sizeof(TC_ITEM));
		item.mask=TCIF_TEXT|TCIF_IMAGE|TCIF_PARAM;
		item.pszText=new wchar_t[512];
		item.cchTextMax=512;
		GetItem(i, &item);
		int tw=dc.GetTextExtent(item.pszText, wcslen(item.pszText)).cx+40;
		RECT rect;
		rect.top=TAB_TOP_MARGIN;
		rect.bottom=h;
		rect.left=offset;
		rect.right=offset+tw;
		CTalkTab* tab=(CTalkTab*)item.lParam;

		totalWidth+=tw;

		if(i==this->GetCurSel()){
			skin.tabActive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			dc.SetTextColor(skin.tabActiveTextColor);
		}else if(over_idx==i){
			skin.tabOver.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabOverTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}else{
			skin.tabInactive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabIncativeTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}

		HICON hIcon=skin.iconUnknown;

		bool newmsg=false;
		if(tab){
			newmsg=tab->hasNewMsg;
			if(newmsg){
				hIcon=skin.iconNewMsg;
			}
		}

		if(item.iImage>0 && !newmsg){
			bool inList=false;
			for(int j=0;j<con.clDlg->friendList.items.size();j++){
				if(con.clDlg->friendList.items[j].uid==item.iImage){
					inList=true;
					break;
				}
			}
			if(inList){
				if(con.clDlg->friendList.items[con.clDlg->friendList.GetItemByUID(item.iImage)].online){
					hIcon=skin.iconOnline;
				}else{
					hIcon=skin.iconOffline;
				}
			}
		}

		if(tab){
			if(tab->tabProxy)tab->tabProxy->SetIcon(hIcon, false);
		}

		DrawIconEx(dc.GetSafeHdc(), offset+2, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, hIcon, 16, 16, 0, NULL, DI_NORMAL);

		if(i==this->GetCurSel()){
			skin.tabCloseAct.DrawUnscaled(&dc, offset+tw-18, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, 15, 15, 0, 0);
		}else{
			skin.tabCloseInact.DrawUnscaled(&dc, offset+tw-18, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, 15, 15, 0, 0);
		}

		if(!aero){
		dc.DrawText(item.pszText, wcslen(item.pszText), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		}else{
			if(i==this->GetCurSel()){
				CUtils::DrawAeroText(rect, &dc, 0, DT_CENTER|DT_VCENTER|DT_SINGLELINE, &fnt, item.pszText);
			}else{
				CUtils::DrawAeroText(rect, &dc, 3, DT_CENTER|DT_VCENTER|DT_SINGLELINE, &fnt, item.pszText);
			}
		}

		delete item.pszText;
		offset+=tw+TAB_SPACING;
		itemWidths.push_back(tw);
	}

	_dc.BitBlt(0, 0, w, h, &dc, 0, 0, SRCCOPY);
	dc.SelectObject(obmp);
	dc.SelectObject(ofnt);
	ReleaseDC(&dc);
	ReleaseDC(&_dc);
	SetItemSize(CSize(totalWidth/GetItemCount(), 20));
}
示例#8
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);
        }
    }
}
void CALLBACK CXTPMouseManager::TrackMouseTimerProc (HWND hWnd, UINT /*uMsg*/, UINT idEvent, DWORD /*dwTime*/)
{
	RECT    rect;
	POINT   pt;

	if (!IsWindow(hWnd))
	{
		KillTimer (hWnd, idEvent);
		XTPMouseManager()->m_hwndLeave = 0;
		return;
	}
	GetWindowRect(hWnd, &rect);
	::GetCursorPos (&pt);

	BOOL bTopParentActive = GetParent(hWnd) == 0 || (GetWindowLong(hWnd, GWL_STYLE) & WS_POPUP) || IsTopParentActive(hWnd);
	if (!::PtInRect (&rect, pt) || !bTopParentActive)
	{
		KillTimer (hWnd, idEvent);
		XTPMouseManager()->m_hwndLeave = 0;

		::PostMessage (hWnd, WM_MOUSELEAVE, 0, 0);
	}


}
示例#10
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);
	}
}