![]() |
24bit toolbar in the dialog |
Post Reply ![]() |
Author | |
securigy ![]() Groupie ![]() Joined: 23 November 2007 Status: Offline Points: 41 |
![]() ![]() ![]() ![]() ![]() 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); |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
securigy ![]() Groupie ![]() Joined: 23 November 2007 Status: Offline Points: 41 |
![]() ![]() ![]() ![]() ![]() |
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); |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
securigy ![]() Groupie ![]() Joined: 23 November 2007 Status: Offline Points: 41 |
![]() ![]() ![]() ![]() ![]() |
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...
|
|
![]() |
|
securigy ![]() Groupie ![]() Joined: 23 November 2007 Status: Offline Points: 41 |
![]() ![]() ![]() ![]() ![]() |
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!
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi, Modify some our sample and attach it here. Maybe problem with bitmap you have.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |