ListBox??
-
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..
-
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..
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.
-
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.
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
-
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
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.
-
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.
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
-
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
"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.
-
"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.
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 :)