Print Page | Close Window

CXTPControl -> SetEnable issue

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=10383
Printed Date: 26 June 2024 at 7:14am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPControl -> SetEnable issue
Posted By: apple
Subject: CXTPControl -> SetEnable issue
Date Posted: 28 April 2008 at 8:23am
Hi:
   Please see following code:
 
   CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
   CXTPCommandBars* pCommandBars = pMainFrame->GetCommandBars();
   CXTPControl  * button= pCommandBars->FindControl(xtpControlButton,ID_MYID,true,true);
   button->SetEnabled(false);
 
   *ID_MYID: user_defined resource ID.
 
 I try many ways, SetEnable seems as if  out of work . i dont know why?
      
need your help, thx a lot.



Replies:
Posted By: Oleg
Date Posted: 28 April 2008 at 8:57am

Hi,

Because by default used MFC Update handlers - and your button will be Enabled in Handler.
As solution you can add line button->SetFlags(xtpFalgManualUpdate);
but I _very_ recommend use update handler instead.


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


Posted By: apple
Date Posted: 28 April 2008 at 9:44pm
Hi,Oleg:
    How can i use update handler? Can you tell me in details about that?
thx in advance. :-)


Posted By: Oleg
Date Posted: 29 April 2008 at 12:42am
Hi,
In Message Map add
 
ON_UPDATE_COMMAND_UI(ID_MYID, OnUpdateMyID)
 
and such code
 

void CMainFrame::OnUpdateMyID(CCmdUI* pCmdUI)
{
 pCmdUI->Enable(m_bNeedEnableMyID);
}
 
 
See more in MSDN.


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