Microsoft KB Archive/152376

= HOWTO: How To Disable Push Buttons on a DialogBar in MFC =

Article ID: 152376

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 1.52 Professional Edition</li></ul>

 Microsoft Visual C++ 1.0 Professional Edition</li></ul>

 Microsoft Visual C++ 2.0 Professional Edition</li></ul>

 Microsoft Visual C++ 2.1</li></ul>

 Microsoft Visual C++ 2.2</li></ul>

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q152376

<div class="summary_section">

SUMMARY
Push-button controls on a DialogBar cannot be disabled by calling EnableWindow. The following code has no effect: GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE); This article describes how to implement push-button controls that can be disabled.

<div class="moreinformation_section">

MORE INFORMATION
Controls on a DialogBar behave like the bitmaps on a Toolbar. They can be enabled or disabled by manually adding an ON_UPDATE_COMMAND_UI within the message map of the appropriate class (such as CMainFrame).

Step-by-Step Example
After you have placed a control on your DialogBar, such as a push-button with a resource ID of IDC_BUTTON1, use the following steps to manage the state of the control:

<ol>  Within the declaration of your class, add the declaration for a handler function: afx_msg void OnUpdateButton1(CCmdUI* pCmdUI); </li>  Within the implementation of your class, add a manual entry in the message map: BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) //AFX_MSG_MAP ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateButton1) END_MESSAGE_MAP </li>  Provide the definition of the handler function, as follows: void CMainFrame::OnUpdateButton1(CCmdUI* pCmdUI) {      pCmdUI->Enable( TRUE ); } </li></ol>

Additional query words: 1.00 1.50 1.51 1.52 2.00 2.10 2.20 4.00 4.10

Keywords: kbhowto kbuidesign kbdocview kbmfcctrlbar KB152376

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.