Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. AddString() function again

AddString() function again

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tyagineha
    wrote on last edited by
    #1

    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

    N J H 3 Replies Last reply
    0
    • T tyagineha

      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

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • T tyagineha

        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

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        tyagineha wrote:

        CMyList myobj; if(myobj.DoModal()) { myobj.Addition("hye"); }

        Called With DoModal(), a dialog is modal (blocking the GUI until it goes away). So DoModal() 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 of CMyList and the call to DoModal(). 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 call AddString() 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 a CDialog-derived class. If you do not want to use CDialog, you would have to Create() 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

        1 Reply Last reply
        0
        • T tyagineha

          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

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Can you explain why you derived CListBox do you have any intent of derived?


          WhiteSky


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups