Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Toolbar icons disappear after SetID()
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Toolbar icons disappear after SetID()

 Post Reply Post Reply
Author
Message
Alistair View Drop Down
Newbie
Newbie
Avatar

Joined: 14 May 2004
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alistair Quote  Post ReplyReply Direct Link To This Post Topic: Toolbar icons disappear after SetID()
    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.

 

Back to Top
vladsch View Drop Down
Newbie
Newbie


Joined: 04 February 2004
Location: Canada
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote vladsch Quote  Post ReplyReply Direct Link To This Post 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,
Back to Top
Alistair View Drop Down
Newbie
Newbie
Avatar

Joined: 14 May 2004
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alistair Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2004 at 6:00am

Just the job. Thanks.

--- Al.

 

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.125 seconds.