Tooltip

rbulph said:
How to get the height of a tooltip control?

You may be able to modify the following code to measure the height of a tooltip.

C#:
public static void AutoSizeLabelHeight(Label ctlLabel)
{
	Graphics g = ctlLabel.CreateGraphics();
	Font font = new Font(ctlLabel.Font.Name, ctlLabel.Font.Size, ctlLabel.Font.Style);

	StringFormat sf = new StringFormat();

	SizeF stringSize = g.MeasureString(ctlLabel.Text, font, ctlLabel.Width, sf);

	ctlLabel.Height = (int) stringSize.Height + 2;

	g.Dispose();
	font.Dispose();
	sf.Dispose();
}
 
Not really, since the tooltip doesn't have a font. I suppose I can just create a label and assume it has the same font as a tooltip, but it's a bit of an assumption.
 
You can get the font used for ToolTip. It might be in the SystemInformation class. If not, it should be get-able from the Windows API. That is still an iffy way to find a ToolTip size. Why, if you don't mind my asking, are you looking to find the size of a ToolTip?
 
marble_eater said:
You can get the font used for ToolTip. It might be in the SystemInformation class. If not, it should be get-able from the Windows API. That is still an iffy way to find a ToolTip size. Why, if you don't mind my asking, are you looking to find the size of a ToolTip?
Can't find it in the SystemInformation class. I want it because I'm using it as an autotext hint (like in Word) and want to be able to position it properly above the point where the user is typing. I think just using the value that I find on my system should be OK, though.
 
marble_eater said:
Would it be unacceptable to display the hint below the text?

Yes is the short answer. I'd rather that it was unreliably positioned above, than accurately positioned below.
 
Back
Top