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 » Create a swapping image in the grid control Collapse All
Subject Author Date
Douglas Hoppes Apr 14, 2009 - 2:11 PM

Hi all,

Is there a way to create a swappable image in a grid cell? In the grid cell, I would like to have an Eye icon showing. When the user clicks on the image, a blank image will be shown. The primary example of this is like Photoshop (or any other graphics tool). When the user clicks on the Eye Icon in their list, the image is hidden. If the blank area is clicked on, the image is shown and the Eye icon is displayed again.

Doug

Douglas Hoppes Apr 15, 2009 - 12:09 PM

Thanks for the response. The look/feel is exactly what I was looking for. However, I’m running into an issue with it.

In our core library, I have a special class called CGridControl. This is a wrapper class surrounding all of the Prof-UI grid functionality. In this library goes the CExtGridCellCheckBoxEye.

Now, my application links to this core library, I always get the compile error: "syntax error : identifier ’pMalloc’" in my application (The core library builds fine.... no errors). This is caused by the

IMPLEMENT_ExtGridCell_Clone( CExtGridCellCheckBoxEye, CExtGridCellCheckBox );

How can I get rid of this error?

Doug

Technical Support Apr 16, 2009 - 1:51 PM

You inserted declaration of the CExtGridCellCheckBoxEye class into some .h file in your project. The next step is to insert the following line of code into some .cpp file:

IMPLEMENT_SERIAL( CExtGridCellCheckBoxEye, CExtGridCellCheckBox, VERSIONABLE_SCHEMA|1 );
This line should be inserted at the very beginning of the code file and before declaration of the debug new operator:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

Douglas Hoppes Apr 17, 2009 - 8:20 AM

I already had. From the zip file, I had split the code from the .h to the .h/.cpp.

So, my .h looks like:
---------------------------------------------------------------------------------
class CExtGridCellCheckBoxEye : public CExtGridCellCheckBox
{
public:
    DECLARE_SERIAL(CExtGridCellCheckBoxEye);
    IMPLEMENT_ExtGridCell_Clone(CExtGridCellCheckBoxEye, CExtGridCellCheckBox);
    CExtSafeString m_arrStrings[3]; // 0 - unchecked, 1 - checked, 2 - indeterminate
    mutable CExtCmdIcon m_arrIcons[3]; // 0 - unchecked, 1 - checked, 2 - indeterminate
    CExtGridCellCheckBoxEye(CExtGridDataProvider *pDataProvider = NULL);
    virtual __EXT_MFC_SAFE_LPCTSTR GetTextBuffer() const;
protected:
    INT _GetTextAndCheckMarkIconIndex() const;
public:
    virtual void TextGet( CExtSafeString & strCopy ) const;
    virtual void Assign( const CExtGridCell & other );
    virtual void Serialize( CArchive & ar );
    virtual CSize OnCalcCheckSize(
        bool bPressed,
        bool bHovered,
        bool bEnabled,
        const CExtGridWnd & wndGrid,
        CDC & dc,
        LONG nVisibleColNo,
        LONG nVisibleRowNo,
        LONG nColNo,
        LONG nRowNo,
        INT nColType,
        INT nRowType,
        DWORD dwAreaFlags,
        DWORD dwHelperPaintFlags
        ) const;
    virtual void OnPaintCheck(
        const RECT & rcCheck,
        bool bPressed,
        bool bHovered,
        bool bEnabled,
        const CExtGridWnd & wndGrid,
        CDC & dc,
        LONG nVisibleColNo,
        LONG nVisibleRowNo,
        LONG nColNo,
        LONG nRowNo,
        INT nColType,
        INT nRowType,
        const RECT & rcCellExtra,
        const RECT & rcCell,
        const RECT & rcVisibleRange,
        DWORD dwAreaFlags,
        DWORD dwHelperPaintFlags
        ) const;
};
-----------------------------------------------------------------

.cpp looks like (I took out the code to make it easier to read)
-----------------------------------------------------------------
CExtGridCellCheckBoxEye::CExtGridCellCheckBoxEye(CExtGridDataProvider * pDataProvider /* = NULL */)
:CExtGridCellCheckBox ( pDataProvider )
{
}

__EXT_MFC_SAFE_LPCTSTR CExtGridCellCheckBoxEye::GetTextBuffer() const
{
}

INT CExtGridCellCheckBoxEye::_GetTextAndCheckMarkIconIndex() const
{
}

void CExtGridCellCheckBoxEye::TextGet(CExtSafeString &strCopy) const
{
}

void CExtGridCellCheckBoxEye::Assign(const CExtGridCell &other)
{
}

void CExtGridCellCheckBoxEye::Serialize(CArchive &ar)
{
}

CSize CExtGridCellCheckBoxEye::OnCalcCheckSize(bool bPressed, bool bHovered, bool bEnabled,
                                             const CExtGridWnd &wndGrid,    CDC &dc, LONG nVisibleColNo,
                                             LONG nVisibleRowNo, LONG nColNo, LONG nRowNo, INT nColType,
                                             INT nRowType, DWORD dwAreaFlags, DWORD dwHelperPaintFlags) const
{
}

void CExtGridCellCheckBoxEye::OnPaintCheck(const RECT &rcCheck,    bool bPressed, bool bHovered, bool bEnabled,
                                         const CExtGridWnd &wndGrid, CDC &dc, LONG nVisibleColNo, LONG nVisibleRowNo,
                                         LONG nColNo, LONG nRowNo, INT nColType, INT nRowType, const RECT & rcCellExtra,
                                         const RECT &rcCell, const RECT &rcVisibleRange, DWORD dwAreaFlags, DWORD dwHelperPaintFlags) const
{
}

Douglas Hoppes Apr 17, 2009 - 8:21 AM

Whoops... Forgot.. at the top of my cpp file, I had:

IMPLEMENT_SERIAL(CExtGridCellCheckBoxEye, CExtGridCellCheckBox, VERSIONABLE_SCHEMA|1 );

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

Technical Support Apr 15, 2009 - 4:19 AM

Please download the following ZIP file:

http://www.prof-uis.com/download/forums/tmp/ProfUIS_Controls_PageGrid_UpdatedFiles.zip

Then please unpack the PageGrid.cpp and PageGrid.h files from it into the ..\Prof-UIS\Samples\ProfUIS_Controls folder. Then compile and run the ProfUIS_Controls sample application and select the Grid dialog page. The second column from the left side in the grid window has the CheckBox caption and contains two check box cells with the hidden/visible/semi-transparent eye instead of the check mark. These check box cells are instances of the CExtGridCellCheckBoxEye class which is inside the updated PageGrid.cpp and PageGrid.h files.

Douglas Hoppes Apr 15, 2009 - 1:09 PM

Thanks for the response. The look/feel is exactly what I was looking for. However, I’m running into an issue with it.

In our core library, I have a special class called CGridControl. This is a wrapper class surrounding all of the Prof-UI grid functionality. In this library goes the CExtGridCellCheckBoxEye.

Now, my application links to this core library, I always get the compile error: "syntax error : identifier ’pMalloc’" in my application (The core library builds fine.... no errors). This is caused by the

IMPLEMENT_ExtGridCell_Clone( CExtGridCellCheckBoxEye, CExtGridCellCheckBox );

How can I get rid of this error?

Doug