Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - GetFocusedColumn returns NULL?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

GetFocusedColumn returns NULL?

 Post Reply Post Reply
Author
Message
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 Topic: GetFocusedColumn returns NULL?
    Posted: 04 April 2009 at 6:10am
In my report-control I have this in OnKeyDown:
 
case VK_F2:
{
    CXTPReportSelectedRows *pSelectedRows = GetSelectedRows();
    if (pSelectedRows && pSelectedRows->GetCount())
    {
        XTP_REPORTRECORDITEM_ARGS itemArgs(this, pSelectedRows->GetAt(0), GetFocusedColumn());
        EditItem(&itemArgs);
        if (GetInplaceEdit()->GetSafeHwnd())
        {
            int len = GetInplaceEdit()->GetWindowTextLength();
            GetInplaceEdit()->SetSel(len, len);
        }
    }
}
 
This worked before, but nowadays GetFocusedColumn() always returns NULL, resulting in an assert/crash. What did you change? (Using XTP 13.0.0)
PokerMemento - http://www.pokermemento.com/
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: 08 April 2009 at 4:31pm
in current version

void CXTPReportControl::OnKeyDown

....................
case VK_F2:

GetNavigator()->BeginEdit();

break;

...................
}

void CXTPReportNavigator::BeginEdit()

{

if (!m_pReportControl)

return;

if (!m_pReportControl->IsIconView())

{

m_pReportControl->AdjustScrollBars();

m_pReportControl->RedrawControl();

m_pReportControl->UpdateWindow();

CXTPReportRow* pFocusedRow = m_pReportControl->GetFocusedRow();

if (m_pReportControl->m_pFocusedColumn &&

pFocusedRow && pFocusedRow->GetRecord())

{

XTP_REPORTRECORDITEM_ARGS itemArgs(m_pReportControl, pFocusedRow, m_pReportControl->m_pFocusedColumn);

if (itemArgs.pItem && itemArgs.pItem->IsAllowEdit(&itemArgs))

{

if (!m_pReportControl->IsVirtualMode())

m_pReportControl->EnsureVisible(pFocusedRow);

m_pReportControl->EditItem(&itemArgs);

if (m_pReportControl->GetInplaceEdit()->GetSafeHwnd() &&

m_pReportControl->GetInplaceEdit()->GetItem() == itemArgs.pItem)

{

CXTPReportRecordItemEditOptions* pEditOptions = itemArgs.pItem->GetEditOptions(itemArgs.pColumn);

if (pEditOptions && pEditOptions->m_bSelectTextOnEdit)

{

m_pReportControl->GetInplaceEdit()->SetSel(0, -1);

}

else

{

CString str;

m_pReportControl->GetInplaceEdit()->GetWindowText(str);

m_pReportControl->GetInplaceEdit()->SetSel(str.GetLength(), str.GetLength());

}

}

}

}

}

else

{

CXTPReportRow* pFocusedRow = m_pReportControl->GetFocusedRow();

CXTPReportColumn* pIconCOlumn = m_pReportControl->GetColumns()->Find(m_pReportControl->m_iIconViewColumn);

if (pIconCOlumn &&

pFocusedRow && pFocusedRow->GetRecord())

{

XTP_REPORTRECORDITEM_ARGS itemArgs(m_pReportControl, pFocusedRow, pIconCOlumn);

if (itemArgs.pItem && itemArgs.pItem->IsAllowEdit(&itemArgs))

{

m_pReportControl->EditItem(&itemArgs);

}

}

}

}

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: 20 April 2009 at 7:45am
If I start editing an item when handling VK_F2 in CMyReportControl::OnKeyDown AND let the base-class handle this message, the editing is immediately cancelled:
 
CXTPReportControl::OnKeyDown(...); // Editing will be cancelled!
 
 
This was the main issue here. Not sure if it's a bug or by design.
PokerMemento - http://www.pokermemento.com/
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: 21 April 2009 at 4:08pm

You already saw recent code so question is historical. For specific settings base class support for keypress F2 will open in-pace editor to start.

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: 23 April 2009 at 4:04am
I doubt the default code will work when FocusSubItems(FALSE) is set. I only have one editable column!
PokerMemento - http://www.pokermemento.com/
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.266 seconds.