AddString() function again
-
let me tell the whole method: i want to diaplay a modeless listbox on button click.i.e when i click a button a listbox pops-up.for this i hav made a new class named CMyLIst which is derived from CListBox.in CMyList i have made my own addstring function which is like this: int CMyList::Addition(LPCTSTR lpszItem) { return CListBox::AddString(lpszItem); } In my Parent class which contains the button i have declared an object of CMyList as: CMyList myobj; and i hav used it as void CMyDemo::OnButton1() { CMyList myobj; if(myobj.DoModal()) { myobj.Addition("hye"); } } but i m getting error that DoModal() is not function of CMYList May be this problem is because i have derived C
-
let me tell the whole method: i want to diaplay a modeless listbox on button click.i.e when i click a button a listbox pops-up.for this i hav made a new class named CMyLIst which is derived from CListBox.in CMyList i have made my own addstring function which is like this: int CMyList::Addition(LPCTSTR lpszItem) { return CListBox::AddString(lpszItem); } In my Parent class which contains the button i have declared an object of CMyList as: CMyList myobj; and i hav used it as void CMyDemo::OnButton1() { CMyList myobj; if(myobj.DoModal()) { myobj.Addition("hye"); } } but i m getting error that DoModal() is not function of CMYList May be this problem is because i have derived C
I thought DoModal is only for CDialog derived classes. Use a Dialog to hold the ListBox. Call the Dialog with DoModal, and implement the code of your listbox there. You will be able to acces the ListBox from outside the dialog (your button to add the string) using a pointer or a CListBox member variable related to your listbox in the dialog
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
-
let me tell the whole method: i want to diaplay a modeless listbox on button click.i.e when i click a button a listbox pops-up.for this i hav made a new class named CMyLIst which is derived from CListBox.in CMyList i have made my own addstring function which is like this: int CMyList::Addition(LPCTSTR lpszItem) { return CListBox::AddString(lpszItem); } In my Parent class which contains the button i have declared an object of CMyList as: CMyList myobj; and i hav used it as void CMyDemo::OnButton1() { CMyList myobj; if(myobj.DoModal()) { myobj.Addition("hye"); } } but i m getting error that DoModal() is not function of CMYList May be this problem is because i have derived C
tyagineha wrote:
CMyList myobj; if(myobj.DoModal()) { myobj.Addition("hye"); }
Called With
DoModal()
, a dialog is modal (blocking the GUI until it goes away). SoDoModal()
only returns after your dialog has been closed.IDOK
is the return value when the OK-Button was used,IDCANCEL
when the cancel button was used. So you are filling the Listbox only after it has ended. Add you call to addition between the instantiation ofCMyList
and the call toDoModal()
. You probably will have to store the data in a variable in your derived class, because there is no such thing as a ListBox window you could callAddString()
on. Your class can then handle OnInitDialog() and fill the ListBox after the call to the base class. All this is made easier by using aCDialog
-derived class. If you do not want to useCDialog
, you would have toCreate()
the listbox yourself.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
George Orwell, "Keep the Aspidistra Flying", Opening words -
let me tell the whole method: i want to diaplay a modeless listbox on button click.i.e when i click a button a listbox pops-up.for this i hav made a new class named CMyLIst which is derived from CListBox.in CMyList i have made my own addstring function which is like this: int CMyList::Addition(LPCTSTR lpszItem) { return CListBox::AddString(lpszItem); } In my Parent class which contains the button i have declared an object of CMyList as: CMyList myobj; and i hav used it as void CMyDemo::OnButton1() { CMyList myobj; if(myobj.DoModal()) { myobj.Addition("hye"); } } but i m getting error that DoModal() is not function of CMYList May be this problem is because i have derived C
Can you explain why you derived CListBox do you have any intent of derived?
WhiteSky