示例#1
0
// highlight drop targets sort of like CTreeCtrl
BOOL CListCtrlEx::SelectDropTarget(int item)
{
    static int prevHighlight(-1);
    if (item >= 0 && item < GetItemCount())
    {
        if (item != prevHighlight)
        {
            if (prevHighlight >= 0)
            {
                SetItemState(prevHighlight, 0, LVIS_DROPHILITED); // remove highlight from previous target
                RedrawItems(prevHighlight, prevHighlight);
            }

            prevHighlight = item;
            SetItemState(item, LVIS_DROPHILITED, LVIS_DROPHILITED); // highlight target
            RedrawItems(item, item);

            UpdateWindow();
            return TRUE;
        }
    }
    else
    {
        for (int i(0); i < GetItemCount(); ++i)
            SetItemState(i, 0, LVIS_DROPHILITED); // un-highlight all
        prevHighlight = -1;
    }

    return FALSE;
}
//------------------------------------------------------------------------------
//
// 	Function Name:	CMLListCtrl::Redraw()
//
//	Parameters:		iIndex - index of the element to redraw
//
// 	Return Value:	None
//
// 	Description:	This function is called to redraw an element in the list
//
//------------------------------------------------------------------------------
void CMLListCtrl::Redraw(int iIndex)
{
	//	Is the index within range?
	if((iIndex >= 0) && (iIndex < this->GetItemCount()))
	{
		RedrawItems(iIndex, iIndex);
	}	
}
示例#3
0
bool	CReportCtrl::RedrawRow(int SortKey)
{
	int	row = FindRow(SortKey);
	if (row < 0)
		return(FALSE);
	RedrawItems(row, row);
	return(TRUE);
}
void SmartListCtrl::setDropTarget( int index )
{
	bool oldIgnore = ignoreSelMessages_;
	ignoreSelMessages_ = true;
	SetItemState( index, LVIS_DROPHILITED, LVIS_DROPHILITED );
	if ( index != lastListDropItem_ )
	{
		RedrawItems( index, index );
		if ( lastListDropItem_ != -1 ) 
		{
			SetItemState( lastListDropItem_, 0, LVIS_DROPHILITED );
			RedrawItems( lastListDropItem_, lastListDropItem_ );
		}
		UpdateWindow();
		lastListDropItem_ = index;
	}
	ignoreSelMessages_ = oldIgnore;
}
void CxResLibImgList::OnRButtonDown(UINT nFlags, CPoint point)
{
	m_ToolTip.Deactivate();
	Invalidate();

	vector<int> vSel;
	int nCurSel = -1;
	TestItem(vSel, nCurSel);

	m_RMenu.DestroyMenu();

	if ( nCurSel != -1 )
	{
		SetItemState(m_nLastFocusItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
		RedrawItems(m_nLastFocusItem, m_nLastFocusItem);
	}

	if ( nFlags == MK_RBUTTON && m_nLastFocusItem != -1 )
	{
		if ( vSel.size() == 1 )
		{
			ClearCurSel();
			SetItemState(m_nLastFocusItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
			RedrawItems(m_nLastFocusItem, m_nLastFocusItem);
		}

		if ( m_RMenu.GetSafeHmenu() == NULL )
		{
			m_RMenu.LoadMenu(IDR_RESLIB_LIST_POP);
		}
		
		CPoint pt = point;
		ClientToScreen( &pt);
		CMenu * pPopup = m_RMenu.GetSubMenu(0);
		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this);

		//不加这句话时,在图片上点击右键菜单,然后在其他窗口点击鼠标,使右键菜单消失。
		//此时,原来被菜单覆盖的图片区域没有被重绘。
		Invalidate();
	}
	
	CxListCtrl::OnRButtonDown(nFlags, point);
}
void CQueueListCtrl::UpdateAll()
{
	if(theApp.emuledlg->IsRunning())
	{
		RedrawItems(0,GetItemCount());
		//CWnd::UpdateWindow(); //not needed because of sorting
		// Sort table
		SortItems(SortProc, GetSortItem() + (GetSortAscending() ? 0:100));
	}
}
示例#7
0
//-------------------------------------------------------------------//
// OnDrop()																				//
//-------------------------------------------------------------------//
// This function prepares a drop request and passes it on
// to AcceptDrop.
//-------------------------------------------------------------------//
BOOL OleListCtrl::OnDrop(
	CWnd* pWnd,
	COleDataObject* pDataObject,
	DROPEFFECT dropEffect,
	CPoint point
) {

	// Erase the last drop line.
	RedrawItems( m_nItemAboveLine, m_nItemAboveLine );
	UpdateWindow();

	BOOL bReturn = FALSE;

	// Get item under cursor.
	UINT nHitFlags;
	int nUnderCursor = HitTest( point, &nHitFlags );

	// Adjust based on where point is.
	// If we're in the top half of the item, insert before.
	CRect ItemRect;
	GetItemRect( nUnderCursor, &ItemRect, FALSE );
	ItemRect.DeflateRect( 0, 0, 0, ItemRect.Height()/2 );
	bool bInsertAfter = ( ItemRect.PtInRect( point ) == FALSE );

	// Now adjust based on being BELOW all items.
	// Note: this is biased toward REPORT mode.
	if ( nHitFlags & LVHT_NOWHERE )
	{
		nUnderCursor = GetItemCount() - 1;
		bInsertAfter = true;
	}
	
	// Handle all supplied variants of OleDragData with AcceptDrop.
	if ( pDataObject->IsDataAvailable( ClipFormat ) ) {

		bReturn = AcceptDrop(
			nUnderCursor,
			bInsertAfter,
			nHitFlags,
			point,
			pDataObject,
			dropEffect,
			true
		);

	// We don't currently handle text drops.
	// } else if ( pDataObject->IsDataAvailable( CF_TEXT ) ) {

	}

	// Default is to return false if no CF found.
	return bReturn;

}
示例#8
0
//-------------------------------------------------------------------//
// UpdateAfterDrop()																	//
//-------------------------------------------------------------------//
// Here, we redraw after a drop.  Derived classes can do more, e.g.,
// mark a document as dirty, change a caption, whatever.
//-------------------------------------------------------------------//
void OleListCtrl::UpdateAfterDrop( int nFirstInsertedItem, bool bMarkAsDirty )
{
	if ( bMarkAsDirty )
	{
		// Now that we are handling our own data,
		// we need to force a redraw on drop, as
		// all the item placements may have changed.
		RedrawItems( nFirstInsertedItem, GetItemCount() - 1 );
		UpdateWindow();
	}
}
示例#9
0
//***************************************************************
BOOL CColorListCtrl::SetItemTextColor(ITEM_COLOR color, int Index, int iSub)	
{
    CMyLParam *p=GetMyLParam(Index);
    if (!p) return FALSE;
    if ( p->SetTextColor(color, iSub) )
    {
        RedrawItems( Index, Index );
        return TRUE;
    }
    return FALSE;
}
void SmartListCtrl::clearDropTarget()
{
	if ( lastListDropItem_ != -1 )
	{
		bool oldIgnore = ignoreSelMessages_;
		ignoreSelMessages_ = true;
		SetItemState( lastListDropItem_, 0, LVIS_DROPHILITED );
		RedrawItems( lastListDropItem_, lastListDropItem_ );
		UpdateWindow();
		lastListDropItem_ = -1;
		ignoreSelMessages_ = oldIgnore;
	}
}
//焦点改变
void CxResLibImgList::OnFocusChanged( int nItem, BOOL bFocus )
{
	if ( nItem == -1 ) return;
	SetItemState(nItem, 0, LVIS_FOCUSED);
	if (bFocus) SetItemState(nItem, LVIS_FOCUSED, LVIS_FOCUSED);
	RedrawItems(nItem, nItem);

	if (bFocus)
	{
		CResLibData * pBase = reinterpret_cast< CResLibData * > ( GetItemData( nItem ) );
		if (pBase == NULL)
		{
			return;
		}

		//CRect rc;
		//this->GetItemRect(nItem, &rc, LVIR_BOUNDS);
		//CPoint pt = rc.TopLeft();
		//::ClientToScreen(this->GetSafeHwnd(), &pt);
		//pt.Offset(rc.Width()/2, rc.Height()/2);
		//rc.MoveToXY(pt);

		//CString strTip;
		//strTip.Format( "名称:%s\r\n作者:%s\r\n时间:%s\r\n版本:%s\r\n描述:%s"
		//	, pBase->m_sName.c_str()
		//	, pBase->m_sAuthor.c_str()
		//	, pBase->m_sCreatTime.c_str()
		//	, pBase->m_sVersions.c_str()
		//	, pBase->m_sDsec.c_str()
		//	);

		//m_ToolTip.SetTextMargin (TEXT_MARGIN);
		//m_ToolTip.SetFont ( &theApp.m_font );
		//m_ToolTip.Track (rc, strTip);
	}
	else
	{
		m_ToolTip.Deactivate();
		Invalidate();

		//CMenu * pPopup = m_RMenu.GetSubMenu(0);
		//MENUINFO mi;
		//memset(&mi, NULL, sizeof( MENUINFO ));
		//mi.cbSize = sizeof(mi);
		//m_RMenu.GetMenuInfo(&mi);
	}

	m_bMouseTracked = FALSE;
	SetMouseTrack( m_bMouseTracked, GetSafeHwnd() );
}
示例#12
0
//-------------------------------------------------------------------//
// DrawInsertionLine()																//
//-------------------------------------------------------------------//
// Here, we draw an insertion line UNDER the specified item.
//
// Actually, all the redrawing is expected to be done in a derived
// class.  Here, we merely set m_bDrawInsertionLine to true, and
// force a redraw of the target item.  If you want this to have
// any effect, you'll need to override OnDrawItem() in a derived
// class (Cheat: see HangTheDJ::SongList.cpp for an example).
//-------------------------------------------------------------------//
void OleListCtrl::DrawInsertionLine( int nItemAboveLine )
{
	// If no change, just return.
	if ( m_nItemAboveLine == nItemAboveLine )
		return;

	// Erase the old line.
	if ( m_nItemAboveLine > -1 )
	{
		RedrawItems( m_nItemAboveLine, m_nItemAboveLine );
		UpdateWindow();
	}

	// Draw the new line.
	m_bDrawInsertionLine = true;
	RedrawItems( nItemAboveLine, nItemAboveLine );
	UpdateWindow();
	m_bDrawInsertionLine = false;

	// Save the item we drew the line under.
	m_nItemAboveLine = nItemAboveLine;

}
示例#13
0
/*void CListDocs::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
   if(lpDrawItemStruct->itemData<0)
		return;
	
   CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
   CRect rcItem(lpDrawItemStruct->rcItem);
   UINT uiFlags=ILD_TRANSPARENT;
   
   int nItem=lpDrawItemStruct->itemID;
   BOOL bFocus=(GetFocus()==this);
   
   static _TCHAR szBuff[MAX_PATH];
   
   COLORREF  BkText;
   if(lSelRow==lpDrawItemStruct->itemID)
   {
	   BkText = ::GetSysColor(COLOR_HIGHLIGHT);
	   pDC->SetTextColor(RGB(255,255,255));
   }
   else
   {
	   BkText = RGB(255,255,255);	
	   pDC->SetTextColor(RGB(0,0,0));
   }
   CRect rcLabel;
   
   GetItemRect(nItem,rcLabel,LVIR_LABEL);
   UINT nJustify=DT_LEFT;
   

   CBrush b(BkText);
   CRect rcAllLabels;
   GetItemRect(nItem,rcAllLabels,LVIR_BOUNDS);

   LV_ITEM lvi;
          lvi.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
          lvi.iItem=nItem;
          lvi.iSubItem=0;
          lvi.pszText=szBuff;
          lvi.cchTextMax=sizeof(szBuff);
          lvi.stateMask=0xFFFF;       // get all state flags
          GetItem(&lvi);
       
          BOOL bSelected=(bFocus || (GetStyle() & LVS_SHOWSELALWAYS)) && lvi.state & LVIS_SELECTED;
          bSelected=bSelected || (lvi.state & LVIS_DROPHILITED);

	
	
	pDC->FillRect(rcAllLabels,&b);
	
	long lCount;
	lCount = GetHeaderCtrl()->GetItemCount();
	for(int i = 0;i<lCount;i++)
	{
		CString sName = GetItemText(nItem,i);
		GetSubItemRect(nItem,i,LVIR_BOUNDS,rcLabel);
		rcLabel.left = rcLabel.left + 2;
		pDC->DrawText(sName,-1,rcLabel,nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
	}
	
}
*/
void CListDocs::SelectItem(long lItem)
{
	if((lItem>-1)&&(lItem<GetItemCount()))
	{
		if(lSelRow != lItem)
		{
			if(lSelRow>-1)
			{
				RedrawItems(lSelRow,lSelRow);
			}
			
			lSelRow = lItem;
			RedrawItems(lSelRow,lSelRow);
			SendMessageToParent(NCLD_SELECTED);
		}
	}
	else
	{
		if(lSelRow>-1)
				RedrawItems(lSelRow,lSelRow);
		lSelRow = -1;
		SendMessageToParent(NCLD_SELECTED);
	}
}
示例#14
0
void CListCtrlEx::OnStateChanged(NMHDR* pNMHDR, LRESULT* pResult)
{
// MSDN:
// If a list-view control has the LVS_OWNERDATA style,
// and the user selects a range of items by holding down the SHIFT key and clicking the mouse,
// LVN_ITEMCHANGED notification codes are not sent for each selected or deselected item.
// Instead, you will receive a single LVN_ODSTATECHANGED notification code,
// indicating that a range of items has changed state.

    NMLVODSTATECHANGE* pStateChanged = (NMLVODSTATECHANGE*)pNMHDR;

    // redraw newly selected items
    if (pStateChanged->uNewState == LVIS_SELECTED)
        RedrawItems(pStateChanged->iFrom, pStateChanged->iTo);
}
void SmartListCtrl::updateItemInternal( int index, const AssetInfo& inf, bool removeFromCache )
{
	if ( !provider_ || index < 0 )
		return;

	if ( removeFromCache )
	{
		listCacheBig_.cacheRemove( inf.text(), inf.longText() );
		listCacheSmall_.cacheRemove( inf.text(), inf.longText() );
	}
	CRect clRect;
	GetClientRect( &clRect );
	CRect rect;
	GetItemRect( index, &rect, LVIR_BOUNDS );
	if ( rect.right >= 0 && rect.bottom >= 0 &&
		rect.left <= clRect.right && rect.top <= clRect.bottom )
	{
		RedrawItems( index, index );
		RedrawWindow( rect, NULL, 0 );
	}
}
示例#16
0
void CQListCtrl::RefreshVisibleRows()
{
	int nTopIndex = GetTopIndex();
	int nLastIndex = nTopIndex + GetCountPerPage();
	RedrawItems(nTopIndex, nLastIndex);
}
示例#17
0
void CQListCtrl::RefreshRow(int row)
{
	RedrawItems(row, row);
}
示例#18
0
//-------------------------------------------------------------------//
// OnDragOver()																		//
//-------------------------------------------------------------------//
// This function takes a drag over request, determines if we are over
// an item, and passes the request to WillAcceptDrop.
//-------------------------------------------------------------------//
DROPEFFECT OleListCtrl::OnDragOver(
	CWnd* pWnd,
	COleDataObject* pDataObject,
	DWORD dwKeyState,
	CPoint point
) {

	DROPEFFECT deReturn = DROPEFFECT_NONE;
	bool bInsertAfter = false;
	int nUnderCursor = 0;

	UINT nHitFlags;
	if ( pDataObject->IsDataAvailable( ClipFormat ) ) 
	{
		// Get item under cursor.
		nUnderCursor = HitTest( point, &nHitFlags );

		// Adjust based on where point is.
		// If we're in the top half of the item, insert before.
		CRect ItemRect;
		GetItemRect( nUnderCursor, &ItemRect, FALSE );
		ItemRect.DeflateRect( 0, 0, 0, ItemRect.Height()/2 );
		bInsertAfter = ( ItemRect.PtInRect( point ) == FALSE );

		deReturn = WillAcceptDrop(
			nUnderCursor,
			bInsertAfter,
			nHitFlags,
			pDataObject,
			dwKeyState,
			true
		);

	// We don't currently handle text drops.
	// } else if ( pDataObject->IsDataAvailable( CF_TEXT ) ) {

	}

	// TO DO
	// Note that this next section is tailored to lists in 
	// REPORT mode.  Other modes may still need further work.

	// Convert to always insert AFTER nUnderCursor.
	// Note that first we adjust nUnderCursor for drags BELOW 
	// the bottom item.
	if ( nHitFlags & LVHT_NOWHERE )
	{
		nUnderCursor = GetItemCount() - 1;
	}
	else if ( !bInsertAfter ) 
		nUnderCursor--;
	
	// Indicate where the drop would be inserted.
	if ( 
			(
					deReturn == DROPEFFECT_COPY
				|| deReturn == DROPEFFECT_MOVE
				|| deReturn == DROPEFFECT_LINK
			)
		
		&& nUnderCursor > -1
	) 
		DrawInsertionLine( nUnderCursor );
	
	else
	{
		if ( m_nItemAboveLine > -1 )
		{
			// Erase the old line.
			RedrawItems( m_nItemAboveLine, m_nItemAboveLine );
			UpdateWindow();
			m_nItemAboveLine = -1;
		}
	}

	return deReturn;

}
示例#19
0
/**
 * WM_LBUTTONDOWN メッセージハンドラ
 *  ・ドラッグを開始する
 */
void CTouchListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	if (!m_bDragging && m_bStopDragging) {
		return;
	}

	MZ3_TRACE( L"OnLButtonDown()\n");

	// フォーカスを設定する
	SetFocus();

	// オフセットのずれを調整
	MyAdjustDrawOffset();
	// 慣性スクロール停止
	MyResetAutoScrollTimer();

	m_iDragStartItem = HitTest( point );

	//if( !m_bCanSlide ){
	//	SetSelectItem( m_iDragStartItem );
	//}
#ifdef WINCE
	// フォーカス矩形を表示
	DrawItemFocusRect( m_iDragStartItem );
	// タップ長押しでソフトキーメニュー表示
	SHRGINFO RGesture;
	RGesture.cbSize     = sizeof(SHRGINFO);
	RGesture.hwndClient = m_hWnd;
	RGesture.ptDown     = point;
	RGesture.dwFlags    = SHRG_RETURNCMD;
	if (::SHRecognizeGesture(&RGesture) == GN_CONTEXTMENU) {
		// 長押しした
		// フォーカス矩形を消す
		DrawItemFocusRect( m_iDragStartItem );
		// 項目を選択する
		SetSelectItem( m_iDragStartItem );
		RedrawItems( m_iDragStartItem , m_iDragStartItem );
		// メニューをポップアップ
		ClientToScreen(&point);
		PopupContextMenu(point);
		return;
	}
	// フォーカス矩形を消す
	DrawItemFocusRect( m_iDragStartItem );
#endif

	// ドラッグ開始
	m_bDragging = true;
	m_ptDragStart = point;
	m_iDragLine = 0;
	m_offsetPixelY = 0;

	// キャプチャ開始
	SetCapture();

	// 慣性スクロール情報取得
	m_autoScrollInfo.push( GetTickCount(), point );

	// 標準処理を呼ぶとキャプチャとかWM_LBUTTONUPが怪しいので呼ばない
	// とりあえずクリック処理として
	//  ・アイテムの選択
	//  ・フォーカスの設定
	//  ・クリック通知メッセージを親に送る
	// をやってるが、足りなかったら追加しましょ
	//CListCtrl::OnLButtonDown(nFlags, point);
}
示例#20
0
/**
 * WM_MOUSEMOVE メッセージハンドラ
 *  ・ドラッグ中ならば動的スクロール処理を行う
 */
void CTouchListCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
	if (!m_bDragging && m_bStopDragging) {
		return;
	}

	if( m_bDragging ) {
		int dx = point.x - m_ptDragStart.x;
		int dy = point.y - m_ptDragStart.y;

		DWORD dwNow = GetTickCount();
//		MZ3_TRACE(L"CTouchListCtrl::OnMouseMove : 0x%X\n", dwNow);

		// dx,dyのドラッグ量に応じて、ドラッグ開始かどうかを判定する
		// m_bPanDragging, m_bVerticalDragging, m_drPanScrollDirection が設定される
		MySetDragFlagWhenMovedPixelOverLimit(dx, dy);

		// 縦スクロール中か?
		if (m_bVerticalDragging) {
			if (theApp.m_Platforms.WM6_5 || theApp.m_Platforms.WM6_5_1) {
				// WM6.5 以降であれば無効
			} else {
				//if( m_bCanSlide ){
				//	SetSelectItem( m_iDragStartItem );
				//}
				// 縦スクロール中
				// グーのカーソルに変更
				::SetCursor( AfxGetApp()->LoadCursor(IDC_GRABBING_CURSOR) );

				// 縦ドラッグ処理
	//			MZ3LOGGER_INFO(util::FormatString(L"OnMouseMove : 前回からの経過時間=%d[msec] (%d)", dwNow - m_dwLastDrawTick, dwNow));
				ScrollByMoveY( point.y );

				// ドラッグ開始時のN画面確保用フラグを解除しておく
				m_bFullPageDrawForBlackScrollStart = false;

	#ifdef WINCE
				if( !IsScrollWithBk() ){
					// WMで、かつ背景同時スクロールでない場合は遅延再描画
					MySetRedrawTimer( TIMER_INTERVAL_TOUCHLIST_SCROLLREDRAW_L );
				}
	#endif
				// 慣性スクロール情報取得
				m_autoScrollInfo.push( GetTickCount(), point );
			}
		} else if( m_bPanDragging ){
			// 横スクロール中
			// マウスポインタ変更
			switch( m_drPanScrollDirection ){
				case PAN_SCROLL_DIRECTION_LEFT:
					// 左方向
					::SetCursor( AfxGetApp()->LoadCursor(IDC_ARROW_LEFT_CURSOR) );
					break;
				case PAN_SCROLL_DIRECTION_RIGHT:
					// 右方向
					::SetCursor( AfxGetApp()->LoadCursor(IDC_ARROW_RIGHT_CURSOR) );
					break;
			}
		} else {
			::SetCursor( ::LoadCursor(NULL, IDC_ARROW) );
#ifdef WINCE
			// フォーカス矩形を表示
			DrawItemFocusRect( m_iDragStartItem );
			// タップ長押しでソフトキーメニュー表示
			// (指先が微動した時のため)
			SHRGINFO RGesture;
			RGesture.cbSize     = sizeof(SHRGINFO);
			RGesture.hwndClient = m_hWnd;
			RGesture.ptDown     = point;
			RGesture.dwFlags    = SHRG_RETURNCMD;
			if (::SHRecognizeGesture(&RGesture) == GN_CONTEXTMENU) {
				// 長押しした
				// フォーカス矩形を消す
				DrawItemFocusRect( m_iDragStartItem );

				// WM_LBUTTONUPと同様にドラッグ終了処理を行う

				// キャプチャ終了
				ReleaseCapture();
				// 遅延描画タイマーのリセット
				MyResetRedrawTimer();
				// 選択状態の設定
				SetSelectItem( m_iDragStartItem );
				RedrawItems( m_iDragStartItem , m_iDragStartItem );
				// オフセットの調整(念のため)
				MyAdjustDrawOffset();
				m_autoScrollInfo.clear();

				// ドラッグフラグクリア
				m_bDragging = false;
				m_bPanDragging = false;
				m_bVerticalDragging = false;
				m_drPanScrollDirection = PAN_SCROLL_DIRECTION_NONE;

				// メニューポップアップ
				ClientToScreen(&point);
				PopupContextMenu(point);
				return;
			}
			// フォーカス矩形を消す
			DrawItemFocusRect( m_iDragStartItem );
#endif
		}

	}

	//CListCtrl::OnMouseMove(nFlags, point);
}
示例#21
0
void CFVDownloads_Tasks::UpdateDownload(vmsDownloadSmartPtr dld)
{
	int nIndex = FindIndex (dld);
	if (nIndex != -1)
		RedrawItems (nIndex, nIndex);
}