Using CMFCPropertyGridCtrl,
How to avoid tips when the mouse moves to the edit box with too long content?
Using CMFCPropertyGridCtrl,
How to avoid tips when the mouse moves to the edit box with too long content?
Have you looked at using:
CMFCPropertyGridCtrl::AlwaysShowUserToolTip
It accepts a BOOL parameter.
I had a look at the source code for the property grid and I noticed the following:
void CMFCPropertyGridCtrl::Init()
{
CRect rectDummy;
rectDummy.SetRectEmpty();
if (GetGlobalData()->m_hcurStretch == NULL)
{
GetGlobalData()->m_hcurStretch = AfxGetApp()->LoadCursor(AFX_IDC_HSPLITBAR);
}
if (GetGlobalData()->m_hcurStretchVert == NULL)
{
GetGlobalData()->m_hcurStretchVert = AfxGetApp()->LoadCursor(AFX_IDC_VSPLITBAR);
}
InitHeader();
HDITEM hdItem;
hdItem.mask = HDI_TEXT | HDI_FORMAT;
hdItem.fmt = HDF_LEFT;
hdItem.pszText = _T("Property");
hdItem.cchTextMax = 100;
GetHeaderCtrl().InsertItem(0, &hdItem);
hdItem.pszText = _T("Value");
hdItem.cchTextMax = 100;
GetHeaderCtrl().InsertItem(1, &hdItem);
m_wndScrollVert.Create(WS_CHILD | WS_VISIBLE | SBS_VERT, rectDummy, this, AFX_ID_SCROLL_VERT);
m_ToolTip.Create(this, TTS_ALWAYSTIP);
m_ToolTip.Activate(TRUE);
if (GetGlobalData()->m_nMaxToolTipWidth != -1)
{
m_ToolTip.SetMaxTipWidth(GetGlobalData()->m_nMaxToolTipWidth);
}
m_ToolTip.SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE);
m_IPToolTip.Create(this);
CWnd* pWndParent = GetParent();
m_bControlBarColors = pWndParent == NULL || !pWndParent->IsKindOf(RUNTIME_CLASS(CDialog));
AdjustLayout();
CreateBoldFont();
CalcEditMargin();
}
I don't have access to the header file so I do not know if the m_ToolTip variable is public. Interestingly, when you read about the CMFCPropertyGridToolTipCtrl class it does state:
MFC automatically creates this control and uses it in the
CMFCPropertyGridCtrlClass.
If the tooltip object is not exposed, then maybe you can create your own property grid class that derives from the base class and you then may have the ability to either expose the m_ToolTip control or deactivate it, or do whatever it is you want to do.
I also see references in the code of the CMFCPropertyGridProperty class to:
m_pWndList->m_ToolTip.AddTool(m_pWndList, LPSTR_TEXTCALLBACK, rectName, m_pWndList->m_nTooltipsCount + 1);
m_pWndList->m_nTooltipsCount ++;
It might be worth examining the MFC code to see where and how the tooltips are used and then you will be better able to override their behaviour in your derived class(es).
MFC Code path on my PC:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\atlmfc\src\mfc
You would use this class to define your grid control and now you can add a public method:
void CMyPropertyGrid::DeactivateToolTips()
{
m_ToolTip.Activate(FALSE);
}
In theory, if you call this DeactivateToolTips method at the right time it should disable the tips. Keep in mind that the tool tip control handles the tips for many elements so the final solution might not be this simple but it should get you going in the right direction.