|
-
Feb 2nd, 2004, 09:36 PM
#1
Thread Starter
Banned
Help in reducing this code...
Code:
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 );
}
}
-
Feb 2nd, 2004, 10:39 PM
#2
-
Feb 3rd, 2004, 12:28 AM
#3
Thread Starter
Banned
Originally posted by kasracer
Is that MFC?
Yes it is...
-
Feb 4th, 2004, 10:54 AM
#4
I don't see any room for improvement except that:
[code]if ( Item->nSelCheck ) {
Item->nSelCheck = false;
} else {
Item->nSelCheck = true;
}[code]
should be
Code:
Item->nSelCheck = !Item->nSelCheck
,
Code:
if ( bCheck == FALSE ) {
Item->nSelCheck = TRUE;
} else {
Item->nSelCheck = FALSE;
}
should be
Code:
Item->nSelCheck = !bCheck;
and
Code:
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
Code:
Item->nSelCheck = !Item->nSelCheck;
m_pTreeCtrl->SetItemImage(Item->hItem, Item->nSelCheck, Item->nSelCheck);
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 4th, 2004, 07:44 PM
#5
Thread Starter
Banned
Yup I actually realized that when I really checked this code, One can only save one variable... plus a lot of lines...
Tnx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|