Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - 24bit toolbar in the dialog
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

24bit toolbar in the dialog

 Post Reply Post Reply
Author
Message
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Topic: 24bit toolbar in the dialog
    Posted: 01 April 2009 at 2:00pm
How do I place toolbar with 24bit color on the dialog?
It seems that the following code places the toolbar on the dialog but draws the icons found in the toolbar resource instead of image list that I supply. What do I do wrong?
BOOL CMyClass::OnInitDialog()
{
if (!InitCommandBars()) // this implemented in this class instead of calling the CodeJock library
    return FALSE;
RedrawWindow(0, 0, RDW_ALLCHILDREN|RDW_INVALIDATE);
CXTPCommandBars* pCommandBars = m_pCommandBars;
CXTPToolBar* pToolBar = pCommandBars->Add(_T("Standard"), xtpBarTop);

CBitmap bmp;bmp.

LoadBitmap( IDB_BT_TOOLBAR );
m_ToolbarImageList.Create( 16,15,ILC_COLORDDB|ILC_MASK,7,1);
m_ToolbarImageList.Add( &bmp, RGB(255,0,255) );
pToolBar->SendMessage( TB_SETIMAGELIST, 0, (LPARAM)m_ToolbarImageList.m_hImageList );
pToolBar->LoadToolBar(IDR_BT_TOOLBAR);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_DISCONNECT, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_MAKEDIR, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_PUT, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_GET, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_TOGGLE_VIEW, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_SHOW_IMG, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

pToolBar->GetControls()->CreateOriginalControls();

pCommandBars->GetImageManager()->SetIcons(IDR_BT_TOOLBAR);

XTPImageManager()->SetIcons(IDR_MAINFRAME);

pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault);

pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipOffice);

LoadCommandBars(_T("CommandBars"));

RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);

 
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: 02 April 2009 at 5:14am
Hi,
 
CXTPToolbar doesn't handle TB_SETIMAGELIST message. You need set to imagemanager of CommandBars
 
pCommandBars->GetImageManager()->SetIcons(IDR_BT_TOOLBAR);
or
pCommandBars->GetImageManager()->SetIcons(&m_ToolbarImageList, ...);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 02 April 2009 at 1:54pm
I changed the code to the following and it did not help, still getting toolbar displaying 16bit images from the toolbar resource, but not the 24bit images that I supply in a bitmap file (and make imagelist out of it):
 
BOOL CMyDialog::OnInitDialog()
{
......................
if (!InitCommandBars())
return FALSE;

CXTPCommandBars* pCommandBars = m_pCommandBars;

CXTPToolBar* pToolBar = pCommandBars->Add(_T("Standard"), xtpBarTop);

pToolBar->LoadToolBar(IDR_BT_TOOLBAR);

 
CBitmap bmp;
bmp.LoadBitmap( IDB_BT_TOOLBAR );
m_ToolbarImageList.Create( 16,15,ILC_COLORDDB|ILC_MASK,7,1);
m_ToolbarImageList.Add( &bmp, RGB(255,0,255) );
pCommandBars->GetImageManager()->SetIcons(IDR_BT_TOOLBAR, m_ToolbarImageList); 

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_DISCONNECT, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_MAKEDIR, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_DELETE, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_PUT, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_GET, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_TOGGLE_VIEW, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

((CXTPControlButton*)pToolBar->GetControls()->FindControl(xtpControlButton, ID_BT_SHOW_IMG, TRUE, FALSE))->SetStyle(xtpButtonIconAndCaption);

pToolBar->GetControls()->CreateOriginalControls();

XTPImageManager()->SetIcons(IDR_MAINFRAME);

pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault);

pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipOffice); 

LoadCommandBars(_T("CommandBars"));

RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);

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: 03 April 2009 at 1:01am
Hi,
 
Maybe XTPImageManager()->SetIcons(IDR_MAINFRAME); line override them ?
 
Most easy way is to add line
 
pCommandBars->GetImageManager()->SetIcons(IDR_BT_TOOLBAR, IDB_BT_TOOLBAR);  it will load IDB_BT_TOOLBAR bitmap and willset it for IDR_BT_TOOLBAR icons.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 03 April 2009 at 4:09pm
so is there anybody that can tell me what's wrong with this code? I also tried to call
pToolBar->GetImageManager()->SetIcons(m_ToolbarImageList, buttons, 7, Size(16,15), ...) and
pCommandBars->GetImageManager()->SetIcons(m_ToolbarImageList, buttons, 7, Size(16,15), ...)
 
I also treid to call LoadToolBar before that and adfter that... nothing helps - the toolbar does not show the icons from the image list...
Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 03 April 2009 at 4:19pm
I commented out the following line:
 

//XTPImageManager()->SetIcons(IDR_MAINFRAME);

and also tried your suggestion:

pCommandBars->GetImageManager()->SetIcons(IDR_BT_TOOLBAR, IDB_BT_TOOLBAR);

and also tried:
pToolBar->GetImageManager()->SetIcons(IDR_BT_TOOLBAR, IDB_BT_TOOLBAR);

I also treid to move LoaToolBar before this and after this...
the result is the same... no icons in the toolbar

the only difference between my code and the sample is that my parent is derived from CPropertyPage not from CXTPDialogBase and does not have InitCommandBars so I simply copied the code and pasted InitCommandBars implementation in my dialog class... It shouldn't make the difference - I went through this code and it really does not matter where it is implemented...
 
...getting very frastrated... Help!
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: 06 April 2009 at 11:14am

Hi,

Modify some our sample and attach it here.  Maybe problem with bitmap you have.
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.172 seconds.