Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Toolbar with 256 colors
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Toolbar with 256 colors

 Post Reply Post Reply
Author
Message
aimslife View Drop Down
Newbie
Newbie
Avatar

Joined: 19 January 2007
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote aimslife Quote  Post ReplyReply Direct Link To This Post Topic: Toolbar with 256 colors
    Posted: 19 January 2007 at 2:12am

I am beginner Developer of ToolkitProEval using with vs2k5. I am developing SDI application using vs2k5 with ToolkitProEval. I have Bitmap strip for toolbar icon with 256 colors but I am not able to add bitmap strip as a toolbar in project resources. I found the way to make toolbar using bitmap strip in Ordinary MFC application and code is following which is working.

 

NOTE: m_wndToolBar (Object of CToolBar)

 

if( ! m_wndToolBar.CreateEx( this ) )

{

            TRACE0( "Failed to create toolbar\n" );

            return -1;      // fail to create

}

//------------Load ToolBar - START------------

CImageList img;

CBitmap bm;

 

m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50, 150);

m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);

 

HBITMAP hbm = (HBITMAP)::LoadImage( AfxGetInstanceHandle( ),

                                    MAKEINTRESOURCE( IDB_HOTTOOLBAR ),

                                    IMAGE_BITMAP,

                                    0, 0,

                                    LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS );

 

bm.Attach(hbm);

img.Create( 25, 25, ILC_COLOR8 | ILC_MASK, 4, 4 );

img.Add( &bm, RGB(255, 255, 255) );

m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);

img.Detach( );

bm.Detach( );

 

img.Create(IDB_COLDTOOLBAR, 25, 0, RGB(255, 255, 255));

m_wndToolBar.GetToolBarCtrl().SetImageList(&img);

img.Detach();

 

m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT );

m_wndToolBar.SetButtons(NULL, 8);

 

m_wndToolBar.SetButtonInfo(0, ID_BACK_LEVEL,     TBSTYLE_BUTTON, 0);

m_wndToolBar.SetButtonInfo(1, ID_NEXT_LEVEL,     TBSTYLE_BUTTON, 1);

m_wndToolBar.SetButtonInfo(2, ID_HOME,           TBSTYLE_BUTTON, 2);

m_wndToolBar.SetButtonInfo(3, IDD_NEW_MSG,       TBSTYLE_BUTTON, 3);

m_wndToolBar.SetButtonInfo(4, ID_VIEW_LARGEICON, TBSTYLE_BUTTON | TBSTYLE_CHECK, 4);

m_wndToolBar.SetButtonInfo(5, ID_VIEW_SMALLICON, TBSTYLE_BUTTON | TBSTYLE_CHECK, 5);

m_wndToolBar.SetButtonInfo(6, ID_VIEW_LIST,      TBSTYLE_BUTTON | TBSTYLE_CHECK, 6);

m_wndToolBar.SetButtonInfo(7, ID_VIEW_DETAILS,   TBSTYLE_BUTTON | TBSTYLE_CHECK, 7);

 

CRect rectToolBar;

// set up toolbar button sizes

m_wndToolBar.GetItemRect(0, &rectToolBar);

CSize size = rectToolBar.Size();

m_wndToolBar.SetSizes(size, CSize(25,25));

 

m_wndToolBar.SetBarStyle( m_wndToolBar.GetBarStyle() |

                          CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);

//------------Load ToolBar - END--------------

 

I have seen Toolkit sample programs and all of them made toolbar with the use of toolbar resource, I have no idea about how to add bitmap strip with 256 colors as toolbar in project resource. Can you please help me to add bitmap strip with 256 colors as project resource? Or tell me some other way to make toolbar with all Toolkit style and in look and feel supports.

regards,

-aims
.
regards,
-aims
.
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2007 at 4:05am
Hi Aims,
 
I do it this way:
1. Create the toolbar the usual way within the resource editor
2. After finishing my work I replace the bitmap file used by the toolbar by my 256bit and/or true color bitmap file - after that the toolbar is no longer modifyable by the resource editor, so I keep a copy of the original bitmap to exchange it with the hires bitmap file whenever I have to apply any changes to the toolbar.
 
Another way could be creating the toolbar resource by directly editing the .rc file.
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
aimslife View Drop Down
Newbie
Newbie
Avatar

Joined: 19 January 2007
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote aimslife Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2007 at 10:10am
Hi Martin,

but how i can assign Button Resource ID's? after replace image it will not open in development ide.


regards,
-aims
.
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2007 at 10:16am

Hi Aims;

Thats why I keep a copy of the original bitmap. Whenever I want to change any aspect of the toolbar (add or remove buttons, change IDs, ...) I first exchange the original and the hires bitmap. In this case the IDE is able to open and edit the toolbar. In any case I believe that its necessary to save and close any open resource views before replacing the bitmaps - I haven't tested this.
I for myself do not use the IDE resource editor to manage toolbars, I'm doing all my changes by plain text editing of the apps .rc file(s).

I hope this helps

Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
aimslife View Drop Down
Newbie
Newbie
Avatar

Joined: 19 January 2007
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote aimslife Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2007 at 11:00am
Hi Martin,

i like your idea and this way i will explore .rc file as well and after try it, i will reply you. here today is off now almost, i will do about on Sunday or Monday. But Martin, i have one more question about writing resource information in .rc file, how you define Resource ID value?

for example i write following statement in .rc file

IDR_MAINFRAME TOOLBAR  16, 15
BEGIN
    BUTTON      IDD_NEW
    BUTTON      IDD_OPEN
    BUTTON      IDD_SAVE
END

how i can define IDD_NEW value in resources.h? and are we need to define above lines for define toolbar in .rc file or we need to do some thing else more?
regards,
-aims
.
Back to Top
aimslife View Drop Down
Newbie
Newbie
Avatar

Joined: 19 January 2007
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote aimslife Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2007 at 2:32am

I think it would be better for me to write resource code in .rc file to make toolbar and defining macros for them also. When ever I feel to change some thing in toolbar then I will use mspaint, I think this would better for me. But I have no idea about assigning resource ID to any thing; any one can help me to refer some article to learn about it. How to assign resource ID? And what kind of resource ranges to be use for which resource? I have seen following thing in resource.h file but I was not able to get any article about them, I think these will be help me out in assigning resource ID which I feels after read comment, am I right?

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        134
#define _APS_NEXT_COMMAND_VALUE         32778
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

I need article to help me in making toolbar using writing code in .rc file and assigning resource ID by own and do every thing by writing some thing.

Regards,

-aims

regards,
-aims
.
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2007 at 3:54am
Hi amis,
 
take a look at MSDN. Search for resource ID assignment - there are several articles about reserved IDs and which ranges are best for what kind of resources.
In any case, in MFCs default, command IDs (buttons, menu commands, ...) start with values of 32768; strings start with 100 and also control IDs start with 100. You can select whatever number you like as long as the number for menu, command and string resources is unique and for controls it must be unique within the scope of the control.
 
The code sequence you mentioned is for the internal IDE resource editor to assign new numbers to resources. For example, the next string you insert with the IDE resource editor gets ID 134.
 
I for myself do not use the internal editor, since its very rigid and inflexible. For example try to group string resources to keep them together view by view - ist aimless!
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
aimslife View Drop Down
Newbie
Newbie
Avatar

Joined: 19 January 2007
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote aimslife Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2007 at 4:23am
Hi Martin,

Thanks Martin, its help me a lot. i wrote code in .rc file and define resource Id's in resource.h file and it's successfully working. my bitmap image have white back ground color, can you guide me how to set image Mask colors for toolbar back ground?
regards,
-aims
.
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2007 at 4:38am
Hi aims;
 
take a look at
 
GetCommandBars()->GetImageManager()->SetMaskColor(...)
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
aimslife View Drop Down
Newbie
Newbie
Avatar

Joined: 19 January 2007
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote aimslife Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2007 at 4:47am
Thanks Martin!
regards,
-aims
.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.