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 » CExtGridWnd BestRowFit Collapse All
Subject Author Date
Adam Keadey Sep 7, 2007 - 3:30 AM

I’m trying to use best row fit for images and it is not working.
I assume I have not turned on a style or something.
Code following:

bool bRedraw = false;

    //m_pDataProvider = NULL;
    OuterRowCountTopSet( 1L, bRedraw );
    OuterColumnCountLeftSet( 1L, bRedraw );
    OuterColumnCountRightSet( 1L, bRedraw );
    OuterColumnWidthSet( true, 0L, 14 );
    OuterColumnWidthSet( false, 0L, 14 );

    NoHideSelectionSet( true, bRedraw );
    SubtractSelectionAreasSet( true, bRedraw );
    LbExtSelectionSet( true );
    GridLinesHorzSet( true, bRedraw );
    GridLinesVertSet( true, bRedraw );
    HoverEventsSet( true, true );
    MultiAreaSelectionSet( true );
    HoverHighlightSet( true, false, false, false, true, true );

    BseModifyStyleEx(__EGBS_DYNAMIC_RESIZING|__EGBS_RESIZING_CELLS_INNER, __EGBS_FIXED_SIZE_ROWS);

    //clear the grid
    ClearGrid();

    //insert the columns
    ColumnAdd(2);

    //add the data
    pHeaderData =
        STATIC_DOWNCAST(
            CExtGridCellHeader,
            GridCellGetOuterAtTop(
                0,
                0L,
                RUNTIME_CLASS(CExtGridCellHeader)
                )
            );
    pHeaderData->TextSet( "Data" );
    pHeaderData->ExtentPercentSet(50);
    pHeaderData->ExtentSet(200);

    //add the value
    pHeaderValue =
        STATIC_DOWNCAST(
            CExtGridCellHeader,
            GridCellGetOuterAtTop(
                1,
                0L,
                RUNTIME_CLASS(CExtGridCellHeader)
                )
            );
    pHeaderValue->TextSet( "Value" );
    pHeaderValue->ExtentPercentSet(50);
    pHeaderValue->ExtentSet(200);

    ////insert the rows
    RowAdd(1);

    CExtBitmap bitmap;
    bitmap.LoadBMP_File("res\\Acropolis.bmp", true);
    bitmap.AlphaColor(RGB(0,128,128), RGB(0,0,0), 0);
        CExtGridCellPicture * pCellDesc =
            STATIC_DOWNCAST(
                CExtGridCellPicture,
                GridCellGet(
                    0L,
                    0,
                    0,
                    0,
                    RUNTIME_CLASS(CExtGridCellPicture)
                    )
                );
        pCellDesc->BitmapSet(&bitmap);
        this->BestFitRow(0);

Technical Support Sep 18, 2007 - 11:34 AM

You can send it to support@prof-uis.com.

Suhai Gyorgy Sep 7, 2007 - 5:28 AM

I’ve met this problem not so long ago. It turned out that the problem is caused by the fact that each row has a maximum height set by default, and this max height is a regular single line. So the solution was that I had to call ExtentSet(200, 1); for each row header when initializing. The value 200 is just a made-up value, I guess it could work with any other big enough value.

Adam Keadey Sep 7, 2007 - 5:38 AM

That did not work. I tried setting it on all rows and columns including the header

Suhai Gyorgy Sep 7, 2007 - 6:14 AM

Ok, just to make sure I understood you: Did you try this code?

pHeaderValue =
        STATIC_DOWNCAST(
            CExtGridCellHeader,
            GridCellGetOuterAtLeft(
                0,
                0L,
                RUNTIME_CLASS(CExtGridCellHeader)
                )
            );
pHeaderValue->ExtentSet(200, 1);
 
pHeaderValue =
        STATIC_DOWNCAST(
            CExtGridCellHeader,
            GridCellGetOuterAtRight(
                0,
                0L,
                RUNTIME_CLASS(CExtGridCellHeader)
                )
            );
pHeaderValue->ExtentSet(200, 1);
I think (not definitely sure though) that in your case your need to set both left and right header cells, as these cells store the extent of the row.

Adam Keadey Sep 7, 2007 - 8:13 AM

To simplify I just set it to one column and still had the problem even making the call of pHeaderValue->ExtentSet(200, 1)

Suhai Gyorgy Sep 7, 2007 - 12:55 PM

I made a sample app, only a dialog with one single grid on it. In its OnInitDialog I placed your code (just needed to add the grid variable for the grid-calls), together with my proposed addition. The bmp I used was 32x32 in size. The row height was adjusted properly. Please check your code to this one:

    // your code above, all the same till RowAdd call
    ////insert the rows
    m_wndGrid.RowAdd(1);

	pHeaderValue =
        STATIC_DOWNCAST(
            CExtGridCellHeader,
            m_wndGrid.GridCellGetOuterAtLeft(
                0,
                0L,
                RUNTIME_CLASS(CExtGridCellHeader)
                )
            );
	pHeaderValue->ExtentSet(200, 1);
 
    CExtBitmap bitmap;
    bitmap.LoadBMP_File(_T("res\\tools.bmp"), true);
    bitmap.AlphaColor(RGB(0,128,128), RGB(0,0,0), 0);
        CExtGridCellPicture * pCellDesc =
            STATIC_DOWNCAST(
                CExtGridCellPicture,
                m_wndGrid.GridCellGet(
                    0L,
                    0,
                    0,
                    0,
                    RUNTIME_CLASS(CExtGridCellPicture)
                    )
                );
        pCellDesc->BitmapSet(&bitmap);
        m_wndGrid.BestFitRow(0);

Adam Keadey Sep 18, 2007 - 9:28 AM

Can I post my code somewhere to have it looked at?