Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Changing command bar button bitmaps at runtime
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Changing command bar button bitmaps at runtime

 Post Reply Post Reply
Author
Message
AnotherDay View Drop Down
Newbie
Newbie


Joined: 09 August 2010
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote AnotherDay Quote  Post ReplyReply Direct Link To This Post Topic: Changing command bar button bitmaps at runtime
    Posted: 09 August 2010 at 4:27pm
Hello all -
 
The boss wants his icon bitmaps (in a CmndBar button control) to change based upon whatever random criteria that bosses like to come up with.
 
So, I create the button:
WkFlowButtonMain = WkFlowGroup.Add(XTPControlType.xtpControlButton, ID.ID_WKFLOW_MAIN, "&Workflow", false, false);
 
I load the bitmap:
CmndBars.Icons.LoadBitmap(resDir + "Workflow.bmp", new int[] { ID.ID_WKFLOW_CAL }, XtremeCommandBars.XTPImageState.xtpImageNormal);
 
Everything is fine so far. Now let's say some random user event that the boss picked on any particular day of the year occurs.
 
I reload the bitmap, with a different one:
CmndBars.Icons.LoadBitmap(resDir + "WorkflowParent.bmp", new int[] { ID.ID_WKFLOW_CAL }, XtremeCommandBars.XTPImageState.xtpImageNormal);
 
No change in the button bitmap. But (at least up until today) - the following did work:
 
WkFlowButtonMain.Enabled = false;
CmndBars.Icons.LoadBitmap(resDir + "WorkflowParent.bmp", new int[] { ID.ID_WKFLOW_CAL }, XtremeCommandBars.XTPImageState.xtpImageNormal);
WkFlowButtonMain.Enabled = true;
 
There was a bit of an annoying flash, but the boss got his new bitmap, and life was good. Today, with no changes in code anywhere near this module.... it just quit working.
 
So I'm thinking I'm doing it wrong from the start.
 
Can anyone give me any tips as to how to change a button bitmap at runtime?
 
I'd appreciate it, my boss would appreciate it, and I'd appreciate my boss appreciating it, so as I can move on to working on functionality that actually benefits the end user.
 
Thanks again!
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 11 August 2010 at 3:46am
Hi,

If you have some predefined number of bitmaps that can be set, better load all of them in startup and just change WkFlowButtonMain.IconId property when you need change it.

Think your problem that you save WkFlowButtonMain somewhere in your properties and its not good - if user Load layout this pointer will be not valid.

Better use FindControl or Update handler to find and update it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
AnotherDay View Drop Down
Newbie
Newbie


Joined: 09 August 2010
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote AnotherDay Quote  Post ReplyReply Direct Link To This Post Posted: 11 August 2010 at 10:24am
Thanks!!!!
 
The first option (loading all at startup and setting IconID works perfectly.
 
Thanks again!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.219 seconds.