Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - GetEditCtrl()->GetWindowText crash
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

GetEditCtrl()->GetWindowText crash

 Post Reply Post Reply
Author
Message Reverse Sort Order
kstowell View Drop Down
Admin Group
Admin Group


Joined: 25 January 2003
Location: MIchigan, USA
Status: Offline
Points: 496
Post Options Post Options   Thanks (0) Thanks(0)   Quote kstowell Quote  Post ReplyReply Direct Link To This Post Topic: GetEditCtrl()->GetWindowText crash
    Posted: 03 January 2014 at 10:51am
It could be that the combo box is a drop list in that case it would not have an edit control.  You might want to try something like this:

CXTPControls* pXTPControls = m_myWndToolBar.GetControls();
if (pXTPControls)
    return false;

CXTPControlComboBox* pXTPComboBox =(CXTPControlComboBox*)pXTPControls ->FindControl(ID_ZOOM);
if (!pXTPComboBox)
    return false;

CString strZoom;
CXTPControlComboBoxEditCtrl* pXTPEdit = pXTPComboBox->GetEditCtrl();
if (pXTPEdit)
    strZoom = pXTPComboBox->GetEditText();
else
    strZoom = pXTPComboBox->GetListBoxText();
Kirk Stowell, President and CEO
CODEJOCK SOFTWARE SOLUTIONS<
Back to Top
mathewteena View Drop Down
Newbie
Newbie
Avatar

Joined: 26 December 2013
Location: India
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote mathewteena Quote  Post ReplyReply Direct Link To This Post Posted: 26 December 2013 at 1:29pm
Code snippet is as below:

CXTPControls* pXTPControls = m_myWndToolBar.GetControls();
if (!pXTPControls )
    return false;

  CXTPControlComboBox* pXTPComboBox =(CXTPControlComboBox*)pXTPControls ->FindControl(ID_ZOOM);
   
   if (!pXTPComboBox )
    return false;
 
    CString strZoom;
    pXTPComboBox ->GetEditCtrl()->GetWindowText(strZoom);

The line in the snippet that has been marked as bold causes a crash. I suspect that GetEditCtrl returns NULL( or invalid pointer) which leads to GetWindowText() to crash.

What could be the possible reasons for GetEditCtrl returning invalid pointer?
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.145 seconds.