Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPControlComboBox and ListBox Tooltip
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPControlComboBox and ListBox Tooltip

 Post Reply Post Reply
Author
Message
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 515
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Topic: CXTPControlComboBox and ListBox Tooltip
    Posted: 02 October 2007 at 12:37pm
Hello,

Is there a way to set a tooltip Text for the CXTPControlComboBox ListBox ?
Not a LabelTip.
Like this



  Jimmy
Back to Top
Simon HB9DRV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 July 2005
Location: Switzerland
Status: Offline
Points: 458
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon HB9DRV Quote  Post ReplyReply Direct Link To This Post Posted: 02 October 2007 at 1:31pm
Originally posted by jimmy jimmy wrote:

Hello,

Is there a way to set a tooltip Text for the CXTPControlComboBox ListBox ?
Not a LabelTip.
Like this



  Jimmy
 
Now that would be magic! Come on Oleg, we know you can do it :-)
Simon HB9DRV
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 515
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2007 at 6:32am
Hallo,

Found solution

class CExControlComboBoxList : public CXTPControlComboBoxList
{
public:
    void CreateListBox() { __super::CreateListBox(); };

    virtual ~CExControlComboBoxList()
    {
        if (m_pToolTipContext)
            CMDTARGET_RELEASE(m_pToolTipContext);
    }

    void InitTooltip(LPCTSTR lpTitle)
    {
        m_ToolTipContext.ModifyToolTipStyle(TTS_NOPREFIX, 0);
        m_ToolTipContext.ShowImage(FALSE);
        SetTooltipTitle(lpTitle);

        m_pToolTipContext = &m_ToolTipContext;
        CMDTARGET_ADDREF(m_pToolTipContext);
    }
    void SetTooltipTitle(LPCTSTR lpTitle)
    {
        if (lpTitle && *lpTitle)
        {
            m_strTitle = lpTitle;
            m_ToolTipContext.ShowTitleAndDescription(TRUE);
        }
        else
            m_ToolTipContext.ShowTitleAndDescription(FALSE);
    }
    virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const
    {
        int iSel = GetCurSel();
        if (iSel >= 0)
        {
            CString strText;
            GetText(iSel, strText);
            TSSMap::const_iterator itr = m_mapTooltipText.find(strText);
            if (itr != m_mapTooltipText.end())
            {
                CXTPToolTipContext::FillInToolInfo(pTI, m_hWnd, CRect(0,0,200,50), iSel, itr->second, m_strTitle, itr->second, NULL);
                return iSel;
            }
        }
        return -1;
    }
    void AddTooltipText(const CString& strText, const CString& strTooltip)
    {
        m_mapTooltipText[strText] = strTooltip;
    }
    CXTPToolTipContext *GetToolTipContext() {
        return m_pToolTipContext;
    }
protected:
    typedef std::map<CString,CString> TSSMap;
    TSSMap m_mapTooltipText;
    CXTPToolTipContext m_ToolTipContext;
    CString m_strTitle;
};

class CExControlComboBox : public CXTPControlComboBox
{
public:
    CExControlComboBox()
    {
        if (m_pCommandBar)
            m_pCommandBar->InternalRelease();

        m_pCommandBar = new CExControlComboBoxList();
        GetExControlList()->CreateListBox();
    };

    CExControlComboBoxList *GetExControlList()    { return ((CExControlComboBoxList*)m_pCommandBar); }

    CXTPToolTipContext *GetToolTipContext() {
        GetExControlList()->GetToolTipContext();
    }
    void InitTooltip(LPCTSTR lpTitle = NULL) {
        GetExControlList()->InitTooltip(lpTitle);
    }
    void AddString(const CString& strText, const CString& strTooltip)
    {
        GetExControlList()->AddTooltipText(strText, strTooltip);
        __super::AddString(strText);
    }
    DECLARE_XTP_CONTROL(CExControlComboBox)
};

IMPLEMENT_XTP_CONTROL(CExControlComboBox, CXTPControlComboBox)

And in OnCreateControl

            CExControlComboBox* pComboUrl = (CExControlComboBox*)CExControlComboBox::CreateObject();
            pComboUrl->InitTooltip("Title");
            pComboUrl->AddString(_T("http://www.codejock.com"), "Mein Tooltip 1");
            pComboUrl->AddString(_T("ms-help://MS.VSCC/vsccCommon/html/vsccCommon_Start_Page.htm"), "Mein Tooltip 2" );


But some questions.

1) Better solution to store info Tooltiptext / Entry (i don't like use SetItemData)

2) Tooltip only show inside red border and wrong tooltip is show on green line position.



3) Can you add this function to new version ?

4) What can i make better inthis solution ?

    Jimmy

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2007 at 3:32am
Hi,
 
Nice solution.
 
May be only need add
DECLARE_XTP_COMMANDBAR/IMPLEMENT_XTP_COMMANDBAR for List
and instead predefined CRect(0,0,200,50), use
 
CRect rc;
GetListBoxCtrl()->GetItemRect(iSel, rc);
Think also need to add Save/Load tooltips for customization. See DOPropExchange method.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 515
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2007 at 9:28am
1) better solution ?

2) red border ok, but Tooltip does not work correkt on 2 pixel width between
2 entrys (green line).

3) can add to next Codejock version ?

4) Ok

    Jimmy

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.