CToolTipCtrl flimmert und behindert den MainThread



  • Moin.

    Ich benötige ein ToolTip, welches in einem bestimmten Bereich meines Fensters ständig mit der Maus mitwandert und verschiedene Daten anzeigen soll.

    Dazu habe ich mir eine KLasse entwickelt, welche das Control beinhaltet:

    class CCursorToolTipInformation
    {
    public:
    	CCursorToolTipInformation::CCursorToolTipInformation(CWnd* pParent);
    	virtual ~CCursorToolTipInformation();
    
    	void						Show							(bool bShow);
    	void						Update							();
    	CToolTipCtrl*				GetToolTip						() { return m_pToolTip; }
    	void						SetToolTipText					(CString strText) { m_strToolText = strText; }
    
    protected:
    	CToolTipCtrl	*m_pToolTip;
    	CWnd			*m_pParent;
    	CString			m_strToolText;
    	//DECLARE_MESSAGE_MAP()
    };
    
    //************************************************************************************************************************************//
    CCursorToolTipInformation::CCursorToolTipInformation(CWnd* pParent)
    {
    	m_pToolTip = new CToolTipCtrl;
    	m_pToolTip->Create(pParent, TTS_ALWAYSTIP);
    	m_pToolTip->SetDelayTime(TTDT_AUTOPOP, 0);
    	m_pToolTip->AddTool(pParent);
    	m_pParent = pParent;
    }
    
    //************************************************************************************************************************************//
    CCursorToolTipInformation::~CCursorToolTipInformation(){}
    
    //************************************************************************************************************************************//
    void CCursorToolTipInformation::Show(bool bShow)
    {
    	static bool	bIsShown = false;
    
    	if(bShow == true)
    	{
    		if(bIsShown == false)
    		{
    			m_pToolTip->Activate(TRUE);
    			m_pToolTip->SetMaxTipWidth(SHRT_MAX);
    			bIsShown = true;
    		}
    
    		Update();
    	}
    	else
    	{
    		m_pToolTip->Activate(FALSE);
    		bIsShown = false;
    	}
    }
    
    //************************************************************************************************************************************//
    void CCursorToolTipInformation::Update()
    {
    	if(m_pToolTip == NULL)
    		return;
    
    	// Set tooltip to multiline
    	m_pToolTip->UpdateTipText(m_strToolText, m_pParent);
    }
    

    Befeuert wird diese aus dem View:

    int CS57View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    	if (CView::OnCreate(lpCreateStruct) == -1)
    		return -1;
    
        // some code ...
    
    	m_pCursorInformations = new CCursorToolTipInformation(this);
    	if(m_pCursorInformations == NULL)
    		TRC(TRC_ERR, "CMainFrame::OnCreate() m_pCursorInformations = NULL");
    
    	return 0;
    }
    
    BOOL CS57View::PreTranslateMessage(MSG* pMsg) 
    {
    	if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
    	{
    		if((pMainFrame->m_pCursorInformationsDlg != NULL) && (pMainFrame->m_pCursorInformationsDlg->IsShowInformations() == true))
    			m_pCursorInformations->GetToolTip()->RelayEvent(pMsg);
    	}
    
    	return CView::PreTranslateMessage(pMsg);
    }
    

    OnMouseMove bedient das Show() des Objektes m_pCursorInformations mit Parameter true.
    OnMouseLeave ebenso nur mit false.
    Beide kommen aus dem abgeleiteten S57View.

    Grundsätzlich macht das ToolTip was es soll. Leider Gottes flimmert es stark, wenn man die Maus nicht bewegt und weiterhin bleibt der MainThread auf meinem i7 soweit stehen, dass nicht mal mehr die Timer feuern.

    Ich denke, ich hab da wohl was nicht richtig gemacht und würde mich über Tips und Hilfe freuen.

    EntwicklungsSystem: i7 mit Win7 und VS2003
    Zielsystem: Intel Dualcore mit WinXP

    Gruß, Sven


  • Mod

    Du musst doch gar keinen Show machen. Ein Tooltip popped doch selber auf!


Anmelden zum Antworten