At 7/12/2004 01:40 PM, Palmer, Jean L. wrote:

>No, you understand correctly.
>
>But, with my list as an example, I have 68 items in the list.  So I have to
>set each line in the list like this (or in a switch statement):
>if (dwGetItemDataValue == 1)
>    csNew = Get1();
>else if (dwGetItemDataValue == 2)
>    csNew = Get2();
>else if (dwGetItemDataValue == 3)
>    csNew = Get3();
>etc. etc.  all the way to 68, very tedious... and think of how I have to
>rewrite the numbering if I insert a new list item in the middle of the list.
>
>And it even gets more complicated because the number of items in my list
>varies.  Sometimes it might be 68 items long, and sometimes it might be 22
>(or other numbers) items long. So sometimes the 60th item in the list would
>use Get60() and at other times the 40th item in the list would use GetXX()
>(some other 'Get' function).
>
>It just would make a lot more sense to assign a pointer to function or a
>pointer to member to each list item.

I don't know. This code seems pretty simple to me. But I do only have 12 columns.

But naming them by column number is probably not a good idea. Just give them appropriate names.

void AeciUiPpMgtImages::OnGetImagesDispInfo (
    NMHDR* pNMHDR, LRESULT* pResult)
{
    LV_DISPINFO* plvDispInfo = (LV_DISPINFO*)pNMHDR;
    *pResult = 0;
    NP_ASSERT(plvDispInfo->item.iSubItem < kIMAGES_NUM_COLUMNS);

    int nIndex = plvDispInfo->item.lParam;

    static AeciRmCString csName;
    CTime ctTime;

    switch (mnColumnId[plvDispInfo->item.iSubItem]) {
      case kIMGMGTCOL_NAME:
        csName = marrImages[nIndex]->name();
        break;
      case kIMGMGTCOL_STATUS:
        csName = marrImages[nIndex]->loadStatus();
        break;
      case kIMGMGTCOL_SAVEDPATH:
        csName = marrImages[nIndex]->savedPath();
        break;
      case kIMGMGTCOL_ACTIVEPATH:
        csName = marrImages[nIndex]->activePath();
        break;
      case kIMGMGTCOL_CREATED:
        csName = marrImages[nIndex]->fileCreateDate(ctTime);
        break;
      case kIMGMGTCOL_MODIFIED:
        csName = marrImages[nIndex]->fileModDate(ctTime);
        break;
      case kIMGMGTCOL_SIZE:
        csName = marrImages[nIndex]->fileSize();
        break;
      case kIMGMGTCOL_DENSITY:
        csName = marrImages[nIndex]->density();
        break;
      case kIMGMGTCOL_FILETYPE:
        csName = marrImages[nIndex]->fileType();
        break;
      case kIMGMGTCOL_DEPTH:
        csName = marrImages[nIndex]->depth();
        break;
      case kIMGMGTCOL_COLORTYPE:
        csName = marrImages[nIndex]->colorType();
        break;
      case kIMGMGTCOL_OTHER:
        csName = marrImages[nIndex]->other();
        break;
    }
    plvDispInfo->item.pszText = (LPTSTR)(LPCTSTR)csName;
}

Phil Daley          < AutoDesk >
http://www.conknet.com/~p_daley




_______________________________________________ msvc mailing list [EMAIL PROTECTED] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.

Reply via email to