Print Page | Close Window

Changing command bar button bitmaps at runtime

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=17090
Printed Date: 06 October 2024 at 8:39am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Changing command bar button bitmaps at runtime
Posted By: AnotherDay
Subject: Changing command bar button bitmaps at runtime
Date 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!
 



Replies:
Posted By: Oleg
Date 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


Posted By: AnotherDay
Date Posted: 11 August 2010 at 10:24am
Thanks!!!!
 
The first option (loading all at startup and setting IconID works perfectly.
 
Thanks again!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net