Print Page | Close Window

GetFocusedColumn returns NULL?

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=13918
Printed Date: 21 September 2024 at 9:04pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: GetFocusedColumn returns NULL?
Posted By: znakeeye
Subject: GetFocusedColumn returns NULL?
Date 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/



Replies:
Posted By: mdoubson
Date 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);

}

}

}

}



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


Posted By: znakeeye
Date 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/


Posted By: mdoubson
Date 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.



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


Posted By: znakeeye
Date 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/



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