//MyList.cpp #include "stdafx.h" #include "mylist.h" CMyBitmapList::CMyBitmapList() { L_INT i; for (i=0; i= MAX_COUNT) || (nIndex >= m_nCount)) return NULL; return m_List[nIndex]; } L_VOID CMyBitmapList::RemoveBitmap(L_INT nIndex) { //internal function HWND hWndView = m_List[nIndex]->GetBitmapWnd(); HWND hWnd = GetParent(hWndView); m_List[nIndex]->SetWndHandle(NULL); DWORD dwStyle = ::GetWindowLong(hWndView, GWL_STYLE); dwStyle &= ~(WS_HSCROLL | WS_VSCROLL); ::SetWindowLong(hWndView,GWL_STYLE, dwStyle); ::SetWindowPos(hWndView, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); delete m_List[nIndex]; ::InvalidateRect(hWnd, NULL, TRUE); m_List[nIndex] = 0; } L_INT CMyBitmapList::DeleteLastBitmap() { L_INT nRet; if (m_nCount > 0) { m_nCount--; RemoveBitmap(m_nCount); nRet = FAILURE; } else { nRet = FAILURE; } return nRet; } L_INT CMyBitmapList::DeleteBitmap(L_INT nIndex) { if ((nIndex < 0) || (nIndex >= MAX_COUNT) || (nIndex >= m_nCount)) return FAILURE; if (nIndex + 1 == m_nCount) { DeleteLastBitmap(); } else { RemoveBitmap(nIndex); } return SUCCESS; } L_INT CMyBitmapList::AddBitmap(L_TCHAR *pszFileName, L_INT nBitsPerPixel, L_INT nOrder) { L_INT nIndex = -1; nIndex = NewBitmap(); if (nIndex != -1) { L_INT nRet; nRet = m_List[nIndex]->Load(pszFileName, nBitsPerPixel, nOrder); if (nRet != SUCCESS) { nIndex = -1; DeleteLastBitmap(); } } return nIndex; } L_INT CMyBitmapList::AddBitmap(LBitmapBase &MyBitmapBase) { L_INT nIndex = -1; nIndex = NewBitmap(); if (nIndex != -1) { L_INT nRet; nRet = m_List[nIndex]->Copy(MyBitmapBase); if (nRet != SUCCESS) { nIndex = -1; DeleteLastBitmap(); } } return nIndex; } L_INT CMyBitmapList::GetCount() { L_INT nCount = 0; L_INT i; for (i=0; i