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 » CExtPropertyValue / CExtGridCellComboBox question Collapse All
Subject Author Date
Krustys Donuts Jul 12, 2005 - 7:22 PM

Hi, I’m following the latest example for the property grid control. I now have the in place combobox working to the point that it displays the strings that I’d like displayed. Now I have two questions:

1. How can I make this combobox a droplist (i.e. not editable) instead? I assume it’s a window style, so perhaps I need to subclass CExtGridCellComboBox (and thus also use the IMPLEMENT_ExtGridCell_Clone macro) and then set the window style upon creation. Can you please confirm this?

2. Currently, I have four strings in the in place combobox. For starters, I just want to display a MessageBox anytime a user selects a string. I’ve put the code in Apply(), just like the example. However, this method gets called as soon as I click on the dropdown arrow, which seems a little weird to me since I haven’t actually selected anything yet. Also, as long as I select an item from the droplist, everything is basically ok (except that the messagebox is obscured by the droplist). However, if I type in the edit box and then set the focus elsewhere, my application crashes.

Thanks again,
Dave

Krustys Donuts Jul 18, 2005 - 11:25 AM

I have another question regarding the property grid control. I have something that looks like this:

MyStore <-- comboboxbar

+ Field 1 <-- category
  Source    | Database |v|| <-- property value, combobox 


When the user selects something in the source combobox (database or file), I would like a different set of properties to appear below Source, like this:

For database case:
+ Field 1
  Source    | Database |v||
    Query    | <enter sql query here> |

For file case:
+ Field 1
  Source    | File          |v||
    Filename    | <enter filename nere> |


Here are my questions related to this:
1. I assume that I can’t actually add query / filename below source, since there’s an ASSERT( FALSE) in CExtPropertyItem::ItemInsert(), so...
2. I worked around this by creating an "Attributes" category, and then putting query / filename inside of this category, and then inserted the category into Field 1. The problem here is that I can’t get "Attributes" to appear *after* Source, so now my property grid control looks like this:

+ Field 1
  + Attributes
    Source    | Database |v||


instead of this:

+ Field 1
  Source    | Database |v||
  + Attributes


I’ve looked at the property grid sample, and it seems to be able to do what I want, but I can’t pinpoint how you actually accomplish this. Any info would be really appreciated! Thanks!

Technical Support Jul 18, 2005 - 1:45 PM

What you need is automatically supported by the property grid control. The CExtPropertyGridComboBoxBar class is part of the CExtPropertyGridCtrl component. The combo box bar keeps a collection of property stores and displays content of the selected property store in the property grid control. This bar in the PropertyGrid sample application contains one property store for each star button on the main dialog window and two combined property stores. The combined property store is a result of the operation called property tree combining. This operation is performed by the CExtPropertyItem::Combine() method and allows you to see properties of several stores in a new combined property store. The similar property value with different CExtGridCell values are displayed as empty/undefined values in the property grid control. Editing an undefined property value changes property values in all the property stores used in the property tree combining operation. The combined property store is a separate CExtPropertyStore instance. To create a combined property store, call its Combine() method.

The CMainDlg::_CombineMixedStoreAll() and CMainDlg::_CombineMixedStoreSelection() methods in the PropertyGrid sample application demonstrates how to combine property stores. The following code snippet in the CMainDlg::OnInitDialog() method shows how to get a pointer to the combo box bar and initialize its content:

CExtPropertyGridComboBoxBar * pCombo =
    STATIC_DOWNCAST(
        CExtPropertyGridComboBoxBar,
            m_PGC.GetChildByRTC(
            RUNTIME_CLASS(CExtPropertyGridComboBoxBar)
            )
        );
 ASSERT_VALID( pCombo );
 pCombo->PropertyStoreInsert( &m_PropertyStoreCompoundSelection );
 pCombo->PropertyStoreInsert( &m_PropertyStoreAll );
 pCombo->PropertyStoreInsert( m_Btn1.GetPropertyStore() );
 pCombo->PropertyStoreInsert( m_Btn2.GetPropertyStore() );
 pCombo->PropertyStoreInsert( m_Btn3.GetPropertyStore() );
 pCombo->PropertyStoreInsert( m_Btn4.GetPropertyStore() );
Please note that the CExtPropertyGridComboBoxBar class does not delete inserted property store objects.

Technical Support Jul 13, 2005 - 10:05 AM

To make any CExtGridCell object (including CExtGridCellComboBox) non-editable, just apply the __EGCS_READ_ONLY cell style to make the in-place editor control read-only. You can apply the __EGCS_NO_INPLACE_CONTROL cell style to disable activation of the in-place editor control at all. You can change the style of the grid cell object by using the ModifyStyle() method of the grid cell objects used in property values.

To catch the selection change event, create a CExtGridCellComboBox-derived class and override the CExtGridCell::OnPopupListBoxSelEndOK() virtual method which should return the value from parent method and perform your custom actions. You can invoke the wndListBox.GetCurSel() code to get the finally selected item’s index in the pop-up list box.

Krustys Donuts Jul 18, 2005 - 8:53 AM

Hi, I think I need to clarify what I was asking for earlier. I’m not interested in making an inplace combobox readonly, actually. I want to just make sure that the user can only select items that I’ve explicitly added to the list (i.e. dropLIST). The default mode is dropdown, which allows a user to type text into the inplace combobox. Is it possible to get droplist functionality? I couldn’t find any style modifiers for this.

Technical Support Jul 18, 2005 - 1:22 PM

You can apply the __EGCS_NO_INPLACE_CONTROL style to any grid cell object by using its CExtGridCell::ModifyStyle() method. Such a grid cell, which shows pop-up list box by clicking its drop-down button, will behave as drop-down-list combo box control. You should apply the __EGCS_NO_INPLACE_CONTROL style to the cell objects used inside property values.

Krustys Donuts Jul 18, 2005 - 2:29 PM

That seems to work okay, however, I’d like it to be more like standard droplist comboboxes, where clicking on the blank area itself (and not just the dropdown arrow) will cause the list to appear. Can this be added?

Technical Support Jul 19, 2005 - 8:19 AM

In this case, your should create and use your own grid cell class which can be derived from CExtGridCell or any other grid cell class available in Prof-UIS. Here it is the basic implementation of the drop-down-list grid cell class:

class C_YOUR_GridCell : public BASE_CELL_CLASS
{
public:
    DECLARE_SERIAL( C_YOUR_GridCell );
    IMPLEMENT_ExtGridCell_Clone( C_YOUR_GridCell, BASE_CELL_CLASS );
    C_YOUR_GridCell(
        CExtGridDataProvider * pDataProvider = NULL
        )
        : BASE_CELL_CLASS( pDataProvider )
    {
        ModifyStyle( __EGCS_BUTTON_DROPDOWN, 0L );
    }
    bool OnClick(
        CExtGridWnd & wndGrid,
        const CExtGridHitTestInfo & htInfo,
        UINT nChar,   // VK_LBUTTON,
                      // VK_RBUTTON or VK_MBUTTON only
        UINT nRepCnt, // 0 - button up,
                      // 1 - single click
                      // 2 - double click
                      // 3 - post single click(begin edit)
        UINT nFlags   // mouse event flags
        )
    {
        bool bRetVal =
            BASE_CELL_CLASS::OnClick(
                wndGrid,
                htInfo,
                nChar,
                nRepCnt,
                nFlags
                );
        if( nRepCnt != 0 )
            return bRetVal;
        if( (htInfo&__EGBWA_CELL_BUTTON) != 0 )
            return bRetVal;
        TrackCellStateInfo_t _tcsi(
            (*this),
            wndGrid,
            INT(CExtGridCell::__EBTT_DROPDOWN),
            htInfo.m_rcExtra,
            htInfo.m_rcItem,
            htInfo.m_nVisibleColNo,
            htInfo.m_nVisibleRowNo,
            htInfo.m_nColNo,
            htInfo.m_nRowNo,
            htInfo.GetInnerOuterTypeOfColumn(),
            htInfo.GetInnerOuterTypeOfRow()
            );
        OnButtonPopupMenuTrack( _tcsi );
        return true;
    }
} // class C_YOUR_GridCell

IMPLEMENT_SERIAL(
    C_YOUR_GridCell,
    BASE_CELL_CLASS,
    VERSIONABLE_SCHEMA|1
    );
If your cell class contains some specific data properties, then you will need to override the CExtGridCell::Serialize(), CExtGridCell::Assign(), CExtGridCell::Compare(), CExtGridCell::TextGet(), CExtGridCell::TextSet() and CExtGridCell::GetVariant() methods. You can use the CExtGridCellBool class as a sample in this case.