08-30-2005 03:12 AM
08-30-2005 10:53 AM
Well, I did a simple try modifying the tooldemo sample program and seems that it's possible to modify the image shown on a toolbar button using a simple bitmap.
To substitute the image shown, you can simply use SetCtrlBitmap on a particular button. This approach is far from optimized since it modifies an already created button, so you must at least have one image file to load when creating the buttons: you simply change the image shown after the button is created with standard functions. Nevertheless, this method permits you to use the standard toolbar instrument driver without modifications.
To test my solution, open the tooldemo project and substitute MenuCallback() function with the following:
void CVICALLBACK MenuCallback (int menuBar, int menuItem, void *callbackData, int panel){
int pnl, ctrl, bitmap = 0;
char description[64];
switch(menuItem){
case MENU_HELP_ABOUT:
if ((hAboutPanel = LoadPanel (0, "tooldemo.uir", ABOUT)) < 0)
return;
InstallPopup (hAboutPanel);
break;
default:
GetMenuBarAttribute (menuBar, menuItem, ATTR_ITEM_NAME, description);
GetBitmapFromFile (IMAGE_BYSIZE, &bitmap);
Toolbar_GetCtrlFromDescription (gToolbar, description, &pnl, &ctrl);
SetCtrlBitmap (pnl, ctrl, 0, bitmap);
break;
}
}
This code loads a bitmap from disk (you can load it from your database) and then shows it on the button.
After this modifications, the image on the first 7 buttons is modified when you click on one of them (it becomes the image associated with the "Sort by size" button).
Hope this can help you
Roberto
08-31-2005 01:46 AM