Unable to add custom icon / bitmap to command bar - WinCE 5 API
I am able to add system icons to a command bar, but when I try to add my own, I just get a blank button. I have tried several configurations, a bitmap vs. an icon, and it still shows up as blank. Since I was testing with a system icon, that code is commented out.
Here is my button structure:
Code:
// File bar button structure
const TBBUTTON tbCBStdBtns[] =
{
// BitmapIndex Command State Style UserData String
// {STD_FILENEW, IDC_NEW, TBSTATE_ENABLED,
// TBSTYLE_BUTTON, 0, 0},
{IDB_SQUARED16, IDC_SQUAREDSHIPPING,
TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0}
};
Here is the creation:
case WM_CREATE:
// Create the command bar
g_hWndCommandBar = CommandBar_Create(g_hInst, hWnd, IDC_CMDBAR);
CommandBar_AddBitmap (g_hWndCommandBar, g_hInst, IDB_SQUARED16, 1, 0, 0);
//CommandBar_AddBitmap (g_hWndCommandBar, HINST_COMMCTRL, IDB_STD_SMALL_COLOR, STD_BMPS, 0, 0);
CommandBar_AddButtons(g_hWndCommandBar, 1, &tbCBStdBtns);
//CommandBar_AddButtons(g_hWndCommandBar, 1, &tbCBStdBtns);
CommandBar_InsertMenubar(g_hWndCommandBar, g_hInst, IDR_MENU, 1);
Note that I want the icon to the left of the menu (originally I wanted the icon on the title bar, but apparently it is not supported in WinCE). I'm pretty new at this, so I apologize in advance if my code inclusion does not follow this website's standards. I will certainly provide the files if necessary.
Thanks in advance!
Last edited by MasterWill; July 1st, 2011 at 02:15 PM.
Re: Unable to add custom icon / bitmap to command bar - WinCE 5 API
Update:
My bitmap appears when I add dummy buttons, but it's out of place. There are now 6 buttons (including the separator) and mine is last in the list despite changing the order in the button structure and ID numbers. Here is the current code:
Re: Unable to add custom icon / bitmap to command bar - WinCE 5 API
SOLVED
So i guess the iBitmap parameter of the TBBUTTON structure is supposed to be the index of the array, not the ID number. The examples I was using (from the Boling book) put the IDs there, which may work for many buttons. Since I just want one button to act as a System menu (until I figure out how to add one in the title bar in Windows CE), I changed the value to 0 and deleted the temporary dummy buttons.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.