Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using dialog controls in resource files (Visual C++ MFC)

Status
Not open for further replies.

sobbayi

Programmer
May 20, 2003
1
KE
how do i add text to a list box.. I dont seem to be making any progress. Below is a snippet of what i am trying to do


I have a property page with a list box in it.
Inside the property page i have placed a list box

inside the property page class i have attached a member variable to my list box, including the ddX...

CListbox m_listbox;

I then have another class, i have a function that attempts to add a string to the resource list box. I am trying to fill strings into the listbox but nothing is happening. This is how i am trying to do it...

my_propertypageclass proppage;
proppage.m_listbox.AddString("sdfsdfs");

this also doesnt work....

my_propertypageclass* proppage;
proppage->m_listbox.AddString("sdfsdfs");

So my question is if i have a dlg control resources attached to member variables in class A, then i have another class B. How do i read or write data etc to from the resources through member variables from a member function of class B?







 
Unless you are intialising the listbox when thepage is first created, then DDX is of limited use to you here.

You need a public function in your property page class such as AddToListBox(CString myString);

In this function you need to include the code

//Create a Pointer to a Listbox
CListBox* pListBox;

//Swap IDC_LIST1 with the control name on your form
pListBox = (CListBox*) GetDlgItem(IDC_LIST1);

//Add the string to the Listbox
pListBox->AddString(myString);

I hope this helps. (Note, there may be other ways of doing this, but this is the way I have been doing it :))

Let me know if it worked !

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top