Print Page | Close Window

GetEditCtrl()->GetWindowText crash

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=22148
Printed Date: 29 March 2024 at 11:51am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: GetEditCtrl()->GetWindowText crash
Posted By: mathewteena
Subject: GetEditCtrl()->GetWindowText crash
Date 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?



Replies:
Posted By: kstowell
Date 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<



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