Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Icons in CXTPToolBar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Icons in CXTPToolBar

 Post Reply Post Reply
Author
Message
GoBeavs View Drop Down
Newbie
Newbie


Joined: 17 June 2008
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote GoBeavs Quote  Post ReplyReply Direct Link To This Post Topic: Icons in CXTPToolBar
    Posted: 23 June 2008 at 12:31pm
Hi,

I'm trying to reuse some icons in a toolbar with the following code.

{
    // make the array for the icons
    UINT icons[] = {0, 0, 0, 0, 0, ID_VALUESET_COMMITCHANGES};

    // now set the color icon
    int index = 0;
    // if we have a valuset, get the correct color
    icons[index] = ID_VALUESET_COLOR;
    // set the icons for the toobar
    VERIFY(m_MainToolBar->GetImageManager()->SetIcons(IDB_VALUESET, icons, _countof(icons), CSize(32, 32)) );
    m_MainToolBar->Invalidate();
}

What I'm seeing is that I am always getting the first 2 icons out of IDB_VALUSET which is a .png file. The behavior I desire is to pick icons within that file and set them on particular buttons. m_MainToolBar is a CXTPToolBar.

Is it the case that the specification of icons[] is somehow wrong, or is this just not possible with a CXTPToolBar?

Thanks,

Darin
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2008 at 1:36pm
Hi,
 
Need to see your toolbar resource and your toolbar bitmap to understand what you need.
 
Attach sample.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
GoBeavs View Drop Down
Newbie
Newbie


Joined: 17 June 2008
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote GoBeavs Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2008 at 1:44pm
Thanks.

We have found 2 ways to resolve this problem and would like to know which is the preferred method.  We found empirically that:

1. Since there are 10 images in my .png file, if I change the icon array to have a place for each icon, the code works.

UINT icons[] = {0, 0, 0, 0, 0, ID_VALUESET_COMMITCHANGES, 0, 0, 0, 0};

2. Changing the array to indicate unused icons with -1 makes the icon mapping work

UINT icons[] = {-1, -1, -1, -1, -1, ID_VALUESET_COMMITCHANGES};

Which is preferred? I tend to like number 2 because it doesn't require me to know how many icons are in the png file, just account for which ones I'm using.

Thanks

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2008 at 2:50pm
Hi,
 
I'm not even sure that second method really work.  if you don't know how many icons in file, how ImageManager have to determine it ?
 
Use first method.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.031 seconds.