// // RemoveAllFromMap // // Removes all objects from the map // void RemoveAllFromMap() { NList<MapObj>::Iterator i(&listOnMap); while (*i) { RemoveFromMap(i++); } ASSERT(!listOnMap.GetCount()); }
// // RegisterDestruction // // Register the destruction of an object // void RegisterDestruction(MapObj *obj) { ASSERT(obj); // Is it still on the map if (obj->OnMap()) { RemoveFromMap(obj); } ASSERT(!obj->OnMap()); // Remove from the off-map list listOffMap.Unlink(obj); // Remove from the display list if (obj->displayNode.InUse()) { listDisplay.Unlink(obj); } }
/** * Remove the dir from the g_OpenDirs map. * @param[in] i The index of the dir handle to remove. */ static void RemoveDirFromMap(int i) { RemoveFromMap((void**)g_OpenDirs, MAX_OPEN_DIRS, i); }
/** * Remove the file from the g_OpenFiles map. * @param[in] i The index of the file handle to remove. */ static void RemoveFileFromMap(int i) { RemoveFromMap((void**)g_OpenFiles, MAX_OPEN_FILES, i); }
LRESULT ActiveCombobox::WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam) { switch (nMsg) { case WM_MOUSEACTIVATE: return MA_NOACTIVATE; case WM_DESTROY: { long nStart, nLength; SendMessage(CB_GETEDITSEL, (LPARAM)&nStart, (LPARAM)&nLength); m_pTool->tpV1.m_nSelStart = (short)nStart; m_pTool->tpV1.m_nSelLength = (short)nLength; m_pTool->m_bPressed = FALSE; m_pTool->m_bDropDownPressed = FALSE; UnsubClass(); LRESULT lResult = FWnd::WindowProc(nMsg, wParam, lParam); m_pTool->m_pBand->Refresh(); m_pTool->m_pBar->m_pTabbedTool = NULL; RemoveFromMap(); delete this; return lResult; } break; case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = BeginPaint(m_hWnd, &ps); if (hDC) { CRect rcClient; GetClientRect(rcClient); rcClient.Inflate(0, -1); ComboStyles nStyle; m_pTool->get_CBStyle(&nStyle); if (VARIANT_FALSE == m_pTool->m_pBar->bpV1.m_vbXPLook) { m_pTool->DrawCombo(hDC, rcClient, m_pTool->m_bDropDownPressed, 0 != (nStyle == ddCBSReadOnly || nStyle == ddCBSSortedReadOnly)); } else { m_pTool->DrawXPCombo(hDC, rcClient, m_pTool->m_bDropDownPressed, 0 != (nStyle == ddCBSReadOnly || nStyle == ddCBSSortedReadOnly)); } EndPaint(m_hWnd, &ps); } return 0; } break; case WM_COMMAND: { switch (HIWORD(wParam)) { case CBN_CLOSEUP: { // Save the text LRESULT lResult = SendMessage(CB_GETCURSEL); CTool* pToolTemp = m_pTool; pToolTemp->GetComboList()->lpV1.m_nListIndex = (short)lResult; if (CB_ERR != lResult) { int nLen = SendMessage(CB_GETLBTEXTLEN, lResult, 0); if (0 != nLen) { TCHAR* szBuffer = new TCHAR[nLen+1]; if (szBuffer) { try { lResult = SendMessage(CB_GETLBTEXT, lResult, (LPARAM)szBuffer); if (CB_ERR != lResult) { MAKE_WIDEPTR_FROMTCHAR(wBuffer, szBuffer); HRESULT hResult = pToolTemp->put_Text(wBuffer); assert(SUCCEEDED(hResult)); if (SUCCEEDED(hResult)) { pToolTemp->AddRef(); ::PostMessage(m_pTool->m_pBar->m_hWnd, GetGlobals().WM_ACTIVEBARTEXTCHANGE, 0, (LPARAM)m_pTool); } } } CATCH { assert(FALSE); REPORTEXCEPTION(__FILE__, __LINE__) } delete [] szBuffer; } } } try { // Fire the combo close event pToolTemp->m_pBar->FireToolComboClose((Tool*)pToolTemp); } catch (...) { assert(FALSE); REPORTEXCEPTION(__FILE__, __LINE__) } // Reset the tool pToolTemp->m_bPressed = FALSE; pToolTemp->m_bDropDownPressed = FALSE; if (IsWindow()) ShowWindow(SW_HIDE); } break; case CBN_KILLFOCUS: SendMessage(WM_CANCELMODE); ShowWindow(SW_HIDE); break; case CBN_DROPDOWN: { m_pTool->m_bPressed = TRUE; m_pTool->m_bDropDownPressed = TRUE; CBList* pList = m_pTool->GetComboList(); if (NULL == pList) break; int nPrevCount = pList->Count(); m_pTool->m_pBar->FireComboDrop((Tool*)m_pTool); int nPrevLines = pList->lpV1.m_nLines; if (nPrevCount != pList->Count()) { SendMessage(CB_RESETCONTENT, 0, 0); pList->m_hWndActive = m_hWnd; BSTR bstrItem; int nCount = pList->Count(); for (int nItem = 0; nItem < nCount; nItem++) { bstrItem = pList->GetName(nItem); if (bstrItem) { MAKE_TCHARPTR_FROMWIDE(szItem, bstrItem); SendMessage(CB_ADDSTRING, 0, (LPARAM)szItem); } } switch (pList->lpV1.m_nStyle) { case ddCBSReadOnly: case ddCBSSortedReadOnly: { MAKE_TCHARPTR_FROMWIDE(szText, m_pTool->m_bstrText); int nIndex = SendMessage(CB_FINDSTRING, (WPARAM)-1, (LPARAM)szText); if (CB_ERR != nIndex) SendMessage(CB_SETCURSEL, nIndex, 0); } break; default: SendMessage(CB_SETCURSEL, pList->lpV1.m_nListIndex); break; } } if (nPrevLines == pList->lpV1.m_nLines) break; CRect rcCB; GetWindowRect(rcCB); int nItemHeight = SendMessage(CB_GETITEMHEIGHT, 0, 0); int nComboHeight = pList->lpV1.m_nLines * nItemHeight + rcCB.Height() + 2; ::MoveWindow(m_hWnd, 0, 0, rcCB.Width(), nComboHeight, FALSE); } break; case CBN_SELCHANGE: { try { int nIndex = SendMessage(CB_GETCURSEL); m_pTool->GetComboList()->lpV1.m_nListIndex = nIndex; assert (CB_ERR != nIndex); if (CB_ERR != nIndex) { int nLen = SendMessage(CB_GETLBTEXTLEN, nIndex, 0); assert(0 != nLen); if (0 != nLen) { TCHAR* szBuffer = new TCHAR[nLen + 1]; assert(szBuffer); if (szBuffer) { HRESULT hResult; LRESULT lResult = SendMessage(CB_GETLBTEXT, nIndex, (LPARAM)szBuffer); assert(CB_ERR != lResult); if (CB_ERR != lResult) { MAKE_WIDEPTR_FROMTCHAR(wBuffer,szBuffer); hResult = m_pTool->put_Text(wBuffer); assert(SUCCEEDED(hResult)); } UpdateWindow(); delete szBuffer; } } } m_pTool->AddRef(); ::PostMessage(m_pTool->m_pBar->m_hWnd, GetGlobals().WM_ACTIVEBARCOMBOSELCHANGE, 0, (LPARAM)m_pTool); } catch (...) { assert(FALSE); } } break; case CBN_EDITCHANGE: { static bool m_bInExchange = FALSE; if (m_bInExchange) break; m_bInExchange = TRUE; // Transfer text HRESULT hResult; int nLen = SendMessage(WM_GETTEXTLENGTH); if (nLen > 0) { TCHAR* szBuffer = new TCHAR[nLen+1]; if (NULL == szBuffer) { m_bInExchange = FALSE; break; } if (SendMessage(WM_GETTEXT, nLen+1, (LPARAM)szBuffer) > 0) { MAKE_WIDEPTR_FROMTCHAR(wBuffer, szBuffer); hResult = m_pTool->put_Text(wBuffer); if (SUCCEEDED(hResult)) { m_pTool->AddRef(); ::PostMessage(m_pTool->m_pBar->m_hWnd, GetGlobals().WM_ACTIVEBARTEXTCHANGE, 0, (LPARAM)m_pTool); } } else { hResult = m_pTool->put_Text(L""); if (SUCCEEDED(hResult)) { m_pTool->AddRef(); ::PostMessage(m_pTool->m_pBar->m_hWnd, GetGlobals().WM_ACTIVEBARTEXTCHANGE, 0, (LPARAM)m_pTool); } } delete [] szBuffer; } else { hResult = m_pTool->put_Text(L""); if (SUCCEEDED(hResult)) { m_pTool->AddRef(); ::PostMessage(m_pTool->m_pBar->m_hWnd, GetGlobals().WM_ACTIVEBARTEXTCHANGE, 0, (LPARAM)m_pTool); } } m_bInExchange = FALSE; } break; } }