void CCheckListBox::AdjustChildren(int nIndex) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { BOOL fMark = pListBoxItem->Mark(); int nCount = GetCount(); if (nCount != LB_ERR) { for (int nChildIndex = nIndex+1; nChildIndex < nCount; nChildIndex++) { CCheckListBoxItem* pChildListBoxItem = GetListBoxItem(nChildIndex); if (pChildListBoxItem != NULL) { if (pChildListBoxItem->Indent() <= pListBoxItem->Indent()) { break; } if (pChildListBoxItem->Indent() > pListBoxItem->Indent()) { if (!pChildListBoxItem->Disable()) { MarkItem(pChildListBoxItem, nChildIndex, fMark); } } } } } } }
/* Obfuscates as in grid table */ void Call_Obfuscate() { CHAR kwrd[100],nwkw[100]; (LRESULT)BSize = (WPARAM)SendMessage(hwMResEdit,WM_GETTEXTLENGTH,0,0); BSize++; SrcPtr = malloc(BSize*2); // +some reserve SendMessage(hwMResEdit,WM_GETTEXT,BSize,SrcPtr+1); SrcPtr[0]=0; for(pi=-1;;) { if((pi = ListView_GetNextItem(hwKwGrid, pi, LVNI_ALL ))<0) break; i=0; GetListBoxItem(nwkw); // new keyword GetListBoxItem(kwrd); // keyword GetListBoxItem(buf); // cnt,ignore GetListBoxItem(buf); // descr. if( nwkw[0]!=0 ) { Obfuscate( SrcPtr+1, nwkw, kwrd, isCheckBoxChecked(hwO2), (strstr("func",buf)!=NULL) ); } } setText(hwOResEdit,SrcPtr+1); free(SrcPtr); }
BOOL CCheckListBox::AdjustParents(int nIndex /*=0*/) { BOOL fResult = FALSE; int nCount = GetCount(); if ((nCount > 0) && (nCount != LB_ERR)) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { fResult = pListBoxItem->Mark(); BOOL fSeenChild = FALSE; for (int nChildIndex = nIndex+1; nChildIndex < nCount; nChildIndex++) { CCheckListBoxItem* pChildListBoxItem = GetListBoxItem(nChildIndex); if (pChildListBoxItem != NULL) { if (pChildListBoxItem->Indent() <= pListBoxItem->Indent()) { break; } if (!fSeenChild) { fResult = TRUE; fSeenChild = TRUE; } if (pChildListBoxItem->Indent() == pListBoxItem->Indent()+1) { fResult &= AdjustParents(nChildIndex); } } } if ((!fResult) || ((m_dwStyle & CHECK_LIST_BOX_DisableAutoMarkParent) == 0)) { MarkItem(pListBoxItem, nIndex, fResult); } } } return fResult; }
void COrderListBox::AdjustFree(void) { int nCount; int nIndex; // Check if an item is marked that costs money... Only then do // we shower the user with free item(s)! BOOL fNonFreeMarked = FALSE; nCount = GetCount(); if (nCount != LB_ERR) { for (nIndex = 0; nIndex < nCount; nIndex++) { CProductCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if ((pListBoxItem != NULL) && (pListBoxItem->Mark())) { CProductItem* pItem = pListBoxItem->Item(); if ((pItem != NULL) && ((!(pItem->TestFlag(PRODUCT_ITEM_Free))))) { fNonFreeMarked = TRUE; break; } } } // Go through and mark or clear all the free items. for (nIndex = 0; nIndex < nCount; nIndex++) { CProductCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { CProductItem* pItem = pListBoxItem->Item(); if ((pItem != NULL) && (pItem->TestFlag(PRODUCT_ITEM_Free))) { MarkItem(pListBoxItem, nIndex, fNonFreeMarked); } } } } }
void CProductCheckListBox::DisableLicensedItems(void) { int nCount = GetCount(); if (nCount != LB_ERR) { for (int nIndex = 0; nIndex < nCount; nIndex++) { CProductCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { BOOL fLicensed = pListBoxItem->Item()->IsLicensed(); DisableItem(pListBoxItem, nIndex, fLicensed); if (fLicensed) { MarkItem(pListBoxItem, nIndex, TRUE); SelectItem(pListBoxItem, nIndex, FALSE); } } } } }
int CCheckListBox::AdjustSelections(int nIndex /*=0*/, int nIndent /*=0*/, BOOL fForceDeselect /*=FALSE*/) { int nCount = GetCount(); if ((nCount > 0) && (nCount != LB_ERR)) { while (nIndex < nCount) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); BOOL fSelect = FALSE; if (pListBoxItem != NULL) { if (pListBoxItem->Indent() < nIndent) { return nIndex; } fSelect = !fForceDeselect && pListBoxItem->Mark(); if (!pListBoxItem->Disable()) { SelectItem(pListBoxItem, nIndex, fSelect); } } nIndex = AdjustSelections(nIndex+1, nIndent+1, fForceDeselect || fSelect); } } return nCount; }
BOOL COrderListBox::Select(int nIndex, BOOL fMark, BOOL fDragging) { CProductCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { if (!pListBoxItem->Disable()) { CProductItem* pItem = pListBoxItem->Item(); if (pItem->TestFlag(PRODUCT_ITEM_Free)) { /* Attempting to change state of a free catagory. */ if (!fDragging) { ::AfxMessageBox("This collection contains free graphics.\n" "It is automatically added to your first order."); return FALSE; } return TRUE; } } } return CProductCheckListBox::Select(nIndex, fMark, fDragging); }
void CCheckListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if (GetCapture() != this) { if (nChar == VK_SPACE) { int nIndex = GetCurSel(); if (nIndex >= 0) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { Select(nIndex, !pListBoxItem->Mark(), FALSE); #ifdef WIN32 GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_SELCHANGE), (LPARAM)GetSafeHwnd()); #else GetParent()->SendMessage(WM_COMMAND, GetDlgCtrlID(), MAKELPARAM(GetSafeHwnd(), LBN_SELCHANGE)); #endif } } } else { COwnerDrawListBox::OnKeyDown(nChar, nRepCnt, nFlags); } } }
void CCheckListBox::OnLButtonDown(UINT nFlags, CPoint point) { if (GetCapture() != this) { int nIndex = Index(point); BOOL fCapture = TRUE; if (nIndex >= 0) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { m_fMark = !pListBoxItem->Mark(); m_nCurrent = nIndex; SetCurSel(nIndex); fCapture = Select(nIndex, m_fMark, FALSE); SetFocus(); #ifdef WIN32 GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_SELCHANGE), (LPARAM)GetSafeHwnd()); #else GetParent()->SendMessage(WM_COMMAND, GetDlgCtrlID(), MAKELPARAM(GetSafeHwnd(), LBN_SELCHANGE)); #endif } } if (fCapture) { StartTimer(); SetCapture(); } } }
BOOL CCheckListBox::SiblingIsMarked(int nIndex) { int nIndent = GetListBoxItem(nIndex)->Indent(); int nCount = GetCount(); int nChildIndex; if (nCount != LB_ERR) { // Look back. for (nChildIndex = nIndex-1; nChildIndex >= 0; nChildIndex--) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nChildIndex); if (pListBoxItem != NULL) { if (pListBoxItem->Indent() < nIndent) { break; } if (pListBoxItem->Mark()) { return TRUE; } } } // Look forward. for (nChildIndex = nIndex+1; nChildIndex < nCount; nChildIndex++) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nChildIndex); if (pListBoxItem != NULL) { if (pListBoxItem->Indent() < nIndent) { break; } if (pListBoxItem->Mark()) { return TRUE; } } } } return FALSE; }
bool CSetDlgLists::GetListBoxItem(HWND hWnd, WORD nCtrlId, eWordItems eWhat, BYTE& nValue) { UINT dwValue = nValue; bool bFound = GetListBoxItem(hWnd, nCtrlId, eWhat, dwValue); _ASSERTE(dwValue==LOBYTE(dwValue)); nValue = LOBYTE(dwValue); return bFound; }
CProductItem* CProductCheckListBox::GetItem(int nIndex) const { CProductCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem == NULL) { return NULL; } return pListBoxItem->Item(); }
int CCheckListBox::GetSel(int nIndex) const { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { return (int)(pListBoxItem->Select()); } return LB_ERR; }
static void copyLBLinetoEditCtl( unsigned index ) { char *lb_item; unsigned len; lb_item = uimalloc( MAX_EDIT_LINE_LEN ); GetListBoxItem( &listData, index, lb_item, MAX_EDIT_LINE_LEN ); len = strlen( lb_item ); uifree( editCtl.buffer ); editCtl.buffer = lb_item; editCtl.length = len; uiupdateedit( curHelpDialog, editVField ); uiprintfield( curHelpDialog, editVField ); }
void CProductCheckListBox::UpdateProductItems(void) { GetApp()->Offer()->ClearProductFlags(); int nCount = GetCount(); if (nCount != LB_ERR) { for (int nIndex = 0; nIndex < nCount; nIndex++) { CProductCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { pListBoxItem->UpdateProductItem(); } } } }
BOOL CCheckListBox::Select(int nIndex, BOOL fMark, BOOL fDragging) { CCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { if (!pListBoxItem->Disable()) { if (pListBoxItem->Mark() != fMark) { MarkItem(pListBoxItem, nIndex, fMark); AdjustChildren(nIndex); AdjustFree(); AdjustParents(); AdjustSelections(); } } } return TRUE; }
void COrderListBox::UpdateMarkedItems(void) { int nCount = GetCount(); if (nCount != LB_ERR) { for (int nIndex = 0; nIndex < nCount; nIndex++) { CProductCheckListBoxItem* pChild = GetListBoxItem(nIndex); if (!pChild->Disable()) { CProductItem* pItem = pChild->Item(); MarkItem(pChild, nIndex, pItem->TestFlag(PRODUCT_ITEM_Marked)); } } AdjustFree(); AdjustParents(); AdjustSelections(); } }
BOOL COrderListBox::Select(int nIndex, BOOL fMark, BOOL fDragging) { CProductCheckListBoxItem* pListBoxItem = GetListBoxItem(nIndex); if (pListBoxItem != NULL) { if (!pListBoxItem->Disable()) { CProductItem* pItem = pListBoxItem->Item(); if (pItem->TestFlag(PRODUCT_ITEM_Free)) { /* Attempting to change state of a free catagory. */ if (!fDragging) { ::AfxMessageBox(IDS_FREE_CATEGORY); return FALSE; } return TRUE; } } } return CProductCheckListBox::Select(nIndex, fMark, fDragging); }