Print Page | Close Window

Toolbar icons disappear after SetID()

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=732
Printed Date: 24 December 2024 at 10:18pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Toolbar icons disappear after SetID()
Posted By: Alistair
Subject: Toolbar icons disappear after SetID()
Date Posted: 14 May 2004 at 5:22am

I'm currently evaluating XTToolkit Pro.

I'm trying to implement a toolbar with icons and text. Just simple buttons.

It all works fine until I assign a command id to a button so that it will actually do something. When I do that, it no longer shows the icon, just the text!

Here's my code (in CMainFrame::OnCreate())

// Create PC-BaX ToolBar

CXTPToolBar* pToolBar = (CXTPToolBar*)

pCommandBars->Add(_T("PC-BaX Tools"), xtpBarTop);

if ( !pToolBar )

{

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

return -1;

}

// Load the toolbar

if ( !pToolBar->LoadToolBar(IDR_TOOLBAR) )

{

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

return -1;

}

pToolBar->ShowTextBelowIcons() ;

CXTPControl *pControl ;

pControl = pToolBar->GetControl ( 0 ) ;

pControl->SetID ( ID_ACTION_EXECUTIVE ) ; // <-- This stops the icon from being displayed but is the only way I know to assign an action to a button.

pControl->SetCaption ( IDS_EXECUTIVE ) ;

pControl->SetFlags ( pControl->GetFlags() | xtpFlagManualUpdate ) ;

pControl->SetStyle ( xtpButtonIconAndCaption ) ;

pControl->SetEnabled ( TRUE ) ;

/*...*/

// Set Office 2003 Theme

CXTPPaintManager::SetTheme(xtpThemeOffice2003);

Any suggestions?

--- Al.

Ps, how do you change the paragraph settings when posting? I seem to have large spaces between my lines.

 




Replies:
Posted By: vladsch
Date Posted: 17 May 2004 at 7:07pm

You need to associate an icon with the ID with the command bars image manager:

    CXTPCommandBars *pBars = theApp.m_pMainFrame->GetCommandBars(); // get the pointer to command bars
    CXTPImageManager* pImageMgr = pBars->GetImageManager();

    HICON hIcon = getIcon();

    pImageMgr->SetIcon(hIcon, getID());

    ::DestroyIcon(hIcon);

In my case getIcon() returns the icon handle for the current instance of the command and getID() returns the ID of the command, substitute your own code. Image manager makes a copy of the icon so you will need to destroy the icon after the call to SetIcon.



-------------
Vladimir,


Posted By: Alistair
Date Posted: 19 May 2004 at 6:00am

Just the job. Thanks.

--- Al.

 




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