Re: CListBox question again



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?
>

.



Relevant Pages

  • Re: CListBox question again
    ... the names show up in the CListBox and as you can see I ... add the CTempName* to see if I could GetItemDataPtr, ... The same pointer that went in comes out. ... and gets the same pointer when I retrieve them with GetItemDataPtr. ...
    (microsoft.public.vc.mfc)
  • [PATCH] s/retreiv/retriev/g
    ... /* Returns the dentry referring to the root of the extended ... we attempt to retrieve it from disk. ... * @tty - pointer to tty instance data ... * @buf - pointer to returned data buffer ...
    (Linux-Kernel)
  • Re: Data structure query
    ... space to store and also the time required to retrieve given a key the ... I will guess that the keys are strings, and that "alphabetical order" refers to the keys. ... I will assume that the values are also of variable length, and that the data structure is static and entirely in memory. ... An array of {pointer to key, pointer to value} sorted by key would allow ordered retrieval, as well as binary search to find a value given the key with minimal space overhead. ...
    (comp.programming)
  • Re: CComboBox/CListBox
    ... > I have a CComboBox who's type is Drop List. ... > the down arrow button is of the CComboBox I believe that a CListBox is the ... > CListBox so that they can't be selected. ... > can get pointer to a data item, except the pointer in all likelyhood is void ...
    (microsoft.public.vc.mfc)
  • Re: Datagrid current row ?
    ... I think if you do DoEvents just under the DataGrid1_Clickevent, ... to let the pointer to the row you clicked catch up. ... > Private Sub DataGrid1_Click ... > As there is no textmatrix like flexgrid, how can I retrieve the Current ...
    (microsoft.public.vb.enterprise)