Results 1 to 5 of 5

Thread: Help in reducing this code...

  1. #1

    Thread Starter
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104

    Arrow 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 );
    		}
    	}

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Is that MFC?

  3. #3

    Thread Starter
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104
    Originally posted by kasracer
    Is that MFC?
    Yes it is...

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  5. #5

    Thread Starter
    Banned debbie_82's Avatar
    Join Date
    Jan 2004
    Location
    inside a hollow void
    Posts
    104
    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
  •  



Click Here to Expand Forum to Full Width