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 General Discussion » CExtPropertyGrid questions Collapse All
Subject Author Date
Torsten Ihben Aug 26, 2005 - 3:41 AM

Hi!

First of all, your toolkit is great, but the help is quite useless :-(

When designing a program using Prof-UIS we encountered various problems that couldn’t be solved with the help of samples and the help. I’m new to Prof-UIS and not so good at MFC programming.

1. Is it possible to format categories? With formating I mean changing the color of the background of either the entire category or just the category header, or changing the font or font style of the category header.

2. When using a CExtGridCellBool changing the value to something different than true or false is not allowed. How can I modify a CExtGridCellComboBox that the user can only enter values that are given in the ComboBox? It would be even better if the user could enter some text in the inplace editor, and then the nearest matching entry is selected.

An example: I have three entries in the ComboBox: test, text and hurz. When the user selects the combo box and presses h the value hurz should be selected. When the user enters the nothing should be selected since it’s not unique, but as soon as he presses s test should be selected. If he enters something not inside the combo box either nothing (empty value) or the default value should be selected. Is this possible?

An additional remark for combo boxes: Normally you can open the combo box drop down list by either pressing F4 or Alt+cursor down. Prof-UIS only supports F4. Perhaps you should implement Alt+down too.

3. Can you explain what happens when the user switches from the category view to the alphabetic view? There are two classes derived from CExtPropertyGridWnd: CExtPropertyGridWndSorted and CExtPropertyGridWndCategorized, this sounds to me that the program somehow switches between those two classes - but how?

I hope you can help me with these questions. From what I have seen so far the tech support is really good.

Regards,
Torsten Ihben

Technical Support Aug 27, 2005 - 7:56 AM

Thank you for the interesting questions. The CExtPropertyGridCtrl class is designed as a container for several windows which implement parts of the entire property grid control. There are two grid windows that display properties: the CExtPropertyGridWndCategorized and CExtPropertyGridWndSorted classes. Each of these classes is kind of the CExtGridWnd class, which implements a generic grid window and manages an array of the CExtGridCell objects which implement particular cells in the grid. The CExtPropertyGridCellArea class implements a cell object that is used for displaying either a category or a value name in the first column of the grid window. You can create a CExtPropertyGridCellArea-derived class and implement OnQueryCellFont(), OnQueryTextColor(), and OnPaintBackground() virtual methods in it. This will allow you to give a custom look to the property category names. To use your "name" cell type in the categorized property grid, create your own CExtPropertyGridWndCategorized-derived class and override the CExtPropertyGridWnd::PropertyItemInsert() method. Your version of this method should be the same as the original one except for specifying the runtime class of your "name" cell when invoking the ItemGetCell() method which instantiates a new cell object inside the grid window of required cell type on-the-fly. To make the property grid control use your categorized tree grid window, please override the OnPgcCreateGrids() virtual method in your CExtPropertyGridCtrl-derived class. This method should also be the same as the original method except it should create your categorized grid window instead of the default instance of the CExtPropertyGridWndCategorized class.

Switching between the CExtPropertyGridWndCategorized and CExtPropertyGridWndSorted windows in the CExtPropertyGridCtrl window is implemented as hiding one grid window and showing another one. Each grid window must have its unique dialog control identifier. These two grid windows are created by default in the property grid control and they have dialog control identifiers equal to the __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED and __EXT_MFC_ID_PROPERTY_GRID_SORTED pre-defined constants. The CExtPropertyGridToolBar window has two buttons with the same command identifier values. The CExtPropertyGridCtrl window treats these commands as active grid selection commands. The code for analyzing command identifiers and toggling grid visibility is implemented in the CExtPropertyGridCtrl::OnPgcProcessChildWindowCommand() method. In fact you can create any number of CExtPropertyGridWnd-derived classes in the property grid control and add their corresponding toolbar buttons to the CExtPropertyGridToolBar window. The property grid control automatically switches the active grid window.

Yes, the CExtGridCellBool class can have the same values as the bool type in C++ and you really need to use the CExtGridCellComboBox class instead. The CExtGridCellComboBox class supports the enumeration mode which can be turned on/of with the CExtGridCellComboBox::SetEnumMode() method. When the enumeration mode is turned on, you can double click the in-place active cell editor to switch the cell value to the next value in the pop-up list box. We agree that we need to make this cell in the enumeration mode automatically apply the nearest possible value and disable entering custom strings. It is also not a problem to add support for Alt+Down Arrow key press event support in addition to the currently implemented F4.





Torsten Ihben Aug 29, 2005 - 7:05 AM

Hi!

Now I had time to look after the last answer. What do you mean with "We agree that we need to make..."? Do you plan to implement this feature for future releases? If yes, when do you plan a release with this change? If not, can you explain how I can perform this change on my own?

I have the same question regarding the Alt+Down arrow key support. Do you plan to implement this in a future release? I found the relevant part in the code, but I don’t know how I can switch for the Alt+Down key combination - VK_F4 is easy, because this is exactly one key. What is the wParam for Alt+Down?

In the current version is it possible to use the GridCellComboBox with disabled inplace editor but with enabled Enum Mode, i.e. double-clicking switches the cell value?

Regards,
Torsten Ihben

Technical Support Aug 29, 2005 - 10:42 AM

Yes, we will try to add the Alt+Down key support and modify the enum mode in the next minor or major release.

You can set a read-only mode for the in-place editor. Just override the CExtGridWnd::OnGridCellInplaceControlQueryStyle virtual method in the derived grid class or CExtGridCell::OnInplaceControlQueryStyle in the derived cell class, and then set the bReadOnly property to true:

void CExtGridCellComboBox::OnInplaceControlQueryStyle(
      CExtGridWnd & wndGrid,
      CWnd * pWndInplaceControlToCreate,
      LONG nVisibleColNo,
      LONG nVisibleRowNo,
      LONG nColNo,
      LONG nRowNo,
      INT nColType,
      INT nRowType,
      DWORD dwAreaFlags,
      bool & bReadOnly,
      bool & bPassword,
      COLORREF & clrBack,
      COLORREF & clrText
      )
{
      ASSERT_VALID( this );
      ASSERT_VALID( (&wndGrid) );
      CExtGridCellString::OnInplaceControlQueryStyle(
            wndGrid,
            pWndInplaceControlToCreate,
            nVisibleColNo,
            nVisibleRowNo,
            nColNo,
            nRowNo,
            nColType,
            nRowType,
            dwAreaFlags,
            bReadOnly,
            bPassword,
            clrBack,
            clrText
            );
      bReadOnly = true;
}

Torsten Ihben Aug 29, 2005 - 4:28 AM

Thank you for the fast reply.
Until now I could only try the first answer, changing text color and font of grid cells.

I created a set of derived classes as you proposed, but my classes are used only if they use exactly the same definition than the base class. The two classes derived from CExtPropertyGridWndCategorized and CExtPropertyGridCtrl work fine, but my CExtPropertyGridCellArea-derived class won’t work until I define it as DECLARE_SERIAL. But as soon as I use IMPLEMENT_SERIAL the compiler complains with error C2665: ’CExtGridCell::operator new’ : none of the 2 overloads can convert parameter 2 from type ’const char [61]’ on the line of IMPLEMENT_SERIAL. I don’t understand this error, my class looks exactly as your CExtPropertyGridCtrl class.

Can you help me with this problem?

Regards,
Torsten Ihben

Technical Support Aug 29, 2005 - 10:01 AM

This problem is caused by a conflict of C++ new operators defined locally in the CExtGridCell class. The solution is very easy. Please open the C++ file that implements your CExtPropertyGridCellArea-derived class and move its IMPLEMENT_SERIAL feature to the top of the file before the definition of the debug version of the new operator:

# include "StdAfx.h"

. . .

IMPLEMENT_SERIAL

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

. . .

Torsten Ihben Aug 29, 2005 - 10:10 AM

Thank you for your fast reply! Your solution worked!

Regards,
Torsten Ihben