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 » CExtGridCellDateTime --> CExtGridCellDuration Collapse All
Subject Author Date
Offer Har Apr 16, 2007 - 6:28 AM

Dear Support,

I see the existing CExtGridCellDateTime. I need a duration cell, but could not find (like the normal control CExtDurationWnd)

Please advise.

Regards,
Ron.

Offer Har Apr 16, 2007 - 6:38 AM

Found it! CExtGridCellDuration

Another question - I see that the cell is displayed 0 Days 00:00:00.
I would like to get rid of the 0 Days part, and if its more then 23:59:59 hours, I would like it to write 24:00:00, 25:00:00 etc.
How can this be done?

Thanks,
Ron.

Technical Support Apr 17, 2007 - 12:30 PM

We have just added a CExtGridCellDuration::IsItemVisible virtual method. By overriding this method in the CExtGridCellDuration-derived class, you can manage the visibility of duration parts: days, hours, minutes and seconds. Please download the latest stable source code from our ftp server.

Offer Har Apr 17, 2007 - 12:45 PM

Will it display two days as 48:00:00?

Technical Support Apr 18, 2007 - 11:41 AM

Yes, it will. But please update the CExtGridCellDuration::TextGet method with this to get the cell text shown correctly:

void CExtGridCellDuration::TextGet( CExtSafeString & strCopy ) const
{
    ASSERT_VALID( this );
    if(        (GetStyleEx()&__EGCS_EX_UNDEFINED_ROLE) != 0 
        ||    IsEmpty()
        )
    {
        strCopy = _T("");
        return;
    }
    strCopy.Empty();

    if( m_dtSpan.GetStatus() == COleDateTimeSpan::valid )
    {
        LONG nTotalSeconds = (LONG) m_dtSpan.GetTotalSeconds();
    
        CString sDays;
        CString sHours;
        CString sMinutes;
        CString sSeconds;

        if( IsItemVisible( day ) )
        {
            INT nDays = nTotalSeconds / (60 * 60 * 24);
            nTotalSeconds -= (nDays * 60 * 60 * 24);
            CString sDaysLocalizedName;
            if( ! g_ResourceManager->LoadString( sDaysLocalizedName, IDS_EXT_DURATION_DAYS ) )
                sDaysLocalizedName = _T(" Days");
            sDays.Format(
                _T("%d%s"),
                nDays,
                sDaysLocalizedName
                );
        }
        if( IsItemVisible( hour ) )
        {
            INT nHours = nTotalSeconds / (60 * 60);
            nTotalSeconds -= (nHours * 60 * 60);
            sHours.Format(
                _T("%02d"),
                nHours
                );
        }
        if( IsItemVisible( minute ) )
        {
            INT nMinutes = nTotalSeconds / 60;
            nTotalSeconds -= (nMinutes * 60);
            sMinutes.Format(
                _T("%02d"),
                nMinutes
                );
        }
        if( IsItemVisible( second ) )
        {
            INT nSeconds = nTotalSeconds;
            sSeconds.Format(
                _T("%02d"),
                nSeconds
                );
        }
        strCopy = sSeconds;
        if( !sMinutes.IsEmpty() )
        {
            if( !strCopy.IsEmpty() )
                strCopy.Insert( 0, _T(":") );
            strCopy.Insert( 0, sMinutes );
        }
        if( !sHours.IsEmpty() )
        {
            if( !strCopy.IsEmpty() )
                strCopy.Insert( 0, _T(":") );
            strCopy.Insert( 0, sHours );
        }
        if( !sDays.IsEmpty() )
        {
            if( !strCopy.IsEmpty() )
                strCopy.Insert( 0, _T(" ") );
            strCopy.Insert( 0, sDays );
        }
    }
}

Suhai Gyorgy Apr 16, 2007 - 6:57 AM

Checking source code, it seems that this format is set in CExtGridCellDuration::TextGet method, in which I can’t see any option how you could customize this behaviour. So my best guess would be to override this method and format the string to your own needs.

Offer Har Apr 16, 2007 - 7:00 AM

That’s a good idea, but I think this should be customizable at the level of the CExtGridCellDuration class.
Support - can this be implemented fro the upcoming version?

Thanks,
Ron.