PDA

Click to See Complete Forum and Search --> : Help in reducing this code...


debbie_82
Feb 2nd, 2004, 09:36 PM
if ( hItem && ((nFlg & TVHT_ONITEMICON) == TVHT_ONITEMICON)){
CItemData *Item = (CItemData *)m_pTreeCtrl->GetItemData(hItem);

if ( Item && Item->child ) {
bCheck = Item->nSelCheck;
theApp.m_pDoc->SetIndexIcon( Item->hItem, m_pTreeCtrl, !bCheck,
theApp.m_pDoc->IsFileInfoComplete( Item, m_pTreeCtrl ) );
if ( bCheck == FALSE ) {
Item->nSelCheck = TRUE;
} else {
Item->nSelCheck = FALSE;
}
theApp.m_pDoc->SetAllParentItems( Item->hItem, Item->nSelCheck, Item->bComplete );

} else if (Item->Kensetu == DPLACE_PHOTO ){
CListBox *pListBoxCtl;
pListBoxCtl = (CListBox*)theApp.m_pView->GetDlgItem( IDC_PHOTO_PATHLIST );
if( pListBoxCtl->GetCount() != 0 ){
if ( Item->nSelCheck ) {
Item->nSelCheck = false;
m_pTreeCtrl->SetItemImage( Item->hItem, 0, 0 );
} else {
Item->nSelCheck = true;
m_pTreeCtrl->SetItemImage( Item->hItem, 1, 1 );
}
m_pTreeCtrl->SetItemData( Item->hItem, (DWORD) Item );
}
} else if (Item->Kensetu != DPLACE_GENERAL && Item->iRootIndx != theApp.m_RootList.GetCount()-1 ) {
// not equal to general & unclassified folders
if ( Item->nSelCheck ) {
Item->nSelCheck = false;
} else {
Item->nSelCheck = true;
}
SetAllChildItems( Item->hItem, Item->nSelCheck );
theApp.m_pDoc->SetAllParentItems( Item->hItem, Item->nSelCheck, Item->bComplete );
}
}

Kasracer
Feb 2nd, 2004, 10:39 PM
Is that MFC?

debbie_82
Feb 3rd, 2004, 12:28 AM
Originally posted by kasracer
Is that MFC?

Yes it is...

CornedBee
Feb 4th, 2004, 10:54 AM
I don't see any room for improvement except that:
if ( Item->nSelCheck ) {
Item->nSelCheck = false;
} else {
Item->nSelCheck = true;
}[code]
should be
[code]Item->nSelCheck = !Item->nSelCheck
,
if ( bCheck == FALSE ) {
Item->nSelCheck = TRUE;
} else {
Item->nSelCheck = FALSE;
}
should be
Item->nSelCheck = !bCheck;
and
if ( Item->nSelCheck ) {
Item->nSelCheck = false;
m_pTreeCtrl->SetItemImage( Item->hItem, 0, 0 );
} else {
Item->nSelCheck = true;
m_pTreeCtrl->SetItemImage( Item->hItem, 1, 1 );
}
should be
Item->nSelCheck = !Item->nSelCheck;
m_pTreeCtrl->SetItemImage(Item->hItem, Item->nSelCheck, Item->nSelCheck);

debbie_82
Feb 4th, 2004, 07:44 PM
Yup I actually realized that when I really checked this code, One can only save one variable... plus a lot of lines...:blush:
Tnx