Microsoft KB Archive/241850

From BetaArchive Wiki

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
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++ 6.0 Standard Edition
    • Microsoft Visual C++ .NET 2002 Standard Edition
    • Microsoft Visual C++ .NET 2003 Standard Edition
    • 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


Keywords: kbtoolbar kbcmnctrls kbprb kbdlg KB241850