Print Page | Close Window

Checking Toolbar Items

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=830
Printed Date: 25 December 2024 at 8:56am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Checking Toolbar Items
Posted By: VeRtEX
Subject: Checking Toolbar Items
Date Posted: 12 June 2004 at 8:03am

Hi,

How can i check items of an CXTPToolBar? Using the standard mfc toolbar it worked like this:

CToolBarCtrl& ctrl  = mToolBar.GetToolBarCtrl();
ctrl.CheckButton(....);

But i don't see any fimilar function, can anyone help?

Cheers




Replies:
Posted By: msamocha
Date Posted: 15 June 2004 at 4:06am

Hi,

I would also like to know how can we Add / Delete / Modify menus/submenus (similar to MFC's CMenu InsertMenu, DeleteMenu and ModifyMenu)

Vertex, Did you try to use GetControl()to get a pointer to the control and then use some of the CXTPControl methods to do what you want?



Posted By: VeRtEX
Date Posted: 15 June 2004 at 11:47am

how exactly?

CXTPControl* button = mToolbar->GetControls()->FindControl(xtpControlButton, ID_TOOLBAR_WIREFRAME, true, true);


i tried that...but crashed....i want to get the control by mfc id

do you know how i can do that?



Posted By: Oleg
Date Posted: 18 June 2004 at 2:42am
To check item you must use update hanler. see FAQ.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: VeRtEX
Date Posted: 18 June 2004 at 9:08am

okay thank you for your help.

i now got it working with:

mToolbar->GetControls()->FindControl(xtpControlButton, ID_TOOLBAR_WIREFRAME, true, true)->SetChecked(app->mShowWireFrame);

i now tried the same to get a control from the menu bar... but doesn't work so i tried another approach:


void CModelViewer2App::UpdateMenuItem(const int id, const bool check)
{
 CMainFrame* mainFrm = (CMainFrame*)GetMainWnd();
 if (mainFrm)
 {
  CXTPControls* controls = mainFrm->mMenuBar.GetControls();
  const int numControls = controls->GetCount();
  LOG("numControls=%i", numControls);
  for (int i=0; i<numControls; i++)
  {
   CXTPControl* control = controls->GetAt(i);

   if (!control)
    break;

   if(control->GetID()==id)
    LOG("found");
  }
}

but my menu has 0 controls...that is a bit strange ;) does anybody of you know how i can get access to my menu items on another way to check / uncheck them?



Posted By: Oleg
Date Posted: 21 June 2004 at 1:42am

Did you try to open FAQ? think no.

sample:

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
       ON_UPDATE_COMMAND_UI(ID_PROPERTIES, OnUpdateProperties)

 END_MESSAGE_MAP()

void CMainFrame::OnUpdateProperties(CCmdUI* pCmdUI)
{
 pCmdUI->SetCheck(TRUE);

}



-------------
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