Click here to Skip to main content
16,006,749 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: What is the difference between the dialog types available in resource editor? Pin
John Aspras8-Apr-02 21:36
John Aspras8-Apr-02 21:36 
GeneralProblem with LIKE from MFC Pin
8-Apr-02 19:31
suss8-Apr-02 19:31 
GeneralRe: Problem with LIKE from MFC Pin
Derek Waters8-Apr-02 19:35
Derek Waters8-Apr-02 19:35 
GeneralRe: Problem with LIKE from MFC Pin
Lakitu8-Apr-02 23:27
Lakitu8-Apr-02 23:27 
GeneralEnable/Disable Toolbar *Buttons* :: MFC Pin
valikac8-Apr-02 19:18
valikac8-Apr-02 19:18 
GeneralRe: Enable/Disable Toolbar *Buttons* :: MFC Pin
Derek Waters8-Apr-02 19:31
Derek Waters8-Apr-02 19:31 
GeneralRe: Enable/Disable Toolbar *Buttons* :: MFC Pin
valikac8-Apr-02 19:42
valikac8-Apr-02 19:42 
GeneralRe: Enable/Disable Toolbar *Buttons* :: MFC Pin
Derek Waters8-Apr-02 19:49
Derek Waters8-Apr-02 19:49 
Well, you can put your command handler anywhere that message are received. The best place to put them in this case would probably be the CFrameWnd-derived class where you create the toolbar. The same class would also have a handler for the menu item. For example, if the menu item is ID_ALLOW_BUTTON and the button itself is ID_MY_BUTTON:

In the header:
bool   m_bButtonAllowed;

afx_msg void OnAllowButtonMenu();
afx_msg void OnUpdateMyButton(CCmdUI *pCmdUI);
afx_msg void OnMyButton();

In your constructor:
m_bButtonAllowed = false;

In the message map:
ON_COMMAND(ID_ALLOW_BUTTON, OnAllowButtonMenu)
ON_UPDATE_COMMAND_UI(ID_MY_BUTTON, OnUpdateMyButton)
ON_COMMAND(ID_MY_BUTTON, OnMyButton)


Then:
CMainFrame::OnAllowButtonMenu()
{
  m_bButtonAllowed = true;
}

CMainFrame::OnUpdateMyButton(CCmdUI *pCmdUI)
{
  pCmdUI->Enable(m_bButtonAllowed ? 1 : 0);
}

CMainFrame::OnMyButton()
{
  AfxMessageBox("Got me!");
}


Hope this helps.

------------------------
Derek Waters
derek@lj-oz.com
GeneralRe: Enable/Disable Toolbar *Buttons* :: MFC Pin
valikac8-Apr-02 20:14
valikac8-Apr-02 20:14 
GeneralRe: Enable/Disable Toolbar *Buttons* :: MFC Pin
Derek Waters8-Apr-02 20:22
Derek Waters8-Apr-02 20:22 
GeneralRe: Enable/Disable Toolbar *Buttons* :: MFC Pin
valikac8-Apr-02 20:28
valikac8-Apr-02 20:28 
GeneralBooks on printing Pin
8-Apr-02 18:30
suss8-Apr-02 18:30 
GeneralRe: Books on printing Pin
Rick Crone9-Apr-02 7:00
Rick Crone9-Apr-02 7:00 
QuestionCan I receive notify message when using connectless UDP Sockets? Pin
Cloudway8-Apr-02 16:49
Cloudway8-Apr-02 16:49 
AnswerRe: Can I receive notify message when using connectless UDP Sockets? Pin
Jon Hulatt8-Apr-02 21:50
Jon Hulatt8-Apr-02 21:50 
GeneralRe: Can I receive notify message when using connectless UDP Sockets? Pin
Jon Hulatt8-Apr-02 21:51
Jon Hulatt8-Apr-02 21:51 
QuestionHow can I get the key code immediately after pressing a key in a DOS-like console program ? Pin
Cloudway8-Apr-02 16:37
Cloudway8-Apr-02 16:37 
AnswerRe: How can I get the key code immediately after pressing a key in a DOS-like console program ? Pin
Christian Graus8-Apr-02 16:51
protectorChristian Graus8-Apr-02 16:51 
GeneralRe: How can I get the key code immediately after pressing a key in a DOS-like console program ? Pin
Cloudway8-Apr-02 17:10
Cloudway8-Apr-02 17:10 
QuestionMay I remote to access a file? Pin
xelin8-Apr-02 15:28
xelin8-Apr-02 15:28 
AnswerRe: May I remote to access a file? Pin
Paul M Watt8-Apr-02 17:24
mentorPaul M Watt8-Apr-02 17:24 
GeneralRe: May I remote to access a file? Pin
xelin8-Apr-02 19:18
xelin8-Apr-02 19:18 
QuestionITextRange or Tom.h??? Pin
Dave_8-Apr-02 14:16
Dave_8-Apr-02 14:16 
AnswerRe: ITextRange or Tom.h??? Pin
Christian Graus8-Apr-02 16:21
protectorChristian Graus8-Apr-02 16:21 
GeneralRe: ITextRange or Tom.h??? Pin
9-Apr-02 2:37
suss9-Apr-02 2:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.