ToolBarCtrl中的插入button时, TBBUTTON并没该button的tooltip,请问如何在动态插入ToolBar按钮时, 指定该按钮的tooltip字符串?typedef struct _TBBUTTON {
int iBitmap;// zero-based index of button image
int idCommand; // command to be sent when button pressed
BYTE fsState; // button state--see below
BYTE fsStyle; // button style--see below
DWORD dwData; // application-defined value
int iString;// zero-based index of button label string
} TBBUTTON;InsertButton( int nIndex, LPTBBUTTON lpButton );
int iBitmap;// zero-based index of button image
int idCommand; // command to be sent when button pressed
BYTE fsState; // button state--see below
BYTE fsStyle; // button style--see below
DWORD dwData; // application-defined value
int iString;// zero-based index of button label string
} TBBUTTON;InsertButton( int nIndex, LPTBBUTTON lpButton );
int idCommand; // command to be sent when button pressed
BYTE fsState; // button state--see below
BYTE fsStyle; // button style--see below
DWORD dwData; // application-defined value
int iString;// zero-based index of button label string
} TBBUTTON;BOOL InsertButton( int nIndex, LPTBBUTTON lpButton );
As described in the procedure below, append the toolbar tip text, separated by a newline character (‘\n’), to the string resource containing the command-line prompt for the toolbar command. The string resource shares the ID of the toolbar button.
其它按钮都有tooltip, 就是动态插入的按钮没tooltip
首先,ToolBar要支持ToolTips
也就是这里所说的
“Add the CBRS_TOOLTIPS style to the other styles (such as WS_CHILD, WS_VISIBLE, and other CBRS_ styles) passed as the dwStyle parameter to theCToolBar::Create function or inSetBarStyle.”然后,用iString来指定你想要添加的按钮的字符串在数组中的下标
要想添加该按钮的字符串值用addString();
这时候关键来了,要想制定tips
这个字符串的值后面要用"\n加tips的内容"
m_tooltip.Activate(true);
m_tooltip.SetTipBkColor(RGB(233,33,33));
m_tooltip.SetTipTextColor(RGB(0,0,200));
m_tooltip.SetDelayTime(100);
m_tooltip.AddTool(ID,"SSSS");
“关于”按钮,它的tips为“我的关于”
则在addstrings(“\n我的关于”);
addstrings的返回值就是该按钮的iString
void CToolBarCtrl::SetToolTips(CToolTipCtrl* pTip );
谢谢了, 但iString指的是button的label的索引而不是tooltip的索引.