Assertion failure While Editing CTreeView Label.
-
Dear Friend, After adding all necessary message handler to support to edit label in CTreeView
void CMyTreeView::OnBeginLabelEdit( NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
// This is the Limit the size of the Tag Name to 127
CTreeCtrl &ctlFiles = GetTreeCtrl();
ctlFiles.GetEditControl()->LimitText( 127 );
*pResult = 0;
}void CMyTreeView::OnEndLabelEdit( NMHDR * pNMHDR, LRESULT * pResult )
{
*pResult = TRUE;
}BOOL CMyTreeView::PreTranslateMessage(MSG* pMsg)
{if ( pMsg->message == WM\_KEYDOWN ) { CTreeCtrl &ctlFiles = GetTreeCtrl(); CEdit\* edit = ctlFiles.GetEditControl(); if (edit) { if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_C ) { edit->Copy(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_V ) { edit->Paste(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_X ) { edit->Cut(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_Z ) { edit->Undo(); return TRUE; } if( pMsg->wParam == VK\_RETURN || pMsg->wParam == VK\_ESCAPE || pMsg->wParam == VK\_CONTROL || pMsg->wParam == VK\_INSERT ) { edit->SendMessage(WM\_KEYDOWN, pMsg->wParam, pMsg->lParam); return TRUE; } } } return CTreeView::PreTranslateMessage(pMsg);
}
If I press a character 'a' to 'z' and 'A' to 'z' then MFC throwing Assertion. I don't know what I am missing out to avoid this issue. Kindly help me on this. Thanks, S Shanmuga Raja
-
Dear Friend, After adding all necessary message handler to support to edit label in CTreeView
void CMyTreeView::OnBeginLabelEdit( NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
// This is the Limit the size of the Tag Name to 127
CTreeCtrl &ctlFiles = GetTreeCtrl();
ctlFiles.GetEditControl()->LimitText( 127 );
*pResult = 0;
}void CMyTreeView::OnEndLabelEdit( NMHDR * pNMHDR, LRESULT * pResult )
{
*pResult = TRUE;
}BOOL CMyTreeView::PreTranslateMessage(MSG* pMsg)
{if ( pMsg->message == WM\_KEYDOWN ) { CTreeCtrl &ctlFiles = GetTreeCtrl(); CEdit\* edit = ctlFiles.GetEditControl(); if (edit) { if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_C ) { edit->Copy(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_V ) { edit->Paste(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_X ) { edit->Cut(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_Z ) { edit->Undo(); return TRUE; } if( pMsg->wParam == VK\_RETURN || pMsg->wParam == VK\_ESCAPE || pMsg->wParam == VK\_CONTROL || pMsg->wParam == VK\_INSERT ) { edit->SendMessage(WM\_KEYDOWN, pMsg->wParam, pMsg->lParam); return TRUE; } } } return CTreeView::PreTranslateMessage(pMsg);
}
If I press a character 'a' to 'z' and 'A' to 'z' then MFC throwing Assertion. I don't know what I am missing out to avoid this issue. Kindly help me on this. Thanks, S Shanmuga Raja
Which line does it occur on when you step through it, and what is the assertion being hit?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
Dear Friend, After adding all necessary message handler to support to edit label in CTreeView
void CMyTreeView::OnBeginLabelEdit( NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
// This is the Limit the size of the Tag Name to 127
CTreeCtrl &ctlFiles = GetTreeCtrl();
ctlFiles.GetEditControl()->LimitText( 127 );
*pResult = 0;
}void CMyTreeView::OnEndLabelEdit( NMHDR * pNMHDR, LRESULT * pResult )
{
*pResult = TRUE;
}BOOL CMyTreeView::PreTranslateMessage(MSG* pMsg)
{if ( pMsg->message == WM\_KEYDOWN ) { CTreeCtrl &ctlFiles = GetTreeCtrl(); CEdit\* edit = ctlFiles.GetEditControl(); if (edit) { if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_C ) { edit->Copy(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_V ) { edit->Paste(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_X ) { edit->Cut(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_Z ) { edit->Undo(); return TRUE; } if( pMsg->wParam == VK\_RETURN || pMsg->wParam == VK\_ESCAPE || pMsg->wParam == VK\_CONTROL || pMsg->wParam == VK\_INSERT ) { edit->SendMessage(WM\_KEYDOWN, pMsg->wParam, pMsg->lParam); return TRUE; } } } return CTreeView::PreTranslateMessage(pMsg);
}
If I press a character 'a' to 'z' and 'A' to 'z' then MFC throwing Assertion. I don't know what I am missing out to avoid this issue. Kindly help me on this. Thanks, S Shanmuga Raja
shanmugarajaa wrote:
...MFC throwing Assertion.
Exactly what assertion is being thrown?
shanmugarajaa wrote:
Kindly help me on this.
Have you stepped through the code using the debugger?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Dear Friend, After adding all necessary message handler to support to edit label in CTreeView
void CMyTreeView::OnBeginLabelEdit( NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
// This is the Limit the size of the Tag Name to 127
CTreeCtrl &ctlFiles = GetTreeCtrl();
ctlFiles.GetEditControl()->LimitText( 127 );
*pResult = 0;
}void CMyTreeView::OnEndLabelEdit( NMHDR * pNMHDR, LRESULT * pResult )
{
*pResult = TRUE;
}BOOL CMyTreeView::PreTranslateMessage(MSG* pMsg)
{if ( pMsg->message == WM\_KEYDOWN ) { CTreeCtrl &ctlFiles = GetTreeCtrl(); CEdit\* edit = ctlFiles.GetEditControl(); if (edit) { if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_C ) { edit->Copy(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_V ) { edit->Paste(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_X ) { edit->Cut(); return TRUE; } if( GetKeyState( VK\_CONTROL ) && pMsg->wParam == VK\_Z ) { edit->Undo(); return TRUE; } if( pMsg->wParam == VK\_RETURN || pMsg->wParam == VK\_ESCAPE || pMsg->wParam == VK\_CONTROL || pMsg->wParam == VK\_INSERT ) { edit->SendMessage(WM\_KEYDOWN, pMsg->wParam, pMsg->lParam); return TRUE; } } } return CTreeView::PreTranslateMessage(pMsg);
}
If I press a character 'a' to 'z' and 'A' to 'z' then MFC throwing Assertion. I don't know what I am missing out to avoid this issue. Kindly help me on this. Thanks, S Shanmuga Raja