Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Adding a Bitmap Toolbar Collapse All
Subject Author Date
Delver Medina May 25, 2006 - 7:09 AM

Hello.
Here is my problem. I download the libraries..I am playing with FunnyBars example. When I try to add a toolbar that I have created in photoshop. Its a { 24 bits (44x40 buttons) } Studio automatically places it as a bitmap and not a toolbar.

So Then I say insert new toolbar and Exit Then go and seperately tryo to edit it. When I open up the project its gone. Hoe do you insert a toolbar 24bit into the example? Please Help!!!!!!

Technical Support May 25, 2006 - 9:32 AM

You can edit the .rc file manually to add a custom toolbar resource and a 15/16/24/32-bit bitmap. Any version of Visual Studio will display this toolbar resource in the resource tree but you will not be able to edit it in the resource editor because the editor does not support 15/16/24/32-bit toolbars. So, please simply insert the bitmap resource and define command identifiers for all the images in this bitmap in your resource.h file manually at this first step. The next step is to initialize the command manager with the images stored in your bitmap using the following code:

#define __COUNT_OF_IMAGES__    . . . // put here the real number of images in your bitmap
static UINT g_arrCommandIDs[ __COUNT_OF_IMAGES__ ] =
{
       ID_COMMAND_0, // define these commands in your resource.h file
       ID_COMMAND_1,
       ID_COMMAND_2,
       // . . .
};
CSize _sizeOneImage( 44, 40 );
CRect _rcCurrentImage( 0, 0, _sizeOneImage.cx, _sizeOneImage.cy );
COLORREF clrTransparent = . . .; // color of transparent pixels or COLORREF(-1L) vale for 32-bit images with alpha channel
CExtBitmap _bmp;
       VERIFY( _bmp.LoadBMP_Resource( MAKEINTRESOURCE( IDR_YOUR_BITMAP ) ) );
       for( int i = 0; i < __COUNT_OF_IMAGES__; i ++ )
       {
             CExtCmdItem * pCmdItem =
                    g_CmdManager->CmdAllocPtr( “your command profile name”, g_arrCommandIDs[ i ] );
             ASSERT( pCmdItem != NULL );
             pCmdItem;
             VERIFY(
                     CmdSetIcon(
                            “your command profile name”,
                            g_arrCommandIDs[ i ],
                            bmp,
                            clrTransparent,
                            &_rcCurrentImage
                           )
                     );
             _rcCurrentImage.OffsetRect( _sizeOneImage.cx, 0 );
       }
Now you can use your images in the toolbar. The following code does the same as the CExtToolControlBar::LoadToolBar() method does:
// this array contains identifiers from the g_arrCommandIDs and
// the ID_SEPARATOR values in the locations where separators should appear
static UINT g_arrToolbarButtonIDs[] =
{
       ID_COMMAND_0,
       ID_COMMAND_1,
       ID_SEPARATOR, // separator
       ID_COMMAND_2,
       // . . .
};
 
       m_wndToolBar.SetButtons(
             sizeof(g_arrToolbarButtonIDs) / sizeof(g_arrToolbarButtonIDs[0])
             );
       m_wndToolBar.InitContentExpandButton(); // creates chevron button