Solved

Multi-line tool tip

Posted on 2004-10-21
852 Views
Last Modified: 2012-05-05
During a search on "multi-line tool tips", I came across an accepted answer that was provided by webbingxia

I am not sure as to how I should implement this code (below "char szLongMessage[] =").   Do I create a module and then call the function from the  Other Tab, Control Tip Text line?   Can anyone help?  

Tom




==========================================================
Multiline Tooltips
Multiline tooltips allow text to be displayed on more than one line. They are supported by version 4.70 and later of the common controls. Your application creates a multiline tooltip by responding to a TTN_GETDISPINFO notification message. To force the tooltip control to use multiple lines, send a TTM_SETMAXTIPWIDTH message, specifying the width of the display rectangle. Text that exceeds this width will wrap to the next line rather than widening the display region. The rectangle height will be increased as needed to accommodate the additional lines. The tooltip control will wrap the lines automatically, or you can use a carriage return/line feed combination, \r\n, to force line breaks at particular locations.

Note that the text buffer specified by the szText member of the NMTTDISPINFO structure can accommodate only 80 characters. If you need to use a longer string, point the lpszText member of NMTTDISPINFO to a buffer containing the desired text.

The following code fragment is an example of a simple TTN_GETDISPINFO notification handler. It creates a multiline tooltip by setting the display rectangle to 300 pixels and setting the lpszText member of NMTTDISPINFO to point to a buffer with the desired text.

char szLongMessage[] =
"This is a long message for the ToolTip, which will automatically "
"be wrapped when it exceeds the maximum tip width.  "
"Alternatively, you can use a \r\n"
"carriage return/line feed combination\r\n"
"to force line breaks at specific\r\n"
"locations.";

switch (lpnmhdr->code) {
  case TTN_GETDISPINFO:
    lpttd = (LPNMTTDISPINFO)lpnmhdr;
    SendMessage(lpnmhdr->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 300);
    lpttd->lpszText = szLongMessage;
    return 0;
     
     ...
 //Other notification handlers go here, as needed.
}
==========================================================
0
Question by:TomBock2004
    2 Comments
     
    LVL 11

    Expert Comment

    by:Jokra_the_Barbarian
    Are you talking about the tooltips that appear when you mouse over a form control? If so, all you have to do is include a vbcrlf in the string. You can set a control tip text on form load if you want:

        Me.Control1.ControlTipText = "Hello." & vbCrLf & "Not much to see here."
    0
     
    LVL 41

    Accepted Solution

    by:
    Tom - the above is C code rather than VBA. As Jokra_the_Barbarian has indicated, you can set line breaks in your tools tips in that manner in code, or else when you are typing into the Properties window, just press CTRL+ENTER to put a line break into the tip.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now