Re: CListBox question again
- From: "Tom Serface" <tom.nospam@xxxxxxxxxxxxx>
- Date: Wed, 7 Mar 2007 19:09:09 -0800
Did you check the retrurn in pName at the top? Does it contain what you'd expected? Did any of the strings show up in the control? Otherwise, this looks OK at first glance. I'm assuming you did call GetDocument() or something to fill in the m_pDoc pointer.
Tom
"Al" <Al@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:216B61D6-B8DB-468C-AEED-D4FB03726655@xxxxxxxxxxxxxxxx
CName* pName;
CName* pTempName;
for(x=0; x<Max; x++)
{
pName = m_pDoc->m_Object.m_NameList.GetAt(x);
c_ListNames.AddString(pName->m_Name);
c_ListNames.SetItemDataPtr(x, pName);
pTempName = (CNames*)c_ListNames.GetItemDataPtr(x);
}
Sorry I missed so code before. The m_NameList is a CTypedPtrArray in the
m_Object class. I see the names and the pointer changes when I SetItemDataPtr
and gets the same pointer when I retrieve them with GetItemDataPtr. This code
is in the OnInitailDlg() function of the dialog with the CListBox in it. When
a name is selected in the CListBox the code in the OnSelchangeListName() is
run where when I try to use the same method of GetItemDataPtr to retrieve the
pointer will give me NULL.
--
Just Al
"Al" wrote:
CName* pName;
CName* pTempName;
for(x=0 x<Max; x++)
{
c_ListNames.AddString(pName->m_Name);
c_ListNames.SetItemDataPtr(x, pName);
pTempName = (CNames*)c_ListPlayerNames.GetItemDataPtr(x);
}
I added the pTempName to see if I could retrieve a pointer and I am. But
when a name is selected in the ListBox, it goes to OnSelectListBox() function
and when I try to retrieve the pointer there I get NULL
--
Just Al
"Tom Serface" wrote:
> Hmmm, the Owner Draw setting shouldn't affect this (especially if set > to
> false). How did you allocate the memory for the pointers you are > assigning
> using the SetItemDataPtr() call? Maybe you could post a little of that > code
> snippet? I'd be happy to give it a look.
> Tom
>
> "Al" <Al@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:0BDD09A0-6A58-4057-B58A-9D5B39192293@xxxxxxxxxxxxxxxx
> > Well I am still having a problem. When compiling there are no errors > > using
> > the (CObject*) cast. But it does not any of the pointers that I
> > SetItemDataPtr when I Initialized the CListBox. The Owner Draw option > > of
> > the
> > list box is set to "No" if that matters. Where do you think I am > > making my
> > error?
>
.
- Follow-Ups:
- Re: CListBox question again
- From: Al
- Re: CListBox question again
- References:
- Re: CListBox question again
- From: Tom Serface
- Re: CListBox question again
- From: Al
- Re: CListBox question again
- Prev by Date: Re: VC++ 2003 MFC used with VC 2005 Express?
- Next by Date: Re: Constructor initializations - which way better why?
- Previous by thread: Re: CListBox question again
- Next by thread: Re: CListBox question again
- Index(es):
Relevant Pages
|