Displaying Tooltiptext -Problem
-
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..
-
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..
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