statusbar
-
Hi, I have a statusbar with text. What I'm trying to do is make the text appear in the form of a tooltip whever text is too large to fit into the length of the statusbar panel. How can I accomplish that? Thank you in advance.
-
Hi, I have a statusbar with text. What I'm trying to do is make the text appear in the form of a tooltip whever text is too large to fit into the length of the statusbar panel. How can I accomplish that? Thank you in advance.
-
Where do you want to display the ToolTip? Do you need the ToolTip on the mouse hover event of the statusbar panel?
Yes, just a basic tooltip unless there is a better way of displaying the text that is not completely visible in the statusbar.
-
Yes, just a basic tooltip unless there is a better way of displaying the text that is not completely visible in the statusbar.
-
All you need is drag drop a ToolTip object from the toolbox. this.toolTip1.SetToolTip(this.StatusBarPanel1, "hello");
That's the easy part, well, actually statusbar panel has it's own tooltip. What I'm trying to figure out is how to know when to activate the tooltip, in other words, when the text is not completely visible. Thanx
-
That's the easy part, well, actually statusbar panel has it's own tooltip. What I'm trying to figure out is how to know when to activate the tooltip, in other words, when the text is not completely visible. Thanx
SendMessage SB_GETRECT on StatusBarPanel will give you the width of the SattusBar. private const int WM_USER = 0x0400; private const int SB_GETRECT = WM_USER + 10; [StructLayout(LayoutKind.Sequential)] public struct Rect { public int left; public int top; public int right; public int bottom; } RECT Rectangle; SendMessage(this.StatusBar1.Handle.ToInt32, SB_GETRECT, Panel, Rectangle) Graphics.MeasureString() will compute the pixel length. Compare the lengths and if the text is clipped display the ToolTip.
-
SendMessage SB_GETRECT on StatusBarPanel will give you the width of the SattusBar. private const int WM_USER = 0x0400; private const int SB_GETRECT = WM_USER + 10; [StructLayout(LayoutKind.Sequential)] public struct Rect { public int left; public int top; public int right; public int bottom; } RECT Rectangle; SendMessage(this.StatusBar1.Handle.ToInt32, SB_GETRECT, Panel, Rectangle) Graphics.MeasureString() will compute the pixel length. Compare the lengths and if the text is clipped display the ToolTip.
"...Graphics.MeasureString() will compute the pixel length..." Does it mean that I have to take over the drawing of the statusbar and catch a painting event in order to use this? Thanx for all the help.
-
"...Graphics.MeasureString() will compute the pixel length..." Does it mean that I have to take over the drawing of the statusbar and catch a painting event in order to use this? Thanx for all the help.
-
Thanx for your time. I was looking for something like 'DrawMode' in order to take over the painting, but nothing like this exists for this control. How and what event am I looking for to catch? Thank you
-
Thanx for your time. I was looking for something like 'DrawMode' in order to take over the painting, but nothing like this exists for this control. How and what event am I looking for to catch? Thank you
-
In the StatusBarPanel you can this.Parent.DrawItem += new StatusBarDrawItemEventHandler(Parent_DrawItem); private void Parent_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent) { //Do the measure String } Anyway I will also make a demo app.
Here is a part of my code. I'm using e.Panel.Width to get the width of the panel. Is there a difference between this and what you suggested? ...this.statusBar1.Panels[0].Style = StatusBarPanelStyle.OwnerDraw; this.statusBar1.DrawItem += new StatusBarDrawItemEventHandler(Parent_DrawItem); ... private void Parent_DrawItem(object sender, StatusBarDrawItemEventArgs e) { SizeF stringSize = e.Graphics.MeasureString(e.Panel.Text, e.Font); ... From here on I'm using stringSize.Width and e.Panel.Width, but when visually panel ends where the text ends their actual widths are very different, eventhough visually they are the same. Why such difference? Thank you for all the help