Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - XTP_NM_REPORTCOLUMNRESIZE notification
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

XTP_NM_REPORTCOLUMNRESIZE notification

 Post Reply Post Reply
Author
Message
Michl View Drop Down
Senior Member
Senior Member


Joined: 14 September 2007
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michl Quote  Post ReplyReply Direct Link To This Post Topic: XTP_NM_REPORTCOLUMNRESIZE notification
    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);
}

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Michl View Drop Down
Senior Member
Senior Member


Joined: 14 September 2007
Status: Offline
Points: 138
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michl Quote  Post ReplyReply Direct Link To This Post 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??
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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 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.
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 16 December 2009 at 5:16am
Can you please explain why you send a XTP_NM_REPORT_COLUMNWIDTHCHANGED with NULL-values?!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.234 seconds.