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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is it possible to insert a new line (\n) in a tool tip?

Is it possible to insert a new line (\n) in a tool tip?

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 Posters 1 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.
  • L Offline
    L Offline
    Luis E Cuadrado
    wrote on last edited by
    #1

    Hello everbody: I was wondering if it is possible to have more than one line in the string that is going to be displayed in a tool tip? I gave it a try with the following code, but is displayed all in one line and there is a small square in between the two strings that I want to display: CString displayLine; CString idString; idString.LoadString(IDS_TT_DCSRAW); displayLine.Format("%s\nHi Res", idString); . . . m_ToolTip->AddTool(this, (LPCTSTR)displayLine,rFileTypeCoord, 1); Is this a Tool Tip attribute that I have to set? Is there another way to put the new line character? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

    W PJ ArendsP L 3 Replies Last reply
    0
    • L Luis E Cuadrado

      Hello everbody: I was wondering if it is possible to have more than one line in the string that is going to be displayed in a tool tip? I gave it a try with the following code, but is displayed all in one line and there is a small square in between the two strings that I want to display: CString displayLine; CString idString; idString.LoadString(IDS_TT_DCSRAW); displayLine.Format("%s\nHi Res", idString); . . . m_ToolTip->AddTool(this, (LPCTSTR)displayLine,rFileTypeCoord, 1); Is this a Tool Tip attribute that I have to set? Is there another way to put the new line character? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

      W Offline
      W Offline
      will1383
      wrote on last edited by
      #2

      No it is not possible that I can see. I've only seen 1 line, albeit some long ones, but when ever I've added the "\n" I only get the text that comes after the "\n". for example: if the tooltip is "I am having\nsome difficulties" what you see on the screen is "some difficulties" There may be some funky trick to do it, but I haven't yet found one. Hope this helps! Dan Willis

      1 Reply Last reply
      0
      • L Luis E Cuadrado

        Hello everbody: I was wondering if it is possible to have more than one line in the string that is going to be displayed in a tool tip? I gave it a try with the following code, but is displayed all in one line and there is a small square in between the two strings that I want to display: CString displayLine; CString idString; idString.LoadString(IDS_TT_DCSRAW); displayLine.Format("%s\nHi Res", idString); . . . m_ToolTip->AddTool(this, (LPCTSTR)displayLine,rFileTypeCoord, 1); Is this a Tool Tip attribute that I have to set? Is there another way to put the new line character? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

        PJ ArendsP Offline
        PJ ArendsP Offline
        PJ Arends
        wrote on last edited by
        #3

        http://www.codeproject.com/miscctrl/#Tooltips[^]


        CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!

        Within you lies the power for good; Use it!

        1 Reply Last reply
        0
        • L Luis E Cuadrado

          Hello everbody: I was wondering if it is possible to have more than one line in the string that is going to be displayed in a tool tip? I gave it a try with the following code, but is displayed all in one line and there is a small square in between the two strings that I want to display: CString displayLine; CString idString; idString.LoadString(IDS_TT_DCSRAW); displayLine.Format("%s\nHi Res", idString); . . . m_ToolTip->AddTool(this, (LPCTSTR)displayLine,rFileTypeCoord, 1); Is this a Tool Tip attribute that I have to set? Is there another way to put the new line character? Any answer is more than welcome. Best regards, Luis E. Cuadrado :0)

          L Offline
          L Offline
          Luis E Cuadrado
          wrote on last edited by
          #4

          I found a way! Where you create the CToolTipCtrl and and you call the Create() method, you had the following line: m_ToolTip->SendMessage( TTM_SETMAXTIPWIDTH, 0, 300); Then in the AddTool() method, you can put \n's and it will add a new line to the tool tip. The code looks pretty much like this: if ( m_ToolTip == NULL ) { m_ToolTip = new CToolTipCtrl; m_ToolTip->Create(this); m_ToolTip->SendMessage( TTM_SETMAXTIPWIDTH, 0, 300); } m_ToolTip->AddTool(this, "One line\nSecond Line\nThird line"); m_ToolTip->Activate(TRUE); I did this and it worked. Best regards, Luis E. Cuadrado :0)

          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