Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. statusbar

statusbar

Scheduled Pinned Locked Moved C#
question
11 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X xilefxilef

    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.

    M Offline
    M Offline
    miah alom
    wrote on last edited by
    #2

    Where do you want to display the ToolTip? Do you need the ToolTip on the mouse hover event of the statusbar panel?

    X 1 Reply Last reply
    0
    • M miah alom

      Where do you want to display the ToolTip? Do you need the ToolTip on the mouse hover event of the statusbar panel?

      X Offline
      X Offline
      xilefxilef
      wrote on last edited by
      #3

      Yes, just a basic tooltip unless there is a better way of displaying the text that is not completely visible in the statusbar.

      M 1 Reply Last reply
      0
      • X xilefxilef

        Yes, just a basic tooltip unless there is a better way of displaying the text that is not completely visible in the statusbar.

        M Offline
        M Offline
        miah alom
        wrote on last edited by
        #4

        All you need is drag drop a ToolTip object from the toolbox. this.toolTip1.SetToolTip(this.StatusBarPanel1, "hello");

        X 1 Reply Last reply
        0
        • M miah alom

          All you need is drag drop a ToolTip object from the toolbox. this.toolTip1.SetToolTip(this.StatusBarPanel1, "hello");

          X Offline
          X Offline
          xilefxilef
          wrote on last edited by
          #5

          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

          M 1 Reply Last reply
          0
          • X xilefxilef

            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

            M Offline
            M Offline
            miah alom
            wrote on last edited by
            #6

            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.

            X 1 Reply Last reply
            0
            • M miah alom

              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.

              X Offline
              X Offline
              xilefxilef
              wrote on last edited by
              #7

              "...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.

              M 1 Reply Last reply
              0
              • X xilefxilef

                "...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.

                M Offline
                M Offline
                miah alom
                wrote on last edited by
                #8

                Thats right.

                X 1 Reply Last reply
                0
                • M miah alom

                  Thats right.

                  X Offline
                  X Offline
                  xilefxilef
                  wrote on last edited by
                  #9

                  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

                  M 1 Reply Last reply
                  0
                  • X xilefxilef

                    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

                    M Offline
                    M Offline
                    miah alom
                    wrote on last edited by
                    #10

                    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.

                    X 1 Reply Last reply
                    0
                    • M miah alom

                      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.

                      X Offline
                      X Offline
                      xilefxilef
                      wrote on last edited by
                      #11

                      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

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups