Also, if you have more than one toolbar, you should have distinct IDs for
each. It appears you are using the default(last parameter in CreateEx).
Eric Lilja wrote:
Ok, I solved it. After creating the toolbar in the framewindow I checked
its styles using GetBarStyle() and even though I specified CBRS_STYLE in
my CreateEx() call it wasn't set! So ORed it in with the other styles
and called SetBarStyle() and now it works! Which is good but I don't
understand why I had to do that. I will do some reading tomorrow
(bedtime here) if no one has replied with an explanation when I wake up.
- Eric
Ok, I was not using CreateEx() properly in my code. Here's the fixed
version:
void
MyToolBar::Create(CWnd *parent)
{
DWORD extended_styles = TBSTYLE_FLAT;
DWORD styles = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP |
CBRS_FLYBY | CBRS_TOOLTIPS;
VERIFY(CToolBar::CreateEx(parent, extended_styles, styles));
bitmap1 = load_button_image(IDB_BITMAP1);
bitmap2 = load_button_image(IDB_BITMAP2);
bitmap3 = load_button_image(IDB_BITMAP3);
bitmap4 = load_button_image(IDB_BITMAP4);
VERIFY(imagelist.Create(16, 15, ILC_COLOR24, 4, 1));
VERIFY(imagelist.Add(bitmap1, (CBitmap *)NULL) == 0);
VERIFY(imagelist.Add(bitmap2, (CBitmap *)NULL) == 1);
VERIFY(imagelist.Add(bitmap3, (CBitmap *)NULL) == 2);
VERIFY(imagelist.Add(bitmap4, (CBitmap *)NULL) == 3);
GetToolBarCtrl().SetImageList(&imagelist);
const UINT button_ids[] = { ID_BUTTON_1, ID_BUTTON_2, ID_BUTTON_3,
ID_SEPARATOR, ID_BUTTON_4 };
VERIFY(SetButtons(button_ids, sizeof(button_ids) /
sizeof(button_ids[0])));
EnableToolTips(TRUE);
}
With this code I don't have to do any SetBarStyle() calls in the frame
window and everything works and looks as I want them to.
- Eric
Eric Lilja wrote:
Joseph M. Newcomer wrote:
What are the strings? Show an example of one.
joe
Thanks for the quick reply. I hope I was able to explain my problem
properly (I'm not a native speaker). Here are the strings (along with
the other strings in of the several string tables in the resource file
I edited manually):
STRINGTABLE
BEGIN
ID_FILE_NEW "Create a new document\nNew"
ID_FILE_OPEN "Open an existing document\nOpen"
ID_FILE_CLOSE "Close the active document\nClose"
ID_FILE_SAVE "Save the active document\nSave"
ID_FILE_SAVE_AS "Save the active document with a new
name\nSave As"
// The string after \n is the the tooltip string, the string before it
is supposed to be the statusbar string
ID_BUTTON_1 "The first button\nfirst"
ID_BUTTON_2 "The second button\nsecond"
ID_BUTTON_3 "The third button\nthird"
ID_BUTTON_4 "The fourth button\nfourth"
END
I've added tooltips to my toolbar and that works just fine (displaying
what's after the \n), but what comes before is only displayed the
statusbar while its corresponding toolbar button i being pressed. If
you need any more info, I will deliver it.
On Wed, 30 May 2007 01:06:24 +0200, Eric Lilja
<mindcoolerremoveme@gmail.com> wrote:
Hello, I tried in my program to create a toolbar manually (I have a
class that derives from CToolBar) instead of modifying what the app
wizard generates for me. Everything works, except for one small