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 » ReportGrid: Group by CExtGridCellPictureRef-column Collapse All
Subject Author Date
Suhai Gyorgy Jul 24, 2007 - 8:53 AM

Dear Support,

In our readonly ReportGrid we have a column which shows Male/Female data as little icons. I used 2 CExtBitmap objects as class variables and CExtGridCellPictureRef cells, for which I set one of these CExtBitmaps with BitmapSetBuffer method. But when the user tries to group by that column, it doesn’t work: every line is grouped as a one-item group, as if every CExtGridCellPictureRef cell had different values.

I need to keep this column "groupable". Please, advise. Since the cells are of PictureRef class, can’t the reportgrid check if the pointers associated with them are the same (they point to the same CExtBitmap)?

Thank you!

Technical Support Jul 24, 2007 - 11:45 AM

If you look at the CExtGridCellPictureBase::Compare() method, you will see that the two bitmaps are compared by their size. If the they have the same size, the two cells are compared in the CExtGridCell::Compare() virtual method where the comparison is performed using VARIANT data types. The VARIANT variable is created in the CExtGridCellPictureBase::GetVariant() virtual method. We would not recommend you change this algorithm. Instead you could create a CExtGridCellPictureRef-derived cell where, in the overridden Compare() virtual method, you could perform your custom comparison using the bitmap pointers.

Suhai Gyorgy Jul 24, 2007 - 11:54 AM

True, I didn’t step into the code to check why it doesn’t work, but reading your post it seems to me that grouping should work without me having to create any derived classes or override any method. Comparing the pointers was just a suggestion, and I agree with you, I’d prefer not changing your algorithm. Shall I try making a sample application showing the problem?

Suhai Gyorgy Jul 25, 2007 - 3:39 AM

Ok, I made a sample application (actually just added a dialog to your ThemeColorizer sample, but the dialog itself is really what demonstrates the problem. Downloadable from here) A reportgrid occupies the dialog, in the grid I added 2 columns and 10 lines. First column is CExtGridCellPictureRef-column, second is just a simple CExtGridCellString. The same way as in my own application, I added 2 CExtBitmap objects to the dialog class and one by one, the cells of the first column got associated with one of those 2 pictures using BitmapSetBuffer. Second column was filled with unique strings.

When trying to sort by the first column, the result is not as should be, lines seem to be sorted randomly. And this time I stepped through your code, and as you wrote in your last post, it all boils down to CExtGridCellPictureBase::GetVariant() method. It is called twice from CExtGridCell::Compare(), once for each cell being compared. When those 2 cells have the same picture associated with them, BitmapGetBuffer() inside GetVariant() returns the very same pointer, but the created VARIANT variables still differ!! I think this is a bug, the created VARIANT should be the same!

I’m using ProfUIS v2.64.1 with VS2003 in Static Unicode Debug configuration. If a newer version has an improved CExtGridCellPictureBase::GetVariant(), please, let me know. Thank you!

Technical Support Jul 25, 2007 - 1:30 PM

We have no chance to compare pictures universally. Even if we could compare the content of picture surfaces using some AI algorithms, the pictures would be definitively equal or unequal to each other but not greater or less. In your project, we would not recommend to use CExtGridCellPictureBase-based classes at all. Instead you could register two icons in the report grid window using the CExtGridWnd::GridIconInsert() method and use these icons in the CExtGridCell/CExtGridCellComboBox/CExtGridCellCheckBox objects using the CExtGridCell::IconIndexSet() method. The combo box cell could display Male/Female strings in the popup list box. The check box cell could display the male/female status in the check box.

Suhai Gyorgy Jul 26, 2007 - 4:23 AM

Sorry, last post went to the wrong thread!

I will go for this icon-solution, situation is even easier in our case as the grid is readonly.

Suhai Gyorgy Jul 26, 2007 - 4:21 AM

Renaming works great now, thank you!