How to change a toolbar bitmap image?
-
I want to change a toolbar bitmap image Inbox to a different bitmap (or a bitmap with a very different color background) when there are messages in the Inbox. Or some way to give the user an alert that there are new messages in the Inbox. Can this be done? Elizabeth
-
I want to change a toolbar bitmap image Inbox to a different bitmap (or a bitmap with a very different color background) when there are messages in the Inbox. Or some way to give the user an alert that there are new messages in the Inbox. Can this be done? Elizabeth
One quick method would be to have two cpies of the same toolbar in your resources which have the same buttons, but one has a different image. When you need to switch bitmaps, you just call pToolbar->LoadToolbar() with the correct resource id for the correct images you want. I do somehing similar in an app of mine to switch between small/large icons and it works fine. Roger Allen Sonork 100.10016 Death come early, death come late, It takes us all, there is no reason. For every purpose under heaven, To each a turn, to each a season. A time to weep and a time to sigh, A time to laugh and a time to cry, A time to be born and a time to die. Dust to dust and ashes to ashes, And so I end my song.
-
One quick method would be to have two cpies of the same toolbar in your resources which have the same buttons, but one has a different image. When you need to switch bitmaps, you just call pToolbar->LoadToolbar() with the correct resource id for the correct images you want. I do somehing similar in an app of mine to switch between small/large icons and it works fine. Roger Allen Sonork 100.10016 Death come early, death come late, It takes us all, there is no reason. For every purpose under heaven, To each a turn, to each a season. A time to weep and a time to sigh, A time to laugh and a time to cry, A time to be born and a time to die. Dust to dust and ashes to ashes, And so I end my song.
I tried out your method. However, the toolbar flashes whenever the mouse is over it. I had LoadToolBar() at ON_UPDATE_COMMAND_UI(ID_INBOX, OnUpdateInbox). The flashing is very annoying. Elizabeth
-
I tried out your method. However, the toolbar flashes whenever the mouse is over it. I had LoadToolBar() at ON_UPDATE_COMMAND_UI(ID_INBOX, OnUpdateInbox). The flashing is very annoying. Elizabeth
It sounds like you just need to add a small amount of extra processing that only calls LoadToolbar() when a change in the button state is required. That should remove the flashing in the ON_UPADTE() handler. Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!
-
It sounds like you just need to add a small amount of extra processing that only calls LoadToolbar() when a change in the button state is required. That should remove the flashing in the ON_UPADTE() handler. Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!
I added some lines to set state of the toolbar, but once it gets out of ON_UPDATE_COMMAND_UI, the state is reset. What I am trying to do is to set the toolbar button ID_INBOX to TBSTATE_PRESSED when there is new mail and TBSTATE_ENABLED when there is no new mail. But the toolbar keeps flashing when I move the mouse over it. Here is some code: if (pDoc->NewMail()) { if (m_wndToolBarCtrl.GetState(ID_INBOX) != TBSTATE_PRESSED) { m_wndToolBar.LoadToolBar(IDR_MAINFRAME_NEWMAIL); m_wndToolBar.GetToolBarCtrl().SetState(ID_INBOX, TBSTATE_PRESSED); } } else { if (m_wndToolBar.GetToolBarCtrl().GetState(ID_INBOX) != TBSTATE_ENABLED) { m_wndToolBar.LoadToolBar(IDR_MAINFRAME); m_wndToolBar.GetToolBarCtrl().SetState(ID_INBOX, TBSTATE_ENABLED); } } Elizabeth