Print Page | Close Window

XTP_NM_REPORTCOLUMNRESIZE notification

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=13449
Printed Date: 24 November 2024 at 5:01am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: XTP_NM_REPORTCOLUMNRESIZE notification
Posted By: Michl
Subject: XTP_NM_REPORTCOLUMNRESIZE notification
Date Posted: 19 February 2009 at 5:41am
Hi codejocke developers!

If I/user moves a column (AutoColumnSizing = false), why does report send a message XTP_NM_REPORTCOLUMNRESIZE???
(message comes from CXTPReportHeader::AdjustColumnsWidth())

Because my program also react to this message, wrong code will be executed.

In my opinion this code is wrong/to much:

void CXTPReportHeader::AdjustColumnsWidth(int nTotalWidth, int nFirstIndex)
{
    if (m_bAutoColumnSizing)
    {
        int nColumnsWidth = 0;
        CXTPReportColumn* pLastAutoColumn = NULL;
        int nColumn;

        for (nColumn = nFirstIndex; nColumn < m_pColumns->GetCount(); nColumn++)
        {
            CXTPReportColumn* pColumn = m_pColumns->GetAt(nColumn);
            if (!pColumn->IsVisible())
                continue;

            if (pColumn->m_bAutoSize)
            {
                pLastAutoColumn = pColumn;
                nColumnsWidth += pColumn->m_nColumnAutoWidth;
            }
            else
            {
                nTotalWidth -= pColumn->GetWidth();
            }
        }

        if (pLastAutoColumn && nTotalWidth > 0)
        {

            for (nColumn = nFirstIndex; nColumn < m_pColumns->GetCount(); nColumn++)
            {
                CXTPReportColumn* pColumn = m_pColumns->GetAt(nColumn);
                if (!pColumn->IsVisible())
                    continue;

                if (pColumn->m_bAutoSize)
                {
                    if (pColumn == pLastAutoColumn)
                    {
                        pColumn->m_nColumnStaticWidth = max(nTotalWidth, pColumn->GetMinWidth());
                        if(pColumn->m_nColumnStaticWidth != pColumn->m_nColumnAutoWidth)
                        {
                            XTP_NM_REPORTCOLUMNRESIZE nmData;
                            nmData.pColumn = pColumn;
                            nmData.nPrevWidth = pColumn->m_nColumnAutoWidth;
                            nmData.nNewWidth = pColumn->m_nColumnStaticWidth;
                            m_pControl->SendNotifyMessage(XTP_NM_REPORT_COLUMNWIDTHCHANGED, (NMHDR*)&nmData);
                        }
                    }
                    else
                    {
                        nColumnsWidth = max(1, nColumnsWidth);

                        pColumn->m_nColumnStaticWidth =
                            max(int(pColumn->m_nColumnAutoWidth * nTotalWidth / nColumnsWidth), pColumn->GetMinWidth());
                        if(pColumn->m_nColumnStaticWidth != pColumn->m_nColumnAutoWidth)
                        {
                            XTP_NM_REPORTCOLUMNRESIZE nmData;
                            nmData.pColumn = pColumn;
                            nmData.nPrevWidth = pColumn->m_nColumnAutoWidth;
                            nmData.nNewWidth = pColumn->m_nColumnStaticWidth;
                            m_pControl->SendNotifyMessage(XTP_NM_REPORT_COLUMNWIDTHCHANGED, (NMHDR*)&nmData);
                        }

                        nTotalWidth -= pColumn->m_nColumnStaticWidth;
                        nColumnsWidth -= pColumn->m_nColumnAutoWidth;
                    }
                }
            }
        }

        m_nHeaderWidth = m_pControl->m_rcHeaderArea.Width();
    }
    else
    {
        m_nHeaderWidth = 0;

        for (int nColumn = 0; nColumn < m_pColumns->GetCount(); nColumn++)
        {
            CXTPReportColumn* pColumn = m_pColumns->GetAt(nColumn);

            if (pColumn && pColumn->IsVisible())
                m_nHeaderWidth += pColumn->GetWidth();
        }

        if (m_nHeaderWidth == 0)
        {
            m_nHeaderWidth = nTotalWidth;
        }

        m_pControl->AdjustScrollBars();
    }

    XTP_NM_REPORTCOLUMNRESIZE nmData;
    ZeroMemory(&nmData, sizeof(nmData));
    m_pControl->SendNotifyMessage(XTP_NM_REPORT_COLUMNWIDTHCHANGED, (NMHDR*)&nmData);
}




Replies:
Posted By: mdoubson
Date Posted: 20 February 2009 at 4:12pm
I think you are right - better use as
if (!m_bAutoColumnSizing)
{
    XTP_NM_REPORTCOLUMNRESIZE nmData;
    ZeroMemory(&nmData, sizeof(nmData));
    m_pControl->SendNotifyMessage(XTP_NM_REPORT_COLUMNWIDTHCHANGED, (NMHDR*)&nmData);
}
You can also modify your app OnNotify code and check m_bAutoColumnSizing flag before doing smth


-------------
Mark Doubson, Ph.D.


Posted By: Michl
Date Posted: 29 June 2009 at 11:39am
Hmmm
The newest code was edited, but it doing the same as before.... ????

Why should I notified with a message
COLUMNWIDTHCHANGED whenn I move a column??
(if !
m_bAutoColumnSizing, columns still have the same size after moving)

Make it sense to remove code??


Posted By: mdoubson
Date Posted: 29 June 2009 at 12:00pm
I did not promice to change it right now - had something more important
 
I commented red code as I agree with your opinion - no needed notification
 
You can get updated code here https://forum.codejock.com/uploads/DemoVersion/ReportControlMFCUpdated.rar - https://forum.codejock.com/uploads/DemoVersion/ReportControlMFCUpdated.rar  and build fresh version
 
I like to have some responds from forum members who need this fix.
Same request for selection - move case.
 
There are also some complains about resizing model but nobody propose some spec for resizing we can discuss and implement.


-------------
Mark Doubson, Ph.D.


Posted By: znakeeye
Date Posted: 16 December 2009 at 5:16am
Can you please explain why you send a XTP_NM_REPORT_COLUMNWIDTHCHANGED with NULL-values?!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net