mfc >> Multiline tooltips

by Steve » Thu, 30 Oct 2003 05:48:10 GMT

I'm handling TTN_NEEDTEXTx messages in my CMainFrame class and copying a
string to the szText member of the TOOLTIPTEXTx structure depending on the
resource id of the control. I'm doing this because the state for each
control id can change and I want the tooltip to reflect the current state of
the control. Okay, that all works fine, but how do I implement a multi-line
height tooltip? I've tried using \r\n and just \n but the tooltips still
are single line with a little box character in place of the carriage return
or line feed. Anyone know how to do multi-line tooltips and if so, will
this work on all Win platforms? I'm using Win2K and VS.NET 2003.

Thanks




mfc >> Multiline tooltips

by Jeff Partch » Thu, 30 Oct 2003 06:10:01 GMT





of
multi-line
return

No promises, but according to the docs it looks as if you need to
SendMessage it a TTM_SETMAXTIPWIDTH. It should work with all platforms for
which version 4.70 and later of the common controls are installed.
--
Jeff Partch [VC++ MVP]





mfc >> Multiline tooltips

by Steve » Thu, 30 Oct 2003 09:14:18 GMT

Yep, I missed that initially but just tried it and it works as
advertised.... My tooltips are happy happy happy!





the
state
still




Multiline tooltips

by Joe Estock » Sun, 30 Nov 2003 02:52:07 GMT




Yes it is. I am not sure as the version specifics, however Baloon tooltips
can accomplish this (and iirc so can normal tooltips). Check the MSDN
documentation on the CreateToolTipEx function (this may or may not be the
correct function, but it is sure to find you the correct one).




Multiline tooltips

by Jeff Partch [MVP] » Sun, 30 Nov 2003 04:57:04 GMT





Please see the "Multiline Tooltips" sub-topic at this URL...

http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/tooltip/usingtooltips.asp

--
Jeff Partch [VC++ MVP]




Multiline tooltips

by behzad Nazari » Sun, 30 Nov 2003 12:45:58 GMT

hi,
Is it possible to have multiline tooltips ?

thanks,
Behzad




Multiline tooltips

by behzad Nazari » Sun, 30 Nov 2003 15:04:40 GMT

thanks for your reply,

but I could not find that function in MSDN, There was no
CreateTooltipEx











Similar Threads

1. MultiLine ToolTips in designer- An Answer

VS2003

1) If you don't have one, add a tooltip control to your design canvas.
2) open the properties for the control that gets the tool tip
3) type in all your text in the 'tooltip on tooltip1' property. 
   The line feeds come later. The property editor has no way to enter 
   a \n. It doesn't parse and it doesn't accept control characters 
   escaped or not.
4) Switch from the design view to the form code.
   e.g. 'MainFrm.cs' instead of 'MainFrm.cs[Design]'
5) Find the code that creates the control. It will be in the
   InitializeComponent() method that you are NOT supposed to edit.
   (More about that later)
6) Change the code for the tooltip from:
	this.toolTip1.SetToolTip(this.someControl, "Line1Line2");
   to:
	this.toolTip1.SetToolTip(this.someControl, "Line1\nLine2");
7) Build and run. When the cursor floats over the control, you'll have 2 lines.
   Do NOT look at the design page or examine properties.
8) Exit the solution (close it or save it, or open another, or exit VS)
9) Reopen the solution. Examine the properties for the control.
   Tooltip on Tooltip 1 will say: "Line1[]Line2", AND
   the linefeed will *stay* until you remove it, even if you edit/change 
   the design or properties.
  
   Not only that, but the non-printable character '[]' that represents the line 
   feed in the tool tip text will copy and paste.

Explanation:

The InitializeComponent method is in a reserved region like this:
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>

		....

		#endregion

Whenever you are on the design page making changes, that region is 
'empty'. Anytime you look at the page that has the code, or compile the 
form, the design page generates code representing the current state 
of the design and stuffs it in the region.

When and how are not material. The point is that the region is volatile
and will be re-written anytime the design view wants to (changes).

Now, I'm guessing, but it seems that when put away, the *code* is the
persistent backing for the design view of the form. So when you put
away the solution, and reload it, the design view is recreated from 
the code. As a result, the tooltip on tooltip 1 text property now
has an embedded line feed character. The trick here, is that by changing
the 'region code' you have changed the persistent image of the form
without the knowledge of the design view. 

This is a dirty trick, and I don't know how long it will last, but
it sure beats a stick in the eye. In the meantime, I have a copy/
pastable linefeed character that I can use in any of the properties that 
accept text.

regards

bullshark

2. Displaying MultiLine tooltips in CListCtrl anyone?

3. Linecount in multiline textbox

Hi,

In case of an error in an input file, I inform the user which line in the 
file (i.e. the string) were the file were encountered. 

The user will then need to navigate to this line in the somewhat long text 
file shown in a textbos (no word wrap). However he needs to count line 
himself!!.

I would like a lable outside the textbox to show the line number on which 
the caret is placed.

What event do I need to hook up on if I want to be notified when the caret 
has changed, and how do I get the position (then I can count lines to this 
pos) of the caret in the string that the textbox shows?

Thanx for your help. Very appreciated.
Jesper.


4. DrawString, multiline string but full width - CSharp/C#

5. ListBox entry with \n (multiline)

Hi everyody,

I want to diplay strings of some objects in a LixtBox.
Sometimes the text is longer than my ListBox and a horizontal scrollbar 
is displayed.

Is it possible to get the ListBox to display the Text in multiple lines 
(per entry)?

I found some controls on CodeProject but they are to overloaded. I just 
want to diplay the Text without scrolling (that every word of the stings 
is visible on the first sight).

Greetings
Stefan

6. Multiline TreeNode - CSharp/C#

7. DrawString, multiline string but full width

On Apr 26, 3:29爌m, "Peter Duniho" < XXXX@XXXXX.COM >
wrote:
> On Fri, 25 Apr 2008 21:51:04 -0700, Sin Jeong-hun < XXXX@XXXXX.COM > ?
> wrote:
>
> > It seems like the default behavior of DrawString is trying to keep the
> > whole word if possible. I'd like the string to be drawn in multilines,
> > but filling the entire line width.
> > [...]
> > Is what I'm trying to do achievable with any formatting options or do
> > I have to draw each character manually with my own calculation?
>
> Off the top of my head, I think maybe you want to set the ?
> StringFormat.Trimming property to Character.
>
> If I'm mistaken about that, you may be able to use the TextRenderer class ?
> instead to do your drawing, using the TextFormatFlags.WordBreak flag (or ?
> rather, making sure that flag is _not_ set) to have the text wrapped on ?
> whatever character reaches the very end of the line.
>
> Sorry I'm being so vague...I don't have something right in front of me ?
> that would let me test the code to make sure my recollection is right.
>
> Pete

Thank you for your reply. But, DrawString() with Trimming property set
to Character didn't work. It was the same as when I didn't even set
the Trimming property. Secondly, TextRender.DrawText draws multiline
text if and only if the TextFormatFlag has WordBreak. Setting
WorkBreak gave the same result as when I used DrawString().

8. tooltip - multiline not working - CSharp/C#