Custom tooltip for VirtualMode Report |
Post Reply |
Author | |
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
Posted: 01 April 2009 at 10:59pm |
You can use this:
afx_msg void OnReportNeedTooltip(NMHDR * pNotifyStruct, LRESULT * result);
ON_NOTIFY(XTP_NM_REPORT_GETTOOLTIPINFO, XTP_ID_REPORT_CONTROL, OnReportNeedTooltip) void CVirtualListView::OnReportNeedTooltip(NMHDR* pNotifyStruct, LRESULT * /*result*/) { XTP_NM_REPORTTOOLTIPINFO* pItemNotify = (XTP_NM_REPORTTOOLTIPINFO*) pNotifyStruct; if (!pItemNotify->pRow || !pItemNotify->pItem) return; TRACE(_T("\nRow=%d Index=%d\n"), pItemNotify->pRow->GetIndex(), //this is row # pItemNotify->pItem->GetIndex()); //this is column # //e.g. if (pItemNotify->pItem->GetIndex() == 4) pItemNotify->pItem->SetTooltip("AAA"); } |
|
markr
Senior Member Joined: 01 August 2004 Status: Offline Points: 443 |
Post Options
Thanks(0)
|
Mark, there appears to be something wrong with this functionality.
I'm running XTP v13.1.0 (latest public release at time of this writing), and there appears that the tooltips are not painted correctly when moving from one report record to another. To make sure my app was not at fault somehow, I modified CodeJock sample entitled "VirtualList". I added the ON_NOTIFY macro for message XTP_NM_REPORT_GETTOOLTIPINFO, along with the following method: void CVirtualListView::OnReportNeedTooltip(NMHDR* pNotifyStruct, LRESULT * /*result*/) { XTP_NM_REPORTTOOLTIPINFO* pItemNotify = (XTP_NM_REPORTTOOLTIPINFO*) pNotifyStruct; if (!pItemNotify->pRow || !pItemNotify->pItem) return; CString sFormat; sFormat.Format(_T("%d, %d"), pItemNotify->pRow->GetIndex(), //this is row # pItemNotify->pItem->GetIndex()); //this is column # pItemNotify->pItem->SetTooltip(sFormat); } Now compile and run the sample, moving your mouse over various rows and columns. You'll quickly see that the tooltip is not showing the correct row and item index values. What's interesting here is that the values ARE being assigned correctly - the tooltip just doesn't show them correctly for some period of time. In other words, using TRACE shows the *correct* values in the debug output window, but the tooltip still does not paint the correct text! |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
I don't use this function here -
and I can see tolltip for any cells if cell width is not enough
Now I updated it and you can see Custom Tooltip for column 5 items for any width of this column
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
It works with Notification respond but in same logical conditions - small column width - I can see for one given column my text "AAA"
void CVirtualListView::OnReportNeedTooltip(NMHDR* pNotifyStruct, LRESULT * /*result*/) {XTP_NM_REPORTTOOLTIPINFO* pItemNotify = (XTP_NM_REPORTTOOLTIPINFO*) pNotifyStruct; if (!pItemNotify->pRow || !pItemNotify->pItem) return; if (pItemNotify->pItem->GetIndex() == 4)pItemNotify->pItem->SetTooltip( "AAA");TRACE(_T( "\nRow=%d Index=%d\n"), pItemNotify->pRow->GetIndex(), pItemNotify->pItem->GetIndex());} So we need to force show tooltip if app pass it without checking cell width for external (notification-based) text passed? Btw - in Calendar control I have special flag to force show tooltip |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Confirmed - It work for any cases after I add flag CXTPReportPaintManager::m_bForceShowTooltip (default = FALSE)
same for OCX as PaintManager.ForceShowTooltip = True
Thanks for catch
You can get fresh source https://forum.codejock.com/uploads/DemoVersion/ReportControlMFCUpdated.rar and rebuild your app
or get fresh beta-ocx https://forum.codejock.com/uploads/BetaOCX/ReportControlBeta13-2.rar and use same effect in VB test app
|
|
markr
Senior Member Joined: 01 August 2004 Status: Offline Points: 443 |
Post Options
Thanks(0)
|
> Thanks for catch
And thank you for getting the problem resolved so quickly. You folks provide the best support in the business. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
New feature in VirtualMode - multiline items - see updated sample - https://forum.codejock.com/uploads/DemoVersion/EditVirtualListIconStatic.rar
|
|
markr
Senior Member Joined: 01 August 2004 Status: Offline Points: 443 |
Post Options
Thanks(0)
|
Mark, this still doesn't appear to be working as expected in the v13.2 beta.
I'm setting GetReportControl().GetPaintManager()->m_bForceShowTooltip = TRUE; ... but the tooltip still exhibits the problem behavior I described in my previous post. Maybe your changes haven't yet made it into the v13.2 beta? |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
No, they did. There is a problem with tooltip cache - sometimes it show old tooltip string if you move mouse too fast. Need to move mouse in the point where there is no tooltip and move back to proper item - now it will works.
I also have same problem in some NON VIRTUAL MODE project where statusbar always show proper text but tooltip show old value:
((CFrameWnd*) AfxGetMainWnd())->SetMessageText(s); --- WORKS ALWAYS SetTooltip(s); --- NOT ALWAYS! so this tooltip problem is not related to virtual mode!
Btw - m_bForceShowTooltip flag have another purpose - show tooltip in the case item text is fit in the item rectangle and usual criteria to show tooltip prevent it. But I checked again my virtual mode case:
void CVirtualListView::OnReportNeedTooltip(NMHDR* pNotifyStruct, LRESULT * /*result*/) {XTP_NM_REPORTTOOLTIPINFO* pItemNotify = (XTP_NM_REPORTTOOLTIPINFO*) pNotifyStruct; if (!pItemNotify->pRow || !pItemNotify->pItem) return;CString s; s.Format(_T( "Custom Tooltip text %d"), rand() % 100); if (GetReportCtrl().IsIconView()) { if (pItemNotify->pItem->GetIndex() == GetReportCtrl().m_iIconViewColumn)pItemNotify->pItem->SetTooltip(s); } else { if (pItemNotify->pItem->GetIndex() == 4)pItemNotify->pItem->SetTooltip(s); } } and it works well - no missing or wrong tooltip strings |
|
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 |