Print Page | Close Window

24bit toolbar in the dialog

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=13894
Printed Date: 17 June 2024 at 7:17am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: 24bit toolbar in the dialog
Posted By: securigy
Subject: 24bit toolbar in the dialog
Date 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);

 



Replies:
Posted By: Oleg
Date 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


Posted By: securigy
Date 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);



Posted By: Oleg
Date 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


Posted By: securigy
Date 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...


Posted By: securigy
Date 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!


Posted By: Oleg
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net