Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - [solved] v17(final) - BUG Text clipped in Tooltips
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] v17(final) - BUG Text clipped in Tooltips

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


Joined: 16 January 2004
Location: Germany
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote Marco1 Quote  Post ReplyReply Direct Link To This Post Topic: [solved] v17(final) - BUG Text clipped in Tooltips
    Posted: 13 January 2016 at 11:26am
Same with ribbon tooltips (tested with Office2007 and Office2010 themes).
Too much space on the right side, cut off at the bottom.

Have a look:

Back to Top
JamesP View Drop Down
Groupie
Groupie
Avatar

Joined: 07 January 2009
Location: United Kingdom
Status: Offline
Points: 73
Post Options Post Options   Thanks (1) Thanks(1)   Quote JamesP Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2016 at 7:39am
In cases where the variable m_nMaxTipWidth is set using the function SetMaxTipWidth and an image is provided, the tooltip text can be quite badly clipped.

The size of the required rect is calculated in the CXTPToolTipContextToolTip::GetToolSize function. This function is giving results bigger than the m_nMaxTipWidth value.

In this function there is a line of code:

CRect rcText(0, 0, nMaxTipWidth - szMargin.cx, 0);

I suspect it should take into account the image size, making it something like:

CRect rcText(szImage.cx, 0, nMaxTipWidth - szMargin.cx, 0);


In order to avoid clipping the text, the first line of code in the CXTPToolTipContextToolTip::DrawEntry function:

rc.right = GetMaxTipWidth();

needs to be removed.

This line was added in 17.1 and wasn't present in the v17 Beta 3 that we have previously been using.
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 25 February 2016 at 5:49pm
Are you running on a hi-res monitor? We are seeing clipping when running on one with the desktop DPI set to 200%.
Back to Top
JamesP View Drop Down
Groupie
Groupie
Avatar

Joined: 07 January 2009
Location: United Kingdom
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote JamesP Quote  Post ReplyReply Direct Link To This Post Posted: 29 February 2016 at 6:52am
I am running on a high res monitor with the desktop dpi set to 200%. I was also getting the issue when running at 100%.

I think a large part of the problem could be down to the fact that we're providing extra large images to support high dpi and the tooltips always use the largest image they can find.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 07 April 2016 at 10:44am
Hi all,

I found resolution for this issue.

For 125% and 150% DPI "XTP_DPI_X(nA) + XTP_DPI_X(nB)" always bigger for 1 than "XTP_DPI_X(nA + nB)". That is why difference in calculations between CXTPToolTipContextToolTip::GetToolSize and CXTPToolTipContextToolTip::DrawEntry.

Also "rc.right = GetMaxTipWidth();" in CXTPToolTipContextToolTip::DrawEntry() makes incorrect tooltips drawing even on 100% and 200% DPI. Thanks James!

Please check this solution. I have tested it with RibbonSample (Office2007 theme)  in 100-125-200% DPI.

CSize CXTPToolTipContextToolTip::GetToolSize(TOOLITEM* lpToolInfo)
{
CClientDC dc(this);

CFont* pOldFont = dc.SelectObject(&m_pContext->m_fnt);

CString str = GetToolText(lpToolInfo);

if (str.IsEmpty())
{
dc.SelectObject(pOldFont);
return CSize(0);
}

int nMaxTipWidth = GetMaxTipWidth();

CRect rcMargin = m_pContext->GetMargin();
CSize szMargin(XTP_DPI_X(3) + rcMargin.left + rcMargin.right + XTP_DPI_X(3),
XTP_DPI_Y(3) + rcMargin.top + rcMargin.bottom + XTP_DPI_Y(3));

DWORD dwFlags = DT_NOPREFIX | DT_EXPANDTABS;

BOOL bDrawImage = m_pIcon != NULL;
BOOL bDrawTitle = !m_strTitle.IsEmpty();
BOOL bDrawImageTop = TRUE;
CSize szImage(0, 0);
CSize szTitle(0, 0);

if (bDrawTitle)
{
CXTPFontDC fntTitle(&dc, &m_pContext->m_fntTitle);

CRect rcTitle(0, 0, 0, 0);
dc.DrawText(m_strTitle, rcTitle, dwFlags | DT_CALCRECT | DT_SINGLELINE);

szTitle = CSize(rcTitle.Width() + XTP_DPI_X(4), rcTitle.Height() + XTP_DPI_Y(10) + XTP_DPI_Y(10));
}

if (bDrawImage)
{
CSize szIcon(XTP_DPI_X(m_pIcon->GetWidth()), XTP_DPI_Y(m_pIcon->GetHeight()));
bDrawImageTop = (szIcon.cy <= XTP_DPI_Y(16));

if (bDrawImageTop)
{
if (!bDrawTitle)
{
szImage.cx = szIcon.cx + XTP_DPI_X(3);
}
else
{
szTitle.cx += szIcon.cx + XTP_DPI_X(1);
}
}
else
{
szImage.cx = szIcon.cx + XTP_DPI_X(5);
}
szImage.cy = szIcon.cy;
}

CRect rcText(0, 0, nMaxTipWidth - szMargin.cx, 0);

if (bDrawTitle)
rcText.right = max(szTitle.cx, nMaxTipWidth - szMargin.cx) - (XTP_DPI_X(10) + XTP_DPI_X(15));

dc.DrawText(str, rcText, dwFlags | DT_CALCRECT | DT_WORDBREAK);
dc.SelectObject(pOldFont);

CSize sz(0, 0);
sz.cy = max(szImage.cy, rcText.Height());
sz.cx = szImage.cx + rcText.Width();

if (bDrawTitle)
{
sz.cx = max(sz.cx + XTP_DPI_X(10) + XTP_DPI_X(15), szTitle.cx);
sz.cy += szTitle.cy;
}

sz += szMargin;

return sz;
}


Regards,
 Oleksandr Lebed
Back to Top
scottp View Drop Down
Groupie
Groupie


Joined: 16 October 2006
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote scottp Quote  Post ReplyReply Direct Link To This Post Posted: 08 April 2016 at 1:10am
when will we see 17.2 released (or a beta) to try this and other recent bug fixes?
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 08 April 2016 at 5:38am

Scott, I don't sure that this fix will be available in 17.2. This and other recent fixes need to testing.

New version is preparing for release now. 

Note  I splited "clipped tooltips" and "clipped markup" to different forum topics.

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.