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 / C++ / MFC
  4. Displaying Tooltiptext -Problem

Displaying Tooltiptext -Problem

Scheduled Pinned Locked Moved C / C++ / MFC
help
2 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.
  • P Offline
    P Offline
    Pazzuzu
    wrote on last edited by
    #1

    Hi, Iam using ToolBarControl & in my "ToolTipsHandler" which is an event declared in the message map as follows BEGIN_MESSAGE_MAP(C_ListPageTemp, CDialog) //{{AFX_MSG_MAP(C_ListPageTemp) ON_NOTIFY_EX(TTN_NEEDTEXTA,0,ToolTipsHandler) //}}AFX_MSG_MAP END_MESSAGE_MAP() Now my "ToolTipsHandler" function goes like this ***************************************** TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; UINT nID =pNMHDR->idFrom; pTTT->lpszText = MAKEINTRESOURCE(nID); pTTT->hinst = AfxGetResourceHandle(); return TRUE; ********************************************* Now instead of taking the tooltiptext from the ResourceStringtable,I want to provide my own strings(decided upon,on which language the tooltip text should appear.This language string, I will be getting from a part of my program which Iam not showing here.) Will be getting this language dependent string in "T_String" type where "T_String" is of type typedef std::wstring T_String; I tried to provide my string as follows. T_String test;//(string which I get from a part of my Program ,depending on language). pTTT->lpszText =const_cast(test). It compiled,but the tooltip displayed was a junk value. Is this(pTTT->lpszText),the right place to give my string in the "TOOLTIPTEXT" structure or should I use the "szText" member. If so,How would I make the necessary conversions. Would be nice if someone could tell me with a code snippet.. Thanks..

    V 1 Reply Last reply
    0
    • P Pazzuzu

      Hi, Iam using ToolBarControl & in my "ToolTipsHandler" which is an event declared in the message map as follows BEGIN_MESSAGE_MAP(C_ListPageTemp, CDialog) //{{AFX_MSG_MAP(C_ListPageTemp) ON_NOTIFY_EX(TTN_NEEDTEXTA,0,ToolTipsHandler) //}}AFX_MSG_MAP END_MESSAGE_MAP() Now my "ToolTipsHandler" function goes like this ***************************************** TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; UINT nID =pNMHDR->idFrom; pTTT->lpszText = MAKEINTRESOURCE(nID); pTTT->hinst = AfxGetResourceHandle(); return TRUE; ********************************************* Now instead of taking the tooltiptext from the ResourceStringtable,I want to provide my own strings(decided upon,on which language the tooltip text should appear.This language string, I will be getting from a part of my program which Iam not showing here.) Will be getting this language dependent string in "T_String" type where "T_String" is of type typedef std::wstring T_String; I tried to provide my string as follows. T_String test;//(string which I get from a part of my Program ,depending on language). pTTT->lpszText =const_cast(test). It compiled,but the tooltip displayed was a junk value. Is this(pTTT->lpszText),the right place to give my string in the "TOOLTIPTEXT" structure or should I use the "szText" member. If so,How would I make the necessary conversions. Would be nice if someone could tell me with a code snippet.. Thanks..

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      FROM MSDN: In writing your tool tip notification handler, you need to use the TOOLTIPTEXT structure. The members of the TOOLTIPTEXT structure are: typedef struct { NMHDR hdr; // required for all WM_NOTIFY messages LPTSTR lpszText; // see below WCHAR szText[80]; // buffer for tool tip text HINSTANCE hinst; // see below UINT uflags; // flag indicating how to interpret the // idFrom member of the NMHDR structure // that is included in the structure } TOOLTIPTEXT, FAR *LPTOOLTIPTEXT; hdr Identifies the tool that needs text. The only member of this structure you might need is the control's command ID. The control's command ID will be in the idFrom member of the NMHDR structure, accessed with the syntax hdr.idFrom. See NMHDR for a discussion of members of the NMHDR structure. lpszText Address of a string to receive the text for a tool. szText Buffer that receives the tool tip text. An application can copy the text to this buffer as an alternative to specifying a string address. hinst Handle of the instance that contains a string resource to be used as the tool tip text. If lpszText is the address of the tool tip text, this member is NULL. When you handle the TTN_NEEDTEXT notification message, specify the string to be displayed in one of the following ways: Copy the text to the buffer specified by the szText member. Copy the address of the buffer that contains the text to the lpszText member. Copy the identifier of a string resource to the lpszText member, and copy the handle of the instance that contains the resource to the hinst member I think you can try using szText. Remember it can only hold 80 characters, which is not much. good luck. (let me now if it worked? tnx) "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

      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