Addstring function
-
Did your MyListBox class derive from CListBox? Then the Create()-code should already be there and be used. But then you could simply write
AddString()
in you class function, as "public derivation" means the derived class *IS A* base class in every respect.
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 -
i want to diaplay a modeless listbox on button click.i m gvng my listbox which in one class from some other class. i hav made a new class in which i have made my own addstring function which is like this: int CMyList::Addition(LPCTSTR lpszItem) { return CListBox::AddString(lpszItem); } i have declared an object of CMyList as: CMyList myobj; obj.Addition("hye"); but i m getting exception error. can anyone tell me how to rectify this exception. is there any other method to do so?? NT
-
Did your MyListBox class derive from CListBox? Then the Create()-code should already be there and be used. But then you could simply write
AddString()
in you class function, as "public derivation" means the derived class *IS A* base class in every respect.
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 -
yes i have derived my new class from CListBox nw do i hav to use create() function???????? NT
Yes. When you want to Create your Listbox. From your description, that would be the button-click-handler. Remember, though, that a local MyListBox variable would be destroyed on leaving the Button-click-handler. But you wanted your ListBox modeless and staying on the screen even when your program continues. You would possibly need to make a member variable in its parent for it.
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 -
yes i have derived my new class from CListBox nw do i hav to use create() function???????? NT
It depends. If in your case
myobj
is a member of your dialog where the list box belongs to and ifmyobj
is associated with that list box, then no. If you createdmyobj
in some function locally, then yes. Maybe you can have a look at the MFC Controls -> List controls section for some sample code to study. Regards Marcus -
Learn to better look at the exception, I think the ASSERT is yelling coz theres is not window. In Window you gotta create first the window and THEN work with them. I do loading often in the CWnd::OnShowWindow(...) function
Greetings from Germany
KarstenK wrote:
Learn to better look at the exception, I think the ASSERT...
While it very well may be an assertion that fired (i.e., nonexistent window), the OP stated it was an exception that was thrown.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
i want to diaplay a modeless listbox on button click.i m gvng my listbox which in one class from some other class. i hav made a new class in which i have made my own addstring function which is like this: int CMyList::Addition(LPCTSTR lpszItem) { return CListBox::AddString(lpszItem); } i have declared an object of CMyList as: CMyList myobj; obj.Addition("hye"); but i m getting exception error. can anyone tell me how to rectify this exception. is there any other method to do so?? NT
Get a book on MFC. You're not using the class correctly in the first place. All MFC objects that wrap Win32 primitives like HWND, HDC, etc, have a similar pattern: CWnd wnd; //make a new instance or CWnd* wnd = new CWnd(); //"create" the instance wnd.Create(......); or wnd->Create(.....);
¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog
-
Get a book on MFC. You're not using the class correctly in the first place. All MFC objects that wrap Win32 primitives like HWND, HDC, etc, have a similar pattern: CWnd wnd; //make a new instance or CWnd* wnd = new CWnd(); //"create" the instance wnd.Create(......); or wnd->Create(.....);
¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog
-
Again, you're using terms incorrectly. Saying you want to use a "modeless listbox" doesn't make any sense. I suspect what you want is to display a modeless *dialog* with a list box in it. Look up CDialog, and the differences between DoModal and a modeless dialog in MSDN.
¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog