Click here to Skip to main content
15,909,827 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalproblem drawing stretched image Pin
nm_11419-May-04 19:11
nm_11419-May-04 19:11 
Generalvcpp6 keeps hanging Pin
closecall19-May-04 17:16
closecall19-May-04 17:16 
GeneralVisual Studio .NET vs old mfc class Pin
zecodela19-May-04 17:09
zecodela19-May-04 17:09 
GeneralRe: Visual Studio .NET vs old mfc class Pin
Christian Graus19-May-04 17:27
protectorChristian Graus19-May-04 17:27 
GeneralRe: Visual Studio .NET vs old mfc class Pin
Michael P Butler19-May-04 22:36
Michael P Butler19-May-04 22:36 
GeneralCombo Boxes and numbers Pin
Eversman19-May-04 16:56
Eversman19-May-04 16:56 
GeneralRe: Combo Boxes and numbers Pin
Mahendra_78619-May-04 21:33
Mahendra_78619-May-04 21:33 
GeneralRe: Combo Boxes and numbers Pin
Andrew Quinn AUS19-May-04 23:50
Andrew Quinn AUS19-May-04 23:50 
Hi,

As a side issue have you considered using SetItemData to make the code look cleaner?

e.g. create enum for the Activity:

enum enumActivity
{
    eSwim = 0,
    eRun,
    eCycle,
    eStretch
};


Then when you create both combos...

// populate duration drop-down
CString strText;
for(int t=10; t<=60; t++)
{
   strText.Format("%d Minutes");
   int nIdx = m_dur2.AddString(strText);
   if (nIdx >= 0) m_sur2.SetItemData(nIdx, t);
}

// populate activity drop-down
int nIdx2 = m_type2.AddString(_T("Swimming"));
if (nIdx2 >= 0) m_type2.SetItemData(nIdx2, (DWORD)eSwim);

nIdx2 = m_type2.AddString(_T("Running"));
if (nIdx2 >= 0) m_type2.SetItemData(nIdx2, (DWORD)eRun);

// ... etc ...


Then in the handler you gave the code for you can use a nice switch statement:

int cur1 = m_dur2.GetCurSel ();
int cur = m_type2.GetCurSel ();

switch((enumActivity)m_type2.GetItemData(cur))
{
  case eSwim:
         totalswim += m_dur2.GetItemData(cur1);
         break;
  case eRun:
         totalrun += m_dur2.GetItemData(cur1);
         break;
}
// ...


Hope this helps,
Andy
GeneralShowWindow() problem - MFC Pin
J.B.19-May-04 16:21
J.B.19-May-04 16:21 
GeneralRe: ShowWindow() problem - MFC Pin
nguyenvhn19-May-04 18:18
nguyenvhn19-May-04 18:18 
GeneralRe: ShowWindow() problem - MFC Pin
J.B.19-May-04 18:57
J.B.19-May-04 18:57 
GeneralRe: ShowWindow() problem - MFC Pin
*Dreamz20-May-04 2:23
*Dreamz20-May-04 2:23 
GeneralRe: ShowWindow() problem - MFC Pin
J.B.20-May-04 3:26
J.B.20-May-04 3:26 
GeneralRe: ShowWindow() problem - MFC Pin
*Dreamz20-May-04 3:34
*Dreamz20-May-04 3:34 
GeneralRe: ShowWindow() problem - MFC Pin
J.B.20-May-04 5:16
J.B.20-May-04 5:16 
GeneralRe: ShowWindow() problem - MFC Pin
*Dreamz20-May-04 19:21
*Dreamz20-May-04 19:21 
GeneralA probelm of launching excel from C++ Pin
xiaosongxia19-May-04 16:18
xiaosongxia19-May-04 16:18 
GeneralRe: A problem of launching excel from C++ Pin
Steve S19-May-04 22:37
Steve S19-May-04 22:37 
GeneralMFC and Menus Pin
Eversman19-May-04 16:16
Eversman19-May-04 16:16 
GeneralRe: MFC and Menus Pin
valikac19-May-04 18:31
valikac19-May-04 18:31 
GeneralRe: MFC and Menus Pin
Eversman20-May-04 2:45
Eversman20-May-04 2:45 
GeneralRe: MFC and Menus Pin
valikac20-May-04 5:21
valikac20-May-04 5:21 
GeneralRe: MFC and Menus Pin
Eversman20-May-04 9:36
Eversman20-May-04 9:36 
GeneralRe: MFC and Menus Pin
*Dreamz20-May-04 17:48
*Dreamz20-May-04 17:48 
Generalselect an item from a listctrl Pin
dadacncn19-May-04 13:12
dadacncn19-May-04 13:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.