Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtPropertyGrid Collapse All
Subject Author Date
David Skok Sep 4, 2007 - 12:13 PM

I am using a PropertyGrid in my app and do not wish to display a ComboBox or Toolbar and so followed your FAQ regarding not displaying them. I chose to override OnPgcCreateBars() and not create either of these controls. This method does NOT work. It throws an unhandled exception in a call to AfxIsValidAddress inside CExtControlBar::DoCustomModeUpdateControlBars in this line:

hWndUpdateTarget = pWndParentTarget->GetSafeHwnd();.

Just an FYI, I don’t have time to create a small sample proving it.

I’m hiding these windows to do what I want.

Technical Support Sep 4, 2007 - 1:07 PM

We need to reproduce the problem in some way. That is why we asked you to prepare and send a test project. Actually you could also modify our CompoundProperties sample . We added the following method to declaration of the CCanvasPropertyGridCtrl class in this sample:

      bool OnPgcCreateBars()
      {
            ASSERT_VALID( this );
            try
            {
//                CExtPropertyGridComboBoxBar * pComboBoxBar =
//                      new CExtPropertyGridComboBoxBar( this );
//                pComboBoxBar->m_bAutoDeleteWindow = true;
//                if( ! pComboBoxBar->Create(
//                            this,
//                            true
//                            )
//                      )
//                {
//                      ASSERT( FALSE );
//                      throw __EXT_MFC_ID_PROPERTY_GRID_COMBO_BOX;
//                }

                  CExtPropertyGridToolBar * pToolBar =
                        new CExtPropertyGridToolBar( this );
                  pToolBar->m_bAutoDeleteWindow = true;
                  if( ! pToolBar->Create(
                              this,
                              true
                              )
                        )
                  {
                        ASSERT( FALSE );
                        throw __EXT_MFC_ID_PROPERTY_GRID_TOOLBAR;
                  }

                  CExtPropertyGridTipBar * pTipBar =
                        new CExtPropertyGridTipBar( this );
                  pTipBar->m_bAutoDeleteWindow = true;
                  if( ! pTipBar->Create(
                              this,
                              true
                              )
                        )
                  {
                        ASSERT( FALSE );
                        throw __EXT_MFC_ID_PROPERTY_GRID_TIPBAR;
                  }
            }
            catch( ... )
            {
                  return false;
            }
            return true;
      } 
So please try it. This is enough to kill the combo box inside the property grid control but not enough to make the CompoundProperties working. So, we also commented out the following lines in the CMainDlg::OnInitDialog() method:
// CExtPropertyGridComboBoxBar * pCombo =
//          STATIC_DOWNCAST(
//                CExtPropertyGridComboBoxBar,
//                m_PGC.GetChildByRTC(
//                      RUNTIME_CLASS(CExtPropertyGridComboBoxBar)
//                      )
//                );
//    ASSERT_VALID( pCombo );
//    m_PGC.m_PS.Combine( &(m_PGC.m_OC.m_obj1.GetPropertyStore()) );
//    m_PGC.m_PS.Combine( &(m_PGC.m_OC.m_obj2.GetPropertyStore()) );
//    m_PGC.m_PS.Combine( &(m_PGC.m_OC.m_obj3.GetPropertyStore()) );

And we commented the following lines in the same method:

//    pCombo->PropertyStoreInsert( &m_PGC.m_PS );
//    pCombo->PropertyStoreInsert( &(m_PGC.m_OC.m_obj1.GetPropertyStore()) );
//    pCombo->PropertyStoreInsert( &(m_PGC.m_OC.m_obj2.GetPropertyStore()) );
//    pCombo->PropertyStoreInsert( &(m_PGC.m_OC.m_obj3.GetPropertyStore()) );
//    pCombo->SetCurSel( 1 );
//    m_PGC.PropertyStoreSet( &(m_PGC.m_OC.m_obj1.GetPropertyStore()) );
Now you can run the sample application and see the property grid control without the combo box. What we did is:

1) We removed the combo box bar from the property grid control.
2) We removed some references to this combo box bar from the source code of our sample application.



David Skok Sep 5, 2007 - 9:14 AM

I made the mods to the sample and it works however I see a fundamental difference between it and my own code. In the sample, PropertyStores are created in the buttons and persist as long as the app does. In my app I dynamically create stores and I delete them when a new property store is created. I call SetPropertyStore(0) then delete the store. I called SetPropertyStore(0) in the destructor of the PropertyGrid, this was the source of the problem.