Здравствуйте,
добавляю кнопку на основной тулбар программы следующим кодом:
TBBUTTON bi={0};
bi.idCommand=123;
bi.fsStyle=TBSTYLE_BUTTON;
//bi.iString=m_wndToolBar.GetToolBarCtrl().AddStrings("aaa\0");
m_wndToolBar.GetToolBarCtrl().InsertButton(m_wndToolBar.GetToolBarCtrl().GetButtonCount(),&bi);
А как мне задать строку всплывающей подсказки для новой кнопки?
Заранее спасибо.
Здравствуйте, potap, Вы писали:
P>Здравствуйте,
P>добавляю кнопку на основной тулбар программы следующим кодом:
P>P>TBBUTTON bi={0};
P>bi.idCommand=123;
P>bi.fsStyle=TBSTYLE_BUTTON;
P>//bi.iString=m_wndToolBar.GetToolBarCtrl().AddStrings("aaa\0");
P>m_wndToolBar.GetToolBarCtrl().InsertButton(m_wndToolBar.GetToolBarCtrl().GetButtonCount(),&bi);
P>
P>А как мне задать строку всплывающей подсказки для новой кнопки?
Кусок из MSDN:
CToolBarCtrl: Handling Tool Tip Notifications
When you specify the TBSTYLE_TOOLTIPS style, the toolbar creates and manages a tool tip control. A tool tip is a small pop-up window that contains a line of text describing a toolbar button. The tool tip is hidden, appearing only when the user puts the cursor on a toolbar button and leaves it there for approximately one-half second. The tool tip is displayed near the cursor.
Before the tool tip is displayed, the TTN_NEEDTEXT notification message is sent to the owner window of the toolbar to retrieve the descriptive text for the button. If the owner window of the toolbaris a CFrameWnd window, tool tips are displayed wihout any extra effort, because CFrameWnd has a default handler for the TTN_NEEDTEXT notification. If the owner window of the toolbaris not derived from CFrameWnd, such as a dialog box or form view, you must add an entry to the message map of your owner window and provide a notification handler in the message map. The entry to the message map of your owner window is as follows:
ON_NOTIFY_EX( TTN_NEEDTEXT, 0, memberFxn )
memberFxn
The method to be called when text is needed for this button.
Note that the id of a tool tip is always 0.
Спасибо.
А покомпактнее нет способа? чтобы указать строки там же, где и кнопки задаются. а не размазывать код по всей программе.
Здравствуйте, McQwerty, Вы писали:
MQ>Здравствуйте, potap, Вы писали:
P>>Здравствуйте,
P>>добавляю кнопку на основной тулбар программы следующим кодом:
P>>P>>TBBUTTON bi={0};
P>>bi.idCommand=123;
P>>bi.fsStyle=TBSTYLE_BUTTON;
P>>//bi.iString=m_wndToolBar.GetToolBarCtrl().AddStrings("aaa\0");
P>>m_wndToolBar.GetToolBarCtrl().InsertButton(m_wndToolBar.GetToolBarCtrl().GetButtonCount(),&bi);
P>>
P>>А как мне задать строку всплывающей подсказки для новой кнопки?
MQ>Кусок из MSDN:
MQ>CToolBarCtrl: Handling Tool Tip Notifications
MQ>When you specify the TBSTYLE_TOOLTIPS style, the toolbar creates and manages a tool tip control. A tool tip is a small pop-up window that contains a line of text describing a toolbar button. The tool tip is hidden, appearing only when the user puts the cursor on a toolbar button and leaves it there for approximately one-half second. The tool tip is displayed near the cursor.
MQ>Before the tool tip is displayed, the TTN_NEEDTEXT notification message is sent to the owner window of the toolbar to retrieve the descriptive text for the button. If the owner window of the toolbaris a CFrameWnd window, tool tips are displayed wihout any extra effort, because CFrameWnd has a default handler for the TTN_NEEDTEXT notification. If the owner window of the toolbaris not derived from CFrameWnd, such as a dialog box or form view, you must add an entry to the message map of your owner window and provide a notification handler in the message map. The entry to the message map of your owner window is as follows:
MQ>ON_NOTIFY_EX( TTN_NEEDTEXT, 0, memberFxn )
MQ>memberFxn
MQ>The method to be called when text is needed for this button.
MQ>Note that the id of a tool tip is always 0.
Здравствуйте, potap, Вы писали:
P>Спасибо.
P>А покомпактнее нет способа? чтобы указать строки там же, где и кнопки задаются. а не размазывать код по всей программе.
Если кнопок немного, может, проще их не добавлять, а иметь всегда, но дизейблить ? ИМХО так вообще-то лучше — пользователь всегда знает, что тулбар делает, иногда кое-что может быть запрещено по какой-то причине. А если их добавлять и удалять, то пользователь никогда не знает, какие и когда еще могут появиться
Здравствуйте, potap, Вы писали:
P>...
P>А как мне задать строку всплывающей подсказки для новой кнопки?
P>Заранее спасибо.
Привет
Можно использовать следующий код:
// CToolTipCtrl m_toolTip;
// ... как правило при создании тулбара
CRect rect;
m_wndToolBar.GetToolBarCtrl().GetItemRect(0, rect);
// добавить тултип (ы)
// m_toolTip.AddTool(...)
// связать тултип с тулбаром
m_wndToolBar.GetToolBarCtrl().SetToolTips(&m_toolTip);
//////////////////////////////////////////////////////////////////////////
Только там такой момент, что AddTool добавляет текст для всех элементов тулбара (включая пропуски)
, по-моему

В общем раскопаешь
не получится
кнопки пользователь добавляет
выбирает картинку (bmp-файл) и действие (vb-скрипт)
так что я заранее (в момент сборки программы) не знаю, какие будут кнопки
Здравствуйте, Pavel Dvorkin, Вы писали:
PD>Здравствуйте, potap, Вы писали:
P>>Спасибо.
P>>А покомпактнее нет способа? чтобы указать строки там же, где и кнопки задаются. а не размазывать код по всей программе.
PD>Если кнопок немного, может, проще их не добавлять, а иметь всегда, но дизейблить ? ИМХО так вообще-то лучше — пользователь всегда знает, что тулбар делает, иногда кое-что может быть запрещено по какой-то причине. А если их добавлять и удалять, то пользователь никогда не знает, какие и когда еще могут появиться