Changing command bar button bitmaps at runtime |
Post Reply |
Author | |
AnotherDay
Newbie Joined: 09 August 2010 Status: Offline Points: 5 |
Post Options
Thanks(0)
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!
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
AnotherDay
Newbie Joined: 09 August 2010 Status: Offline Points: 5 |
Post Options
Thanks(0)
|
Thanks!!!!
The first option (loading all at startup and setting IconID works perfectly.
Thanks again!
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |