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. ListBox??

ListBox??

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
7 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, I made a list box, and a button. I want the button to do somthing if example: "Print" is selected. But i dont know how. void CTestDlg::OnExe() { if ( ?? == "Print"); { //Do somthing } } The ?? is what i dont know what to put in, it must be somthing like: m_List == "Print" But i tryed that. :) Help is needed. Thank you..

    C 1 Reply Last reply
    0
    • L Lost User

      Hi, I made a list box, and a button. I want the button to do somthing if example: "Print" is selected. But i dont know how. void CTestDlg::OnExe() { if ( ?? == "Print"); { //Do somthing } } The ?? is what i dont know what to put in, it must be somthing like: m_List == "Print" But i tryed that. :) Help is needed. Thank you..

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I think you'll find it's GetItemText(GetCurSel()); The outer gets the text and the inner returns the index of the selected item. Christian The content of this post is not necessarily the opinion of my yadda yadda yadda. To understand recursion, we must first understand recursion.

      L 1 Reply Last reply
      0
      • C Christian Graus

        I think you'll find it's GetItemText(GetCurSel()); The outer gets the text and the inner returns the index of the selected item. Christian The content of this post is not necessarily the opinion of my yadda yadda yadda. To understand recursion, we must first understand recursion.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Can't get it to work, i did this: void CMenuDlg::StartGame() { if (m_Games.GetCurSel("Tribes")); { //Do Somthing } } Error: C:\Dokumenter\C++\Menu\MenuDlg.cpp(180) : error C2660: 'GetCurSel' : function does not take 1 parameters C:\Dokumenter\C++\Menu\MenuDlg.cpp(182) : warning C4390: ';' : empty controlled statement found; is this the intent? Did i do somthing wrong?? Thanks

        D 1 Reply Last reply
        0
        • L Lost User

          Can't get it to work, i did this: void CMenuDlg::StartGame() { if (m_Games.GetCurSel("Tribes")); { //Do Somthing } } Error: C:\Dokumenter\C++\Menu\MenuDlg.cpp(180) : error C2660: 'GetCurSel' : function does not take 1 parameters C:\Dokumenter\C++\Menu\MenuDlg.cpp(182) : warning C4390: ';' : empty controlled statement found; is this the intent? Did i do somthing wrong?? Thanks

          D Offline
          D Offline
          David Fedolfi
          wrote on last edited by
          #4

          You want it to be: void CMenuDlg::StartGame() { if (m_Games.GetLbText(m_Games.GetCurSel()) == "Tribes") { //Do Somthing } } There ia an aletrnative (and possible easier approach). Since you are obviously using this as an application launcher, you coudl store the command line you are executing as m_Games's Item data. Something like teh following; m_Games.SetItemData(m_Games.InsertItem("Tribes"), DWORD("c:\\program files\\tribes\\tribes.exe")); then your start game function woudl look like: CString strCommand = LPCSTR(m_Games.GetItemData(m_Games.GetCurSel())); then call ShellExecute (or whatever you're using to launch the application) with strCommand. Note - this post made before morning coffee and ius therefore subject to containing countless errors and typos.

          L 1 Reply Last reply
          0
          • D David Fedolfi

            You want it to be: void CMenuDlg::StartGame() { if (m_Games.GetLbText(m_Games.GetCurSel()) == "Tribes") { //Do Somthing } } There ia an aletrnative (and possible easier approach). Since you are obviously using this as an application launcher, you coudl store the command line you are executing as m_Games's Item data. Something like teh following; m_Games.SetItemData(m_Games.InsertItem("Tribes"), DWORD("c:\\program files\\tribes\\tribes.exe")); then your start game function woudl look like: CString strCommand = LPCSTR(m_Games.GetItemData(m_Games.GetCurSel())); then call ShellExecute (or whatever you're using to launch the application) with strCommand. Note - this post made before morning coffee and ius therefore subject to containing countless errors and typos.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            I did what you did: void CMenuDlg::StartGame() { if (m_Games.GetLbText(m_Games.GetCurSel()) == "Tribes"); { //Do somthing } } Error: C:\Dokumenter\C++\Menu\MenuDlg.cpp(184) : error C2039: 'GetLbText' : is not a member of 'CListBox' c:\programmer\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox' Dosn't GetLbText belong to a combo box?? Thank's

            D 1 Reply Last reply
            0
            • L Lost User

              I did what you did: void CMenuDlg::StartGame() { if (m_Games.GetLbText(m_Games.GetCurSel()) == "Tribes"); { //Do somthing } } Error: C:\Dokumenter\C++\Menu\MenuDlg.cpp(184) : error C2039: 'GetLbText' : is not a member of 'CListBox' c:\programmer\microsoft visual studio\vc98\mfc\include\afxwin.h(2741) : see declaration of 'CListBox' Dosn't GetLbText belong to a combo box?? Thank's

              D Offline
              D Offline
              David Fedolfi
              wrote on last edited by
              #6

              "Dosn't GetLbText belong to a combo box??" Yeah it does...and didn't I say that that post was written before morning coffee?:) And besides...what do you expect from free advice? Make that m_Games.GetText(m_Games.GetCurSel()) and it shoudl work better.

              S 1 Reply Last reply
              0
              • D David Fedolfi

                "Dosn't GetLbText belong to a combo box??" Yeah it does...and didn't I say that that post was written before morning coffee?:) And besides...what do you expect from free advice? Make that m_Games.GetText(m_Games.GetCurSel()) and it shoudl work better.

                S Offline
                S Offline
                Soren Alsbjerg Horup
                wrote on last edited by
                #7

                if (m_Games.GetText(m_Games.GetCurSel()) == "Tribes") { //Do somthing } Only one error left :) error: Error C2661: 'GetText' : no overloaded function takes 1 parameters Whats an overloaded function?? I got lots to learn :) Ps. Am glad you help's me with this one :)

                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