rbulph Posted November 22, 2006 Posted November 22, 2006 How to get the height of a tooltip control? Quote
headkaze Posted November 24, 2006 Posted November 24, 2006 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. 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(); } Quote
rbulph Posted November 25, 2006 Author Posted November 25, 2006 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. Quote
Leaders snarfblam Posted November 26, 2006 Leaders Posted November 26, 2006 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? Quote [sIGPIC]e[/sIGPIC]
rbulph Posted November 26, 2006 Author Posted November 26, 2006 You can get the font used for ToolTip. It might be in the SystemInformation class. If not' date=' 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?[/quote'] 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. Quote
Leaders snarfblam Posted November 27, 2006 Leaders Posted November 27, 2006 Would it be unacceptable to display the hint below the text? Quote [sIGPIC]e[/sIGPIC]
rbulph Posted November 27, 2006 Author Posted November 27, 2006 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.