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

Still not fixed

 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: Still not fixed
    Posted: 24 March 2010 at 4:06am
Hello Codejock-Team!

Please load your sample application "ReportSample" and add this code:

void CReportSampleView::OnReportKeyDown(NMHDR * pNotifyStruct, LRESULT * /*result*/)
{
    LPNMKEY lpNMKey = (LPNMKEY)pNotifyStruct;

    if (!GetReportCtrl().GetFocusedRow())
        return;

    if (lpNMKey->nVKey == VK_RETURN)
    {
        CMessageRecord* pRecord = DYNAMIC_DOWNCAST(CMessageRecord, GetReportCtrl().GetFocusedRow()->GetRecord());
        if (pRecord)
        {
            if (pRecord->SetRead())
            {
                GetReportCtrl().Populate();
            }
        }
    }
    else if (lpNMKey->nVKey == VK_DELETE)
    {
        CMessageRecord* pRecord = DYNAMIC_DOWNCAST(CMessageRecord, GetReportCtrl().GetFocusedRow()->GetRecord());
        if (!pRecord)
            AfxMessageBox( _T("Can't remove record!"), MB_OK);
    }
}


Compile and run application.
If application is showing press immediatelly [DEL] to remove (as sample action) first selected record.

It is not possible!
The reason ist that Populate() select every time internally row 0 as active selection! (in this case the group row)
But this don't works if groups are displaying.

    if (m_nFocusedRow == -1)
    {
        SetTopRow(0);

        if (GetRows()->GetCount() > 0)
        {
            m_nFocusedRow = 0;
            if (IsSelectionEnabled() && IsInitialSelectionEnabled())
            {
                CXTPReportRow* pFirst = m_pRows->GetAt(0);
                if (pFirst)
                {
                    if (!IsSkipGroupsFocusEnabled() || !pFirst->IsGroupRow())
                        m_pSelectedRows->Select(pFirst);
                    else
                    {
                        while (pFirst->IsGroupRow())
                        {
                            if (pFirst->HasChildren())
                                pFirst = pFirst->GetChilds()->GetAt(0);
                        }
                        m_pSelectedRows->Select(pFirst);
                    }
                }
            }
        }

    }
    else
    {
        EnsureVisible(GetFocusedRow());
    }



I see you have extend OnRButtonDown() with SetFocusedRow(). This solves the problem only for mouse inputs.

void CXTPReportControl::OnRButtonDown(UINT nFlags, CPoint point)
{
    CWnd::OnRButtonDown(nFlags, point);

    CXTPReportRow* pRow = HitTest(point, TRUE);
    if (pRow)
    {
        SetFocusedRow(pRow, pRow->IsSelected());
        m_pointDrag = point;
        if (m_bRClickDrag) m_bPrepareDrag = TRUE;
    }
    else if (m_bFastDeselectMode)
    {
        BOOL bControlKey = (GetKeyState(VK_CONTROL) < 0) || m_bControlKeyAlwaysOn;
        BOOL bShiftKey = (GetKeyState(VK_SHIFT) < 0);
        if (!bControlKey && !bShiftKey)
        {
            m_pSelectedRows->Clear();
            if (m_pSelectedRows->IsChanged())
                OnSelectionChanged();
        }
    }

}


See also my postings:
http://forum.codejock.com/forum_posts.asp?TID=9932&PN=1
http://forum.codejock.com/forum_posts.asp?TID=10539&KW=


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.160 seconds.