Problem with CComboBox::GetItemDataPtr
-
Hi, I am getting a problem with the CComboBox::GetItemDataPtr function i have the following code TCHAR *szFilePath = new TCHAR[MAX_PATH + 1]; ZeroMemory(szFilePath ,MAX_PATH); _tcscpy(szFilePath ,_T("C:\Documents and Settings\user\Desktop\Scrollbar.xml")); int nIndex = m_Combo.AddString(_T("ScrollBar")); m_Combo.SetItemDataPtr(n , szFilePath); using the Above code am setting the ItemDataPtr to a Buffer. On the Selection change event of ComboBox i have the following code void CRegDlg::OnCbnSelchangeCombo() { // TODO: Add your control notification handler code here int nIndex = m_Combo.GetCurSel(); void *szFilePath = m_Combo.GetItemDataPtr(n); } but the GetItemDataPtr() in OnCbnSelchangeCombo always returns a Bad pointer. I don't know what is the actual problem with my code. Is there anything i want to do to get the actual buffer from void*. thanks Nitheesh
Jose Jo Martin http://www.simpletools.co.in
-
Hi, I am getting a problem with the CComboBox::GetItemDataPtr function i have the following code TCHAR *szFilePath = new TCHAR[MAX_PATH + 1]; ZeroMemory(szFilePath ,MAX_PATH); _tcscpy(szFilePath ,_T("C:\Documents and Settings\user\Desktop\Scrollbar.xml")); int nIndex = m_Combo.AddString(_T("ScrollBar")); m_Combo.SetItemDataPtr(n , szFilePath); using the Above code am setting the ItemDataPtr to a Buffer. On the Selection change event of ComboBox i have the following code void CRegDlg::OnCbnSelchangeCombo() { // TODO: Add your control notification handler code here int nIndex = m_Combo.GetCurSel(); void *szFilePath = m_Combo.GetItemDataPtr(n); } but the GetItemDataPtr() in OnCbnSelchangeCombo always returns a Bad pointer. I don't know what is the actual problem with my code. Is there anything i want to do to get the actual buffer from void*. thanks Nitheesh
Jose Jo Martin http://www.simpletools.co.in
Nitheesh George wrote:
_tcscpy(szFilePath ,_T("C:\Documents and Settings\user\Desktop\Scrollbar.xml"));
Are you intentionally not using double backslashes?
Nitheesh George wrote:
m_Combo.SetItemDataPtr(n , szFilePath);
Shouldn't this be:
m_Combo.SetItemDataPtr(nIndex, szFilePath);
Nitheesh George wrote:
void *szFilePath = m_Combo.GetItemDataPtr(n);
Shouldn't this be:
TCHAR *szFilePath = m_Combo.GetItemDataPtr(nIndex);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
-
Nitheesh George wrote:
_tcscpy(szFilePath ,_T("C:\Documents and Settings\user\Desktop\Scrollbar.xml"));
Are you intentionally not using double backslashes?
Nitheesh George wrote:
m_Combo.SetItemDataPtr(n , szFilePath);
Shouldn't this be:
m_Combo.SetItemDataPtr(nIndex, szFilePath);
Nitheesh George wrote:
void *szFilePath = m_Combo.GetItemDataPtr(n);
Shouldn't this be:
TCHAR *szFilePath = m_Combo.GetItemDataPtr(nIndex);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
Hi David, thank you for your reply. Now i realize what is wrong with my code. thanks Nitheesh
Jose Jo Martin http://www.simpletools.co.in