|
|
Comments and Discussions
|
|
 |

|
Thank you for sharing. Useful stuff.
|
|
|
|

|
I have successfully deployed your code using VS 2010 (Win 7/64-bit) to create a CRichEditView SDI interface that put's me well on the road to building an 'Intellisense' like interface. I have two questions:
1 - is there some way to stop the flickering (see previous posts on this problem) ?
2 - would it be possible to insert a control, say a combo box, as well as a tooltip message ?
According to the P. Vickery, this code gets the minimium size for a rich edit control, and is
taken from http://www.codeproject.com/richedit/richeditsize.asp. That author states:
"Do note that, in the TCX Message Box class, I do all this calculation and resizing
before I actually display the window. Otherwise, it will flick crazily as the
application traverses the binary search loop. Therefore, if you need to recalculate
the Rich Edit Control size when it's already visible, you must first freeze the
parent window redraw, or you should move the Rich Edit Control to outside of the
visible area, do all the calculation and, when it's done, you get it back to the
visible area."
Further down a posting in the above article states:
If you set the ES_AUTOHSCROLL style on the rich edit control, the rect returned
in EN_REQUESTRESIZE will contain the actual rect needed to contain all of the text
without any wrapping.
I tried this but can't get it to work. Has anyone else tried this?
Thanks for sharing this great work. I defy anyone to find another publicly available C++ source code that shows how to create tooltips in a CRichEditView. Believe me, I have spent alot of time looking.
|
|
|
|

|
Hi again !
The tooltip in your demo can't display more than one image, only the first occurence is displayed. Whatever its location in the text, whatever image it is. Also some images didn't work when displayed in the tooltip but work fine in the rich edit. Your class _RichToolTipCtrlCookie is buggy.
I fixed it, I found on Painless streaming of rich text to/from CRichEditCtrl[^] a much simple example than the _RichToolTipCtrlCookie class you used. I deleted all this code and simply replaced it by :
DWORD __stdcall StreamInCallback(DWORD_COOKIE dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
if(cb > (((CString*)dwCookie)->GetLength())) cb = ((CString*)dwCookie)->GetLength();
memcpy(pbBuff,*(CString*)dwCookie,cb);
*pcb = cb;
((CString*)dwCookie)->Delete(0,cb); return 0;
}
int CRichToolTipCtrl::CRichToolTipRichEditCtrl::StreamTextIn(LPCTSTR lpszText)
{
CString text ( lpszText );
EDITSTREAM es;
es.dwCookie = (DWORD_COOKIE)&text;
es.pfnCallback = StreamInCallback;
return StreamIn(SF_RTF, es);
}
And now it works like a charm.
Despite this, thank you for your control, I really like it.
modified on Thursday, November 19, 2009 10:34 AM
|
|
|
|

|
Hi !
I'm reporting a bug. In the file RichToolTipCtrlDemoDlg.cpp, function RichTextCtrlCallbackOut, the line
strncpy_s(lpszBuf, cb, (LPCSTR)pbBuff, cb);
..should be replaced by..
strncpy_s(lpszBuf, cb+1, (LPCSTR)pbBuff, cb);
Cheers
|
|
|
|

|
Nice project. Thanks for providing it.
I was trying out different files to replace the supplied Test.rtf, to see what would happen. They happen to have more lines than will fit in the multiline RichEdit field (which may or may not be a factor).
Here are links to two files I used that had problems:
www.berbible.org/misc/Rtf17_Highlight_sa_Super.rtf
www.berbible.org/misc/Ps119.rtf
I changed the following lines:
BOOL CRichToolTipCtrlDemoDlg::OnInitDialog()
{
....
CFile file;
TCHAR* pszFilename = _T("Test.rtf");
pszFilename = _T("Rtf17_Highlight_sa_Super.rtf");
pszFilename = _T("Ps119.rtf");
if (file.Open(pszFilename, CFile::modeRead | CFile::shareDenyNone)) {
When I hover over the multiline RichEdit field that has been pre-filled with the contents of Rtf_Highlight_sa_Super.rtf, it works ok the first time (and sometimes the second time). Subsequent hovers cause the tooltip to be displayed twice. It shows the contents once briefly, flashes, and then re-displays.
With the long Ps119.rtf, it redisplays continuously and never "settles down".
|
|
|
|

|
I've looked into this behaviour, and found that this is a problem in any multi-line tool-tip whose window overlaps the cursor position (i.e. not just in my control). You can fix it in my control by adding some code into the OnShow method: rc.bottom = rc.top + (size.cy);
CPoint pt;
GetCursorPos(&pt);
if (rc.PtInRect(pt))
rc.MoveToX(pt.x == rc.left ? pt.x + 1 : pt.x - (rc.Width() + 1));
MoveWindow(&rc);
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|

|
Thanks, but I'm still experiencing problems.
Both test files still "flash" once, but the Ps119.rtf is better behaved in that it doesn't flash repeatedly.
I'm using WinXp-Sp3, if that makes a difference.
Here's a link to a release-build .exe:
www.berbible.org/misc/RichToolTipCtrlDemoVC71.exe
|
|
|
|

|
Mr. Vickery,
first off: nice work, thank you.
We had some issues with a multi-monitor setup when the secondary monitor was on the right of the primary one. The tooltips worked fine on the main monitor or when the secondary monitor was on the left of the main monitor, but when it was on the right, tooltips on this secondary monitor would appear at the very left of the screen.
I took the liberty of changing a few lines in CRichToolTipCtrl::OnShow from
if ((size.cx + rc.left) > rcDesktop.Width())
rc.left = max(rcDesktop.left, rc.left - ((rc.left + size.cx) - rcDesktop.Width()));
if ((size.cy + rc.top) > rcDesktop.Height())
to
if ( (size.cx + rc.left) >= rcDesktop.right )
rc.left = std::max( rcDesktop.left, rcDesktop.right - size.cx );
if ((size.cy + rc.top) >= rcDesktop.bottom )
rc.top = std::max( rcDesktop.top, (ptCursor.y - 16) - size.cy);
Again, thank you for your work ( and, YAY! ZX Spectrum! )
Cheers,
Christian
|
|
|
|

|
I am using it well, tnx.
but on win2k i can not get the tooltip text but only ???????????????
why?
any ideas?
Ariel
|
|
|
|

|
Is this in your own program, or the demo? Also, are you building with UNICODE defined? Is it only on Win2K that you see the problem text?
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|

|
I'm using RichToolTipCtrl for a CComboBox. It is working fine for CButtons and CEdit controls, but I must be incorrectly implementing it for the combo box. Here is the way I am doing it:
In InitDialog:
m_tip.Create();
m_tip.AddTool(GetDlgItem(IDC_COMBO_TRANS_X_TYPE), " ");
Then I override UpdateDate() and add the following:
*******************************************************************
CWnd* editXRate = this->GetDlgItem(IDC_COMBO_TRANS_X_TYPE);
CString strXrate = "";
if (editXRate)
editXRate->GetWindowText(strXrate);
m_tip.UpdateTipText(strXrate, GetDlgItem(IDC_COMBO_TRANS_X_TYPE));
*******************************************************************
This is exactly the way I coded for the CEdit contorls on the dialog, and it works fine for them, but no tooltips show up for the CComboBox.
Anyone have any ideas where I'm going wrong?
Thank you in advance for any help with this.
Bill Holman
Bill Holman
Sr. Systems Programmer
bholman@bholman.com
|
|
|
|

|
You are not doing anything wrong. Unfortunately this is due to the make up of combo box controls. If the combo box is set to the drop-list style, then you should find that the tool-tip works correctly, but if the combo uses the drop-down style, then the edit control will not show the tool-tip, as the edit control is a completely separate control.
To get tool-tips to work, you will need to get the handle of the edit control, and set the tool on that control as well as the combo itself.
If targetting Win98 or later, then there is an easy means of getting the edit control's handle, by using CComboBox::GetComboBoxInfo(). There are several articles on CodeProject which include methods of doing this. If you target earlier platforms and don't want to use this call, you can catch the edit control in a WM_CTLCOLOR handler. See my ComboBoxCS article[^] for where I have code which uses GetComboBoxInfo to get the list box, and falls back on the WM_CTLCOLOR method on earlier platforms.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|

|
Paul,
Thank you very much for your timely and informative response. I will give it a try.
Bill
Bill Holman
Sr. Developer
Visionael
Bill Holman
Sr. Systems Programmer
bholman@bholman.com
|
|
|
|

|
Hi Paul,
there is another problem:
If I call UpdateTipText when the tooltip is visible, the tolltip flickers significant (even with the same rtf string).
I think you calculate the size several times, and this causes a number of repaintings.
Do you have any idea, how to bypass this problem?
cu
Heinz
|
|
|
|

|
i have the same problem. If the tooltip to be displayed is bigger than what can fit on the screen, the tooltip box will continually refresh itself (flicker). Any suugestions appreciated. Thanks.
|
|
|
|

|
I've got the same problem, did you have found a solution ?
In my case, I must show a tooltip for the dialog (this pointer) and for a certain position in the client area of my window, show the appropriated tooltip.
I do this in the WML_MLOUSEMOVE message like this :
BOOL CMyTestDlg::OnInitDialog()
{
...
m_tip.Create(this);
CRect rectTool;
GetClientRect(&rectTool);
m_tip.AddTool(this, "", &rectTool, 9999);
...
}
void CMyTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CDialog::OnMouseMove(nFlags, point);
m_tip.UpdateText( _T("{\\rtf {\\bMy dialog box}}") , this , 9999 );
m_tip.Update();
}
P.S. : Works fine when I use CToolTipCtrl !
|
|
|
|

|
HI Paul,
first, I think you did a good job. Your demo works fine.
I tried to replace CToolTipCtrl in my application - and it doesn't work as desired. I create the tooltip control with the folloing lines:
if(!m_cToolTip.Create(this))
TRACE(_T("Unable to Create ToolTip"));
else
if (!m_cToolTip.AddTool(this, "Info"))
TRACE(_T("Unable to add tip for the control window"));
else
{
m_cToolTip.Activate(TRUE);
m_cToolTip.SetMaxTipWidth(800);
m_cToolTip.SetDelayTime(TTDT_AUTOPOP, 32000);
m_cToolTip.SetDelayTime(TTDT_INITIAL, 350);
m_cToolTip.SetDelayTime(TTDT_RESHOW, 350);
}
Later I change the tiptext with:
m_cToolTip.UpdateTipText(sTooltip, this);
If I set sTooltip to a richtext string like
sTooltip.Format(_T("{{The tool's window text is \'{\\b{BOLD}}\'}}"));
I always see the unformatted text with all backslashes and the other garbage.
Thx in advance
Heinz
|
|
|
|

|
I've tried using UpdateTipText, and it works OK for me (I'm on XP). If it is a problem, then I would like to fix it. Perhaps you could email me a small project which demonstrates the problem?
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|

|
I found my mistake - I wanted a tooltip for my dialog window an in such cases I have to fill all 4 parameters of the AddTool function. Now it works.
cu
Heinz
|
|
|
|
|

|
Mmm. You're right. It appears that EN_REQUESTRESIZE doesn't return the correct results. I'll look into it and try and come up with a solution.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|

|
To fix the size problem, the RichEdit control needs to be created as visible on Windows 98 for the EN_REQUESTRESIZE to work properly. To fix the tip control just change the line: m_edit.Create(WS_CHILD | ES_MULTILINE | ES_READONLY, CRect(0, 0, 0, 0), this, 1);
to: m_edit.Create(WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_READONLY, CRect(0, 0, 0, 0), this, 1);
Unfortunately the formatting seems to get a bit messy on Win98, so I'll have a look at tweaking that to look better, and post the results here.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|

|
The reason the formatting looks wrong is because the rich-edit control is visible over the tool-tip. The correct fix to the problem is to show the control before doing the RequestResize(), and then hide it again once it's resized. So, in CRichToolTipCtrl::CalculateMinimiumRichEditSize(), insert: m_edit.ShowWindow(SW_SHOW); just before the 'do' loop, and insert m_edit.ShowWindow(SW_HIDE); just before the call to MoveWindow().
I'll try to post an update in the next few days.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|

|
with NT there are the same probs. The fix helps her too.
Thanx!
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A tool-tip control with support for rich-text formatting
| Type | Article |
| Licence | CPOL |
| First Posted | 13 Mar 2005 |
| Views | 81,475 |
| Downloads | 3,487 |
| Bookmarked | 82 times |
|
|