![]() |
CXTPControlComboBox and ListBox Tooltip |
Post Reply ![]() |
Author | |
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() 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 |
|
![]() |
|
Simon HB9DRV ![]() Senior Member ![]() ![]() Joined: 07 July 2005 Location: Switzerland Status: Offline Points: 458 |
![]() ![]() ![]() ![]() ![]() |
Now that would be magic! Come on Oleg, we know you can do it :-)
|
|
Simon HB9DRV
|
|
![]() |
|
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |