Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - CXTPControl -> SetEnable issue
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPControl -> SetEnable issue

 Post Reply Post Reply
Author
Message
apple View Drop Down
Newbie
Newbie


Joined: 28 April 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote apple Quote  Post ReplyReply Direct Link To This Post Topic: CXTPControl -> SetEnable issue
    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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
apple View Drop Down
Newbie
Newbie


Joined: 28 April 2008
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote apple Quote  Post ReplyReply Direct Link To This Post 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. :-)
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
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.172 seconds.