Microsoft KB Archive/241850

= Call to CToolBarCtrl::Customize does not keep the customization dialog box visible =

Article ID: 241850

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.2 Professional Edition

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

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

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

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

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

 Microsoft Visual C++ .NET 2002 Standard Edition</li></ul>

 Microsoft Visual C++ .NET 2003 Standard Edition</li></ul>

 Microsoft Visual C++ 2005 Express Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q241850

<div class="notice_section">

Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model.

<div class="symptoms_section">

SYMPTOMS
When you call the CToolBarCtrl::Customize function, the dialog box disappears after it is briefly shown.

<div class="cause_section">

CAUSE
You need to handle the TBN_QUERYINSERT message in the parent window and return TRUE. If you return FALSE or do not handle it, then the customization dialog box is destroyed.

<div class="resolution_section">

RESOLUTION
When you return TRUE for the TBN_QUERYINSERT message, this keeps the customization dialog box visible for the user. Following is the code needed to handle the TBN_QUERYINSERT notification that is sent to the parent window:

LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if (WM_NOTIFY == message) {   NMHDR *lpNMHDR = (LPNMHDR) lParam; switch (lpNMHDR->code) {     case TBN_QUERYINSERT: //Returning FALSE causes customize dialog box to not appear. return TRUE; break; } }

return CFrameWnd::WindowProc(message, wParam, lParam); }

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> <li>Create a new MFC SDI Application using AppWizard and use all of the default settings.</li> <li> Inside of the CMainFrame::OnCreate function call, add the following code just prior to the return 0 line: m_wndToolBar.GetToolBarCtrl.Customize; return 0; }                       </li> <li>Build and run the application.</li></ol>

Notice that the toolbar customization dialog box briefly appears and then disappears when you run the application.

<div class="references_section">