From: jt on
Being a newbie at MFC, I am trying to use the MFC collection CList.

It works fine where I declared the structure in my class module.

Although, how can I access my CList in another class module or any module?

Apprecaite your help.

Thanks,
JT


From: Ajay Kalra on
You can always expose the CList member from your structure or preferably you
should expose the equivalent functionality from your struct so that clients
dont need CList. Something like this:

class CMyclass
{
public :
void AddSomeData(CSomeData* data); // add data to Clist
void RemoveSomeData(CSomeData* data); // remove data from Clist
..
};

--
Ajay Kalra [MVP - VC++]
ajaykalra(a)yahoo.com


"jt" <jtsoft(a)hotmail.com> wrote in message
news:8qN_d.124884$pc5.2430(a)tornado.tampabay.rr.com...
> Being a newbie at MFC, I am trying to use the MFC collection CList.
>
> It works fine where I declared the structure in my class module.
>
> Although, how can I access my CList in another class module or any module?
>
> Apprecaite your help.
>
> Thanks,
> JT
>
>


From: Scott McPhillips [MVP] on
jt wrote:

> Being a newbie at MFC, I am trying to use the MFC collection CList.
>
> It works fine where I declared the structure in my class module.
>
> Although, how can I access my CList in another class module or any module?
>
> Apprecaite your help.
>
> Thanks,
> JT
>
>

That is a basic C++ question, not specific to MFC. And the answer is
the same whether you wish to access an int or double or CList or
whatever type of member.

The "other" class needs a pointer or reference to the object that
contains the CList. It can then use this pointer or reference to access
public members and public functions of the object.

A common example of this in MFC applications is the GetDocument function
built in to every view. If the CList (m_clist) is a public member of
the document here is how a view would access it:

GetDocument()->m_clist.AddTail(...);

If you are attempting to write MFC applications without a good
understanding of the C++ language it would be a good idea to stop and
learn the language first, from books or a class. C++ is quite complex,
and so is MFC, and you're likely to get very confused if you attempt to
learn both at the same time.

--
Scott McPhillips [VC++ MVP]

From: jt on

"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:uXwAASELFHA.2764(a)tk2msftngp13.phx.gbl...
> jt wrote:
>
> > Being a newbie at MFC, I am trying to use the MFC collection CList.
> >
> > It works fine where I declared the structure in my class module.
> >
> > Although, how can I access my CList in another class module or any
module?
> >
> > Apprecaite your help.
> >
> > Thanks,
> > JT
> >
> >
>
> That is a basic C++ question, not specific to MFC. And the answer is
> the same whether you wish to access an int or double or CList or
> whatever type of member.
>
> The "other" class needs a pointer or reference to the object that
> contains the CList. It can then use this pointer or reference to access
> public members and public functions of the object.
>
> A common example of this in MFC applications is the GetDocument function
> built in to every view. If the CList (m_clist) is a public member of
> the document here is how a view would access it:
>
> GetDocument()->m_clist.AddTail(...);
>
> If you are attempting to write MFC applications without a good
> understanding of the C++ language it would be a good idea to stop and
> learn the language first, from books or a class. C++ is quite complex,
> and so is MFC, and you're likely to get very confused if you attempt to
> learn both at the same time.
>
> --
> Scott McPhillips [VC++ MVP]
>

Yep, confused. Then how to I make my CList public?

I put this declaration on top of the cpp file and its not part of a class.
Its just global to that cpp file only.

struct PageData
{
CString csPageData;
};
typedef CList< PageData *, PageData * > dPages;
dPages g_Pages;

Now, on another module cpp file, how would I access this?

Thanks,
JT


From: jt on
I put this declaration on top of the cpp file and its not part of a class.
Its just global to that cpp file only.

struct PageData
{
CString csPageData;
};
typedef CList< PageData *, PageData * > dPages;
dPages g_Pages;

Now, on another module cpp file, how would I access this?

Thanks,
JT

"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
news:%23y%23%23TNELFHA.3340(a)TK2MSFTNGP14.phx.gbl...
> You can always expose the CList member from your structure or preferably
you
> should expose the equivalent functionality from your struct so that
clients
> dont need CList. Something like this:
>
> class CMyclass
> {
> public :
> void AddSomeData(CSomeData* data); // add data to Clist
> void RemoveSomeData(CSomeData* data); // remove data from Clist
> ..
> };
>
> --
> Ajay Kalra [MVP - VC++]
> ajaykalra(a)yahoo.com
>
>
> "jt" <jtsoft(a)hotmail.com> wrote in message
> news:8qN_d.124884$pc5.2430(a)tornado.tampabay.rr.com...
> > Being a newbie at MFC, I am trying to use the MFC collection CList.
> >
> > It works fine where I declared the structure in my class module.
> >
> > Although, how can I access my CList in another class module or any
module?
> >
> > Apprecaite your help.
> >
> > Thanks,
> > JT
> >
> >
>
>