Call to CToolBarCtrl::Customize does not keep the customization dialog box visible (241850)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Editions 4.0
    • Microsoft Visual C++, 32-bit Editions 4.2
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 4.2
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
    • Microsoft Visual C++ .NET (2002)
    • Microsoft Visual C++ .NET (2003)
    • Microsoft Visual C++ 2005 Express Edition

This article was previously published under Q241850
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.

SYMPTOMS

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

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.

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);
}
				

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new MFC SDI Application using AppWizard and use all of the default settings.
  2. Inside of the CMainFrame::OnCreate() function call, add the following code just prior to the return 0 line:
     m_wndToolBar.GetToolBarCtrl().Customize();
     return 0;
    }
    						
  3. Build and run the application.


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

REFERENCES


Modification Type:MajorLast Reviewed:1/9/2006
Keywords:kbCmnCtrls kbDlg kbprb kbToolbar KB241850 kbAudDeveloper