Example #1
0
BOOL CListCtrlEx::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	CRect rect;
	CListCtrlEx::GetClientRect(rect);
	
	POINT mypoint;  
	
	CBrush brush0(m_colRow1);
	CBrush brush1(m_colRow2);
	
	int chunk_height=GetCountPerPage();
	pDC->FillRect(&rect,&brush1);
	
	for (int i=0;i<=chunk_height;i++)
	{
		GetItemPosition(i,&mypoint);
		rect.top=mypoint.y ;
		GetItemPosition(i+1,&mypoint);
		rect.bottom =mypoint.y;
		pDC->FillRect(&rect,i %2 ? &brush1 : &brush0);
		
	}
	brush0.DeleteObject();
	brush1.DeleteObject();
	
	//return FALSE;
	return CListCtrl::OnEraseBkgnd(pDC);
}
Example #2
0
int CEnHeaderCtrl::GetItemPosition(int nItem) const
{
	CIntArray aOrder;
	GetItemOrder(aOrder);

	return GetItemPosition(nItem, aOrder);
}
Example #3
0
int CEnHeaderCtrl::GetNextVisibleItem(int nItem, BOOL bNext) const
{
	CIntArray aOrder;
	int nNumItems = GetItemOrder(aOrder);
	
	int nPos = GetItemPosition(nItem, aOrder);
	
	if (nPos != -1)
	{
		if (bNext)
		{
			while (++nPos < nNumItems)
			{
				nItem = OrderToIndex(nPos);

				if (IsItemVisible(nItem) && GetItemWidth(nItem))
					return nItem;
			}
		}
		else
		{
			while (nPos--)
			{
				nItem = OrderToIndex(nPos);
				
				if (IsItemVisible(nItem) && GetItemWidth(nItem))
					return nItem;
			}
		}
	}

	// outside range
	return -1;
}
Example #4
0
void CPageNavigator::EnsureIconVisible(int nItem)
{
	RECT ItemRect = {0,0,0,0};
	GetIconRect(nItem, &ItemRect);
	RECT ClientRect = {0,0,0,0};
	GetClientRect(&ClientRect);

	int iDelta = 0;
	int dx = (ClientRect.left + m_xLeft) - ItemRect.left;
	if (dx > 0)
		iDelta = dx;
	dx = (ClientRect.right - m_xLeft) - ItemRect.right;
	if (dx < 0)
		iDelta = dx;
	if (!iDelta)
		return;
		
	for (int i = 0; i < GetItemCount(); i++)
	{
		POINT pt = {0,0};
		GetItemPosition(i, &pt);
		pt.x += iDelta;
		SetItemPosition(i, pt);
	}
}
Example #5
0
/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl message handlers
void CMyListCtrl::OnBeginDrag(LPNMHDR pnmhdr, LRESULT *pResult)
{
    CPoint			ptItem, ptAction, ptImage;
    NM_LISTVIEW		*pnmListView = (NM_LISTVIEW *)pnmhdr;

    ((CListCtrlPage *)GetParent())->ShowNotification(pnmhdr, pResult);
    ASSERT(!m_bDragging);
    m_bDragging = TRUE;
    m_iItemDrag = pnmListView->iItem;
    ptAction = pnmListView->ptAction;
    GetItemPosition(m_iItemDrag, &ptItem);  // ptItem is relative to (0,0) and not the view origin
    GetOrigin(&m_ptOrigin);

    ASSERT(m_pimageListDrag == NULL);
    m_pimageListDrag = CreateDragImage(m_iItemDrag, &ptImage);
    m_sizeDelta = ptAction - ptImage;   // difference between cursor pos and image pos
    m_ptHotSpot = ptAction - ptItem + m_ptOrigin;  // calculate hotspot for the cursor
    m_pimageListDrag->DragShowNolock(TRUE);  // lock updates and show drag image
    m_pimageListDrag->SetDragCursorImage(0, m_ptHotSpot);  // define the hot spot for the new cursor image
    m_pimageListDrag->BeginDrag(0, CPoint(0, 0));
    ptAction -= m_sizeDelta;
    m_pimageListDrag->DragEnter(this, ptAction);
    m_pimageListDrag->DragMove(ptAction);  // move image to overlap original icon
    SetCapture();
}
Example #6
0
void CMyListCtrl::OnBeginDrag(LPNMHDR pnmhdr,LRESULT*)
{
  CPoint ptItem,ptAction,ptImage;
  NM_LISTVIEW *pnmListView = (NM_LISTVIEW *)pnmhdr;
  m_oldDNDStyle = GetExtendedStyle();

  if(m_oldDNDStyle != 0)SetExtendedStyle(0);
  ASSERT(!m_bDragging);
  m_bDragging = TRUE;
  m_iItemDrag = pnmListView->iItem;
  ptAction = pnmListView->ptAction;
  GetItemPosition(m_iItemDrag,&ptItem);
  GetOrigin(&m_ptOrigin);
  ASSERT(m_pImageListDrag == NULL);
  m_pImageListDrag = CreateDragImage(m_iItemDrag,&ptImage);
  m_sizeDelta = ptAction - ptImage;
  m_ptHotSpot = ptAction - ptItem + m_ptOrigin;
  m_pImageListDrag->DragShowNolock(TRUE);
  m_pImageListDrag->SetDragCursorImage(0,CPoint(0,0));
  m_pImageListDrag->BeginDrag(0,CPoint(0,0));

  ptAction -=m_sizeDelta;
  m_pImageListDrag->DragEnter(this,ptAction);
  m_pImageListDrag->DragMove(ptAction);
  m_iItemDrop = -1;
  SetCapture();
}
Example #7
0
BOOL CClonePairListCtrl::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default

  CRect rect;
  CClonePairListCtrl::GetClientRect(rect);


  POINT mypoint;  
  
  CBrush brush0(m_colRow1);
  CBrush brush1(m_colRow2);


 
 int chunk_height=GetCountPerPage();
 //pDC->FillRect(&rect,&brush1);

 int top = 0;
 int bottom = 0;
 GetItemPosition(0,&mypoint);
 top = mypoint.y;
 GetItemPosition(1,&mypoint);
 bottom = mypoint.y;
 int height = bottom - top;
 for (int i=0;i<=chunk_height;i++)
 {
		
	//GetItemPosition(i,&mypoint);
	rect.top=top; //mypoint.y ;
	//GetItemPosition(i+1,&mypoint);
	rect.bottom = bottom; //mypoint.y;
	pDC->FillRect(&rect,i %2 ? &brush1 : &brush0);

	top = bottom;
	bottom +=height;

 }

  brush0.DeleteObject();
  brush1.DeleteObject();

  return FALSE;
}
Example #8
0
/******************************************************************************
Function Name  :  OnEraseBkgnd
Input(s)       :  CDC* - The pointer of Client DC
Output         :  BOOL - Nonzero if it erases the background; otherwise 0.
Functionality  :   
Member of      :  CListCtrlEx
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  30/03/2011
Modifications  :  
******************************************************************************/
BOOL CListCtrlEx::OnEraseBkgnd(CDC* pDC)
{
    CRect omClientRect;
    POINT omItemPos;  

    int nTotalItems =  GetCountPerPage();
    GetClientRect(omClientRect);

    for(int i=0;i<nTotalItems+2;i++)
    {
        GetItemPosition(i,&omItemPos);
        omClientRect.top=omItemPos.y ;
        GetItemPosition(i+1,&omItemPos);
        omClientRect.bottom =omItemPos.y;
        CBrush omBrush(i %2 ? m_colRow1 : m_colRow2);
        pDC->FillRect(&omClientRect, &omBrush);
        omBrush.DeleteObject();
    }
    //Nonzero if it erases the background; otherwise 0.
    return TRUE;
}
Example #9
0
void CPageNavigator::GetIconRect(int nItem, RECT* pRect)
{
	if (!pRect)
		return;
		
	POINT pt = {0,0};
	GetItemPosition(nItem, &pt);

	pRect->left   = pt.x;
	pRect->top    = pt.y;
	pRect->right  = pRect->left + m_dxIcon;
	pRect->bottom = pRect->top  + m_dyIcon;

	RECT TestItemRect = {0,0,0,0};
	bool bOK = !!GetItemRect(nItem, &TestItemRect, LVIR_ICON);
}
Example #10
0
void CuListCtrlLoggedEvent::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	CPoint p, ptItem, ptAction, ptImage;

	UINT nFlags;

	GetCursorPos(&ptAction);
	p = ptAction;
	ScreenToClient(&p);
	m_iItemDrag = HitTest(p, &nFlags);
	if (!(m_iItemDrag != -1 || (nFlags&TVHT_ONITEM)))
	{
		m_iItemDrag = -1;
		m_bDragging = FALSE;
		return;
	}
	if (!m_pEventSettingFrame)
		m_pEventSettingFrame = (CfEventSetting*)GetParentFrame();
	CvEventSettingBottom* pBottomView= m_pEventSettingFrame->GetBottomView();
	CListCtrl* pListCtrl = pBottomView->GetListCtrl();; 
	CaLoggedEvent* pMsg = (CaLoggedEvent*)pListCtrl->GetItemData (m_iItemDrag);
	if (pMsg->IsNotFirstLine()) {
		m_iItemDrag = -1;
		m_bDragging = FALSE;
		return;
	}



	ASSERT(!m_bDragging);
	m_bDragging = TRUE;

	ASSERT(m_pImageListDrag == NULL);
	m_pImageListDrag = CreateDragImage(m_iItemDrag, &ptImage);
	GetItemPosition(m_iItemDrag, &ptItem);         // ptItem is relative to (0,0) and not the view origin
	m_sizeDelta = ptAction - ptImage;              // difference between cursor pos and image pos
	m_ptHotSpot = ptAction - ptItem + m_ptOrigin;  // calculate hotspot for the cursor
	m_pImageListDrag->DragShowNolock(TRUE);        // lock updates and show drag image
	m_pImageListDrag->SetDragCursorImage(0, CPoint(0, 0) /*m_ptHotSpot*/);  // define the hot spot for the new cursor image
	m_pImageListDrag->BeginDrag(0, CPoint(0, 0));

	m_pImageListDrag->DragEnter(/*this*/GetParentFrame(), ptAction);
	m_pImageListDrag->DragMove(ptAction);  // move image to overlap original icon
	SetCapture();
}
Example #11
0
void  CPictureListView::DrawListViewThumbnails()
{
	// Set the length of the space between thumbnails
	// You can also calculate and set it based on the length of your list control

	// Hold the window update to avoid flicking
	SetRedraw(FALSE);

	// Reset the image list
	for (int i=0; i<m_ImageList.GetImageCount(); i++)
		m_ImageList.Remove(i);	

	// Remove all items from list view
	if (GetItemCount())
		DeleteAllItems();

	// Draw the thumbnails
	i = 0;
	for (int nIndex = 0; nIndex < MAX_NUM_PICTURES; nIndex++)
	{
		CAGSymImage* pImage = m_pParent->GetEnvelopeWizard()->m_pGraphics[nIndex];
		if (!pImage)
			continue;

		BITMAPINFOHEADER* pDib = pImage->GetDib();
		if (!pDib)
			continue;

		// Borrow our dib header to create our thumbnail bitmap
		int nWidth = pDib->biWidth;
		int nHeight = pDib->biHeight;
		pDib->biWidth = m_nThumbnailSize;
		pDib->biHeight = m_nThumbnailSize;

		// Create thumbnail bitmap section
		HBITMAP hBitmap = ::CreateDIBSection(NULL, (BITMAPINFO*)pDib, DIB_RGB_COLORS, NULL, NULL, 0); 

		// Restore the dib header
		pDib->biWidth = nWidth;
		pDib->biHeight = nHeight;

		// Select the thumbnail bitmap into screen dc
		HDC	hMemDC = ::CreateCompatibleDC(NULL);	
		HGDIOBJ	hOldObj = ::SelectObject(hMemDC, hBitmap);

		// Set stretch mode
		::SetStretchBltMode(hMemDC, COLORONCOLOR);

		int dx = m_nThumbnailSize;
		int dy = m_nThumbnailSize;
		ScaleToFit(&dx, &dy, nWidth, nHeight, true/*bUseSmallerFactor*/);

		// Populate the thumbnail bitmap bits
		RECT rect = {0, 0, m_nThumbnailSize, m_nThumbnailSize};
		::FillRect(hMemDC, &rect, CAGBrush(RGB(255,255,255)));
		::StretchDIBits(hMemDC,
						(m_nThumbnailSize - dx)/2, (m_nThumbnailSize - dy)/2,
						dx, dy, 0, 0, nWidth, nHeight, DibPtr(pDib), 
						(BITMAPINFO*)pDib, DIB_RGB_COLORS, SRCCOPY);

		// Restore DC object
		::SelectObject(hMemDC, hOldObj);
	  
		// Clean up
		::DeleteObject(hMemDC);
		
		// Add the bitmap to our image list
		m_ImageList.Add(hBitmap);

		// Set the image file name as item text
		InsertItem(i, "", i);

		// Get the current item position	 
		POINT pt;
		GetItemPosition(i, &pt);	 
	  
		// Shift the thumbnail to desired position
		pt.x = 0; 
		pt.y = i * m_nThumbnailSize;
		SetItemPosition(i, pt);
		i++;
	}

	// Show the new thumbnails
//j	Arrange(LVA_ALIGNLEFT);
	SetRedraw(TRUE); 
}