GetFocusedColumn returns NULL? |
Post Reply |
Author | |
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
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/
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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); } } } } |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
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/
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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. |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
I doubt the default code will work when FocusSubItems(FALSE) is set. I only have one editable column!
|
|
PokerMemento - http://www.pokermemento.com/
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |