Example #1
0
void CButtonStyle::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
{
	
	CDC *pDC = CDC::FromHandle(lpDIS->hDC);
	
	CString sCaption;
	CRect rect=lpDIS->rcItem;

	GetWindowText(sCaption);
	pDC->SetBkMode(TRANSPARENT);

	CFont *oldFont = pDC->SelectObject(&m_Font);
	
	m_Selected = (lpDIS->itemState & ODS_SELECTED);
	
	if((!m_bTab) || (GetDlgCtrlID()!=m_IDSelected))
	{
		if(nState==1){
			if(m_hHdc!=NULL)
				PaintBG(pDC,1);
			pDC->DrawIcon(0,3,m_hIcon1);
			pDC->SetTextColor(m_TextColorDark);
			pDC->DrawText(sCaption, rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
		}				
		else if(nState==3){
			if(m_hHdc!=NULL)
				PaintBG(pDC,3);
			if(m_Selected)
			{
				pDC->DrawIcon(1,4,m_hIcon2);
				pDC->SetTextColor(m_TextColorLight);
				pDC->DrawText(sCaption, rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
			}
			else
			{
				pDC->DrawIcon(0,3,m_hIcon2);
				pDC->SetTextColor(m_TextColorLight);
				pDC->DrawText(sCaption, rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
			}				
		}else if(nState==2){
			if(m_hHdc!=NULL)
				PaintBG(pDC,2);
			pDC->DrawIcon(0,3,m_hIcon2);
			pDC->SetTextColor(m_TextColorLight);
			pDC->DrawText(sCaption, rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);		
		}		
	}else
	{		
		if(m_hHdc!=NULL)
			PaintBG(pDC,1);
		pDC->DrawIcon(0,3,m_hIcon2);
		pDC->SetTextColor(m_TextColorLight);	
		pDC->DrawText(sCaption, rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);					
	}
	pDC->SelectObject(oldFont);					
	

}
void CPatchPaletteButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
  CDC *pDC = GetDC();
  CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  
  CModelerView *pModelerView = CModelerView::GetActiveMappingNormalView();
  if( pModelerView == NULL)
  {
    pDC->FillSolidRect( &lpDrawItemStruct->rcItem, 0x00aaaaaa);
    pDC->DrawEdge( &lpDrawItemStruct->rcItem, EDGE_RAISED, BF_RECT);
  }
  else
  {
    INDEX iButtonNo = lpDrawItemStruct->CtlID - IDC_PATCH_BUTTON_BASE;
    ULONG ulCurrentMask = pModelerView->m_ModelObject.GetPatchesMask();
    CModelerDoc* pDoc = pModelerView->GetDocument();
    ULONG ulExistingMask = pDoc->m_emEditModel.GetExistingPatchesMask();
    pDC->FillSolidRect( &lpDrawItemStruct->rcItem, 0x00aaaaaa);
    // If this patch doesn't exist
    if( (ulExistingMask & (1UL << iButtonNo)) == 0)
    {
      pDC->DrawEdge( &lpDrawItemStruct->rcItem, EDGE_RAISED, BF_RECT);
    }
    // If this patch exists but it is not turned on
    else if( (ulCurrentMask & (1UL << iButtonNo)) == 0)
    {
      // If this is active patch
      if( iButtonNo == pModelerView->m_iActivePatchBitIndex)
        pDC->DrawIcon( 2, 2, pMainFrame->m_dlgPatchesPalette->m_PatchActiveIcon);
      else
        pDC->DrawIcon( 2, 2, pMainFrame->m_dlgPatchesPalette->m_PatchExistIcon);
      pDC->DrawEdge( &lpDrawItemStruct->rcItem, EDGE_RAISED, BF_RECT);
    }
    // If this patch is turned on and it is active patch
    else if( iButtonNo == pModelerView->m_iActivePatchBitIndex)
    {
      pDC->DrawIcon( 2, 2, pMainFrame->m_dlgPatchesPalette->m_PatchActiveIcon);
      pDC->DrawEdge( &lpDrawItemStruct->rcItem, EDGE_SUNKEN, BF_RECT);
    }
    // If this patch is turned on and it is not active patch
    else
    {
      pDC->DrawIcon( 2 ,2, pMainFrame->m_dlgPatchesPalette->m_PatchInactiveIcon);
      pDC->DrawEdge( &lpDrawItemStruct->rcItem, EDGE_SUNKEN, BF_RECT);
    }
  }
  ReleaseDC( pDC);
}          
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CIconComboBox::OnDrawIcon( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	// any items to draw?
	if( GetCount() == 0 )
		return;

	// get the device context - to draw
	CDC* pDC = CDC::FromHandle( lpDrawItemStruct->hDC );

	// get the current icon to render
	HICON hIcon = ( HICON )lpDrawItemStruct->itemData;
	if( !hIcon )
		return;

	// calculate the icon's upper left corner
	int UpperLeftX = lpDrawItemStruct->rcItem.left + 
		             ( ( lpDrawItemStruct->rcItem.right - lpDrawItemStruct->rcItem.left ) / 2 ) - 
			         ( m_IconSize.cx / 2 );
	int UpperLeftY = lpDrawItemStruct->rcItem.top + 
		             ( ( lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top ) / 2 ) - 
					 ( m_IconSize.cy / 2 );

	// render the icon
	pDC->DrawIcon( UpperLeftX, UpperLeftY, hIcon );
}               
Example #4
0
void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	ASSERT(pDC != NULL);

	CRect rect;
	GetClientRect(rect);
	int cxClient = rect.Width();
	int cyClient = rect.Height();

	// load icon
	HICON hicon = AfxGetApp()->LoadIcon(ID_SYM_ICON_GDB);
	if (hicon == NULL)
		return;

	// draw icon into off-screen bitmap
	int cxIcon = ::GetSystemMetrics(SM_CXICON);
	int cyIcon = ::GetSystemMetrics(SM_CYICON);

	CBitmap bitmap;
	if (!bitmap.CreateCompatibleBitmap(pDC, cxIcon, cyIcon))
		return;
	CDC dcMem;
	if (!dcMem.CreateCompatibleDC(pDC))
		return;
	CBitmap* pBitmapOld = dcMem.SelectObject(&bitmap);
	if (pBitmapOld == NULL)
		return;

	// blt the bits already on the window onto the off-screen bitmap
	dcMem.StretchBlt(0, 0, cxIcon, cyIcon, pDC,
		2, 2, cxClient-CX_SHADOW-4, cyClient-CY_SHADOW-4, SRCCOPY);

	// draw the icon on the background
	dcMem.DrawIcon(0, 0, hicon);

	// draw border around icon
	CPen pen;
	pen.CreateStockObject(BLACK_PEN);
	CPen* pPenOld = pDC->SelectObject(&pen);
	pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW);
	if (pPenOld)
		pDC->SelectObject(pPenOld);

	// draw shadows around icon
	CBrush br;
	br.CreateStockObject(DKGRAY_BRUSH);
	rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient);
	pDC->FillRect(rect, &br);
	rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient);
	pDC->FillRect(rect, &br);

	// draw the icon contents
	pDC->StretchBlt(2, 2, cxClient-CX_SHADOW-4, cyClient-CY_SHADOW-4,
		&dcMem, 0, 0, cxIcon, cyIcon, SRCCOPY);
}
Example #5
0
void CRMessageBox::OnPaint()
{
    if (!IsWindowVisible() || IsIconic())
    {
        CDialog::OnPaint();
        return;
    }

    // 绘制窗口
    CRDialog::OnPaint();

    // 显示图标
    HICON hIcon;
    CRect rcIcon;
    POINT point;

    m_stcIcon.GetWindowRect(&rcIcon);
    ScreenToClient(&rcIcon);
    point.x = rcIcon.left;
    point.y = rcIcon.top;

    // 根据消息框类型加载不同的图标
    switch (m_iType & 0xF0)
    {
    case MB_ICONHAND: // MB_ICONERROR/MB_ICONSTOP
        hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_HAND));
        break;
    case MB_ICONQUESTION:
        hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_QUESTION));
        break;
    case MB_ICONEXCLAMATION: // MB_ICONWARNING
        hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_WARNING));
        break;
    case MB_ICONINFORMATION: // MB_ICONASTERISK
        hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_INFORMATION));
        break;
    case MB_USERICON:
    default:
        hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_INFORMATION));
        break;
    }

    // 画图标
    CDC *pDC = GetDC();
    pDC->DrawIcon(point, hIcon);
    ReleaseDC(pDC);
}
void CBlendSelectWnd::OnPaint()
{
	CPaintDC dc(this);

	CRect rcClient(0,0,m_dwWidth, m_dwMargin + m_dwTitleHeight + m_dwMargin);

	CDC dcMem;
	if (!dcMem.CreateCompatibleDC(&dc))
		return;

	CBitmap bm;
	bm.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
	dcMem.SelectObject(&bm);

	dcMem.FillSolidRect(&rcClient, m_crBkgnd);

	dcMem.SetTextColor(m_crText);
	dcMem.SetBkColor(m_crBkgnd);

	// Draw Close Button
	::DrawIconEx(dcMem.GetSafeHdc(), m_rcBtnClose.left, m_rcBtnClose.top, 
		m_bCloseDown ? m_hIconCloseDown : m_hIconClose, 16, 16, 0, NULL, DI_NORMAL);

	// Draw Icon
	int nIconSize = 0;

	if (m_hIcon) {
		dcMem.DrawIcon(rcClient.left + m_dwMargin, rcClient.top + m_dwMargin, m_hIcon);
		nIconSize = 32;
	}

	// Draw Title
	CRect rcTitle = rcClient;
	rcTitle.left += (nIconSize > 0) ? m_dwMargin * 2 + nIconSize : m_dwMargin;
	rcTitle.right -= m_dwMargin;
	rcTitle.top += m_dwMargin;
	rcTitle.bottom = rcClient.bottom;

	if (m_ftTitle.GetSafeHandle()) {
		dcMem.SelectObject(&m_ftTitle);
	}

	dcMem.DrawText(m_strTitle, m_strTitle.GetLength(), &rcTitle, DT_WORDBREAK | DT_NOPREFIX);

	dc.BitBlt(0, 0, rcClient.Width(), rcClient.Height(),
		&dcMem, 0, 0, SRCCOPY);
}
Example #7
0
HBITMAP ConvertIconToBitmap(HICON hIcon)
{
    CBitmap bmpIcon;
    CDC dcBmp;

    if (dcBmp.CreateCompatibleDC(NULL)) // create memory DC
    {
        if (bmpIcon.CreateCompatibleBitmap(&dcBmp, 16, 16))// 16x16 icon
        {
            CBitmap *poldBmp = dcBmp.SelectObject(&bmpIcon);
            dcBmp.DrawIcon(0, 0, hIcon); // Draw icon (hIcon should be loaded already)
            dcBmp.SelectObject(poldBmp); // Restore DC
        }
    }

    return (HBITMAP)bmpIcon;
}
Example #8
0
void CDMPlaceListPage::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
{

	HICON hIco;
	switch(nIDCtl)
	{
	case IDC_ADD:
		hIco = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ADD), IMAGE_ICON, 16, 16, 0);
		break;
	case IDC_DELETE:
		hIco = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DEL), IMAGE_ICON, 16, 16, 0);
		break;
	case IDC_NEW:
		hIco = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_NEW), IMAGE_ICON, 16, 16, 0);
		break;
	default:
		CPropertyPage::OnDrawItem(nIDCtl, lpDrawItemStruct);
		return;
	}


	CDC dc;
	dc.Attach(lpDrawItemStruct->hDC);

	if((lpDrawItemStruct->itemAction&ODA_SELECT) && (lpDrawItemStruct->itemState&ODS_SELECTED))
	{
		CBrush br(RGB(0,0,0));
		dc.FillSolidRect(&lpDrawItemStruct->rcItem, RGB(255,255,255));
		dc.FrameRect(&lpDrawItemStruct->rcItem, &br);
	}
	else
	{
		dc.FillSolidRect(&lpDrawItemStruct->rcItem, GetSysColor(COLOR_BTNFACE));
	}

	dc.DrawIcon(2, 2, hIco);
	dc.Detach();
}
Example #9
0
void CLab08View::OnDraw(CDC* _pDC)
{
	CLab08Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc) return;

	CRect size;
	_pDC->GetWindow()->GetClientRect(&size);

	// Супер костыли
	CMemDC dc(*_pDC, _pDC->GetWindow());
	CDC * pDC = &dc.GetDC();
	// Крутая штука, почему я раньше её не юзал

	// Чистим фон
	CBrush bgBrush(_pDC->GetBkColor());
	pDC->FillRect(size, &bgBrush);

	if (size.Width() < 150 || size.Height() < 150 ) {
		LONG x = size.left + (size.right - size.left) / 2;
		LONG y = size.top + (size.bottom - size.top) / 2;
		HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
		pDC->DrawIcon(x - 16, y - 16, m_hIcon);
		return;
	}

	auto & props = pDoc->properties;
	auto & funcs = pDoc->properties.functions;

	// Начало координат в пикселях. Может не попадать в область видимости
	LONG center_x = t_dim_to_pixel_x(size, 0.0);
	LONG center_y = t_dim_to_pixel_y(size, 0.0);

	pDC->SetBkMode(TRANSPARENT);

	// Рисуем вспомогательную сетку
	CPen penGird(PS_DOT, 1, COLORREF(0x7f7f7f));
	pDC->SelectObject(&penGird);
	pDC->SetTextColor(COLORREF(0x7f7f7f));
	double gird_lx = ceil(t_pixel_to_dim_x(size, size.left) / props.x_grid) * props.x_grid;
	double gird_rx = floor(t_pixel_to_dim_x(size, size.right) / props.x_grid) * props.x_grid;
	for(double i = gird_lx; i <= gird_rx; i += props.x_grid) {
		LONG ix = t_dim_to_pixel_x(size, i);
		if ( ix != center_x && size.left + 1 < ix && ix < size.right - 1) {
			pDC->MoveTo(ix, size.bottom - 5); pDC->LineTo(ix, size.top + 5);
		}
	}
	double gird_ly = ceil(t_pixel_to_dim_y(size, size.bottom) / props.y_grid) * props.y_grid;
	double gird_ry = floor(t_pixel_to_dim_y(size, size.top) / props.y_grid) * props.y_grid;
	for(double i = gird_ly; i <= gird_ry; i += props.y_grid) {
		LONG iy = t_dim_to_pixel_y(size, i);
		if ( iy != center_y && size.top + 1 < iy && iy < size.bottom - 1) {
			pDC->MoveTo(size.left + 5, iy); pDC->LineTo(size.right - 5, iy);
		}
	}

	// Рисуем оси, если это имеет смысл
	CPen penAxis(PS_SOLID, 2, COLORREF(0x000000));
	pDC->SelectObject(&penAxis);
	pDC->SetTextColor(0);
	if ( size.left <= center_x && center_x <= size.right ) {
		pDC->MoveTo(center_x, size.bottom - 5); pDC->LineTo(center_x, size.top + 5);
		// стрелочка
		pDC->MoveTo(center_x - 5, size.top + 10);
		pDC->LineTo(center_x, size.top + 5);
		pDC->LineTo(center_x + 5, size.top + 10);
		// Буковка
		pDC->TextOut(center_x + 5, size.top + 10, _T("Y"));
	}
	if ( size.top <= center_y && center_y <= size.bottom ) {
		pDC->MoveTo(size.left + 5, center_y); pDC->LineTo(size.right - 5, center_y);
		// стрелочка
		pDC->MoveTo(size.right - 10, center_y - 5);
		pDC->LineTo(size.right - 5, center_y);
		pDC->LineTo(size.right - 10, center_y + 5);
		// Буковка
		pDC->TextOut(size.right - 15, center_y + 5, _T("X"));
	}
	if ( size.left <= center_x && center_x <= size.right && 
		size.top <= center_y && center_y <= size.bottom ) {
		pDC->TextOut(center_x + 1, center_y + 1, _T("(0;0)"));
	}

	// координаты в углах
	{
		CString tmp;

		tmp.Format(_T("(%g;%g)"), gird_lx, gird_ly);
		drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_lx),
			t_dim_to_pixel_y(size, gird_ly), tmp);
		tmp.Format(_T("(%g;%g)"), gird_lx, gird_ry);
		drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_lx),
			t_dim_to_pixel_y(size, gird_ry), tmp);
		tmp.Format(_T("(%g;%g)"), gird_rx, gird_ly);
		drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_rx),
			t_dim_to_pixel_y(size, gird_ly), tmp);
		tmp.Format(_T("(%g;%g)"), gird_rx, gird_ry);
		drawPoint(pDC, size, t_dim_to_pixel_x(size, gird_rx),
			t_dim_to_pixel_y(size, gird_ry), tmp);
	}

	// Рисование графиков
	for(int ii = 0; ii < funcs.size(); ++ii) {
		CPen penFunc(PS_SOLID, 1, funcs[ii].second);
		pDC->SelectObject(&penFunc);
		for(int pixel_x = size.left; pixel_x < size.right; pixel_x += props.accuracy) {
			//Sleep(1); // TEST ONLY
			double dim_x = t_pixel_to_dim_x(size, pixel_x);
			double dim_y = funcs[ii].first.f(dim_x);
			int pixel_y = t_dim_to_pixel_y(size, dim_y);
			if (pixel_x == size.left) pDC->MoveTo(pixel_x, pixel_y);
			else pDC->LineTo(pixel_x, pixel_y);
		}
	}
}
void CPrimitiveHistoryCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
  INDEX iItem = lpDrawItemStruct->itemID;
  BOOL bSelected = lpDrawItemStruct->itemState & (ODS_FOCUS|ODS_SELECTED);
  COLORREF clrfBcgColor;
  UINT ulEdgeType;
  if( bSelected)
  {
    clrfBcgColor = CLRF_CLR( 0xDFDFFF00UL); 
    ulEdgeType = EDGE_SUNKEN;
  }
  else
  {
    clrfBcgColor = CLRF_CLR( C_WHITE);
    ulEdgeType = EDGE_RAISED;
  }
  
  CValuesForPrimitive *pVFP = (CValuesForPrimitive *) GetItemData( iItem);
  if( (ULONG) pVFP == CB_ERR) return;

  CDC *pDC = CDC::FromHandle( lpDrawItemStruct->hDC);
  RECT rectItem = lpDrawItemStruct->rcItem;
  pDC->SetBkMode( TRANSPARENT);
  pDC->SetBkColor( clrfBcgColor);
  pDC->FillSolidRect( &rectItem, clrfBcgColor);
  
  // polygon color
  RECT rectPolygon = rectItem;
  rectPolygon.top+=1;
  rectPolygon.bottom-=1;
  rectPolygon.left += 2;
  rectPolygon.right = rectPolygon.left+16;
  COLORREF clrfColor = CLRF_CLR( pVFP->vfp_colPolygonsColor);
  pDC->FillSolidRect( &rectPolygon, clrfColor);

  // sector color
  RECT rectSector = rectPolygon;
  rectSector.left += 16;
  rectSector.right += 16;
  clrfColor = CLRF_CLR( pVFP->vfp_colSectorsColor);
  pDC->FillSolidRect( &rectSector, clrfColor);

  RECT rectBorder = rectPolygon;
  rectBorder.right += 16;
  pDC->DrawEdge( &rectBorder, ulEdgeType, BF_RECT);

  // used for rendering from left to right
  PIX pixCursor = 38;
  
  UINT uiPrimitiveIconID;
  switch( pVFP->vfp_ptPrimitiveType)
  {
  case PT_CONUS:{       uiPrimitiveIconID = IDR_ICON_CONUS; break;}
  case PT_TORUS:{       uiPrimitiveIconID = IDR_ICON_TORUS; break;}
  case PT_STAIRCASES:
    {
    if( pVFP->vfp_bLinearStaircases) uiPrimitiveIconID = IDR_ICON_LINEAR_STAIRCASES;
    else                             uiPrimitiveIconID = IDR_ICON_SPIRAL_STAIRCASES; 
    break;
    }
  case PT_SPHERE:{      uiPrimitiveIconID = IDR_ICON_SPHERE; break;}
  case PT_TERRAIN:{     uiPrimitiveIconID = IDR_ICON_TERRAIN; break;}
  }
  HICON hPrimitiveIcon = theApp.LoadIcon( uiPrimitiveIconID);
  pDC->DrawIcon( pixCursor, rectItem.top, hPrimitiveIcon);
  pixCursor += 22;

  UINT uiPrimitiveOperationID;
  switch( pVFP->vfp_csgtCSGOperation)
  {
  case CSG_ADD: {             uiPrimitiveOperationID = IDR_ICON_ADD; break;}
  case CSG_ADD_REVERSE: {     uiPrimitiveOperationID = IDR_ICON_ADD_REVERSE; break;}
  case CSG_REMOVE:  {         uiPrimitiveOperationID = IDR_ICON_REMOVE; break;}
  case CSG_REMOVE_REVERSE:  { uiPrimitiveOperationID = IDR_ICON_REMOVE_REVERSE; break;}
  case CSG_SPLIT_SECTORS: {   uiPrimitiveOperationID = IDR_ICON_SPLIT_SECTORS; break;}
  case CSG_SPLIT_POLYGONS:  { uiPrimitiveOperationID = IDR_ICON_SPLIT_POLYGONS; break;}
  case CSG_JOIN_LAYERS: {     uiPrimitiveOperationID = IDR_ICON_JOIN_LAYERS; break;}
  }
  HICON hOperationIcon = theApp.LoadIcon( uiPrimitiveOperationID);
  pDC->DrawIcon( pixCursor, rectItem.top, hOperationIcon);
  pixCursor += 22;

  HICON hRoomIcon;
  if( pVFP->vfp_bClosed) hRoomIcon = theApp.LoadIcon( IDR_ICON_ROOM);
  else                   hRoomIcon = theApp.LoadIcon( IDR_ICON_MATERIAL);
  pDC->DrawIcon( pixCursor, rectItem.top, hRoomIcon);
  pixCursor += 22;

  if( !pVFP->vfp_bOuter &&
      (pVFP->vfp_csgtCSGOperation != PT_SPHERE) &&
      (pVFP->vfp_csgtCSGOperation != PT_TERRAIN) )
  {
    HICON hOuterIcon;
    hOuterIcon = theApp.LoadIcon( IDR_ICON_INNER);
    pDC->DrawIcon( pixCursor, rectItem.top, hOuterIcon);
    pixCursor += 22;
  }

  if( pVFP->vfp_ptPrimitiveType == PT_STAIRCASES)
  {
    HICON hTopStairsIcon;
    if(      pVFP->vfp_iTopShape == 0) hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_STAIRS);
    else if( pVFP->vfp_iTopShape == 1) hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_SLOPE);
    else                               hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_CEILING);
    pDC->DrawIcon( pixCursor, rectItem.top, hTopStairsIcon);
    pixCursor += 22;

    HICON hBottomStairsIcon;
    if(      pVFP->vfp_iTopShape == 0) hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_STAIRS);
    else if( pVFP->vfp_iTopShape == 1) hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_SLOPE);
    else                               hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_FLOOR);
    pDC->DrawIcon( pixCursor, rectItem.top, hBottomStairsIcon);
    pixCursor += 22;
  }

  // obtain text of drawing item
  CString strText;
  GetLBText( iItem, strText);
  pDC->TextOut( pixCursor, rectItem.top, strText);
}
void CinvadersView::OnDraw(CDC* pDC)
{
	CinvadersDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: add draw code for native data here
	//drawbackground
	CBitmap bitmap;
	CDC dcMemory;
	if(pDoc->sp.level==1){
		bitmap.LoadBitmapW(IDB_BITMAP1);}
	if(pDoc->sp.level==2){
		bitmap.LoadBitmapW(IDB_BITMAP2);}
	if(pDoc->sp.level==3){
		bitmap.LoadBitmapW(IDB_BITMAP3);}
	if(pDoc->sp.level==4){
		bitmap.LoadBitmapW(IDB_BITMAP4);}
	if(pDoc->sp.level==5){
		bitmap.LoadBitmapW(IDB_BITMAP5);}
	dcMemory.CreateCompatibleDC(pDC);
	dcMemory.SelectObject(bitmap);



	HICON player;
	HICON alien1;
	HICON alien2;
	HICON alien3;
	HICON alien4;
	HICON pRocket;
	HICON aRocket;
	HICON explo;
	player=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1));
	alien1=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON2));
	alien2=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON3));
	alien3=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON4));
	alien4=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON5));
	pRocket=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON6));
	aRocket=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON6));
	explo=LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON7));
	//draw player
	dcMemory.DrawIcon(pDoc->sp.player.left,pDoc->sp.player.top,player);

	//draw rocket
	if(pDoc->sp.pRock==true)dcMemory.DrawIcon(pDoc->sp.pRocket.left,pDoc->sp.pRocket.top,pRocket);
	if(pDoc->sp.aRock==true)dcMemory.DrawIcon(pDoc->sp.aRocket.left,pDoc->sp.aRocket.top,aRocket);

	if(pDoc->sp.exploa==true)dcMemory.DrawIcon(pDoc->sp.pRocket.left,pDoc->sp.pRocket.top,explo);pDoc->sp.exploa=false;
	if(pDoc->sp.explop==true)dcMemory.DrawIcon(pDoc->sp.player.left,pDoc->sp.player.top,explo);pDoc->sp.explop=false;
	//draw invaders
	for(int i=0;i<pDoc->sp.aliens.size();i++){
		if(pDoc->sp.aliens.at(i).i==0){
			dcMemory.DrawIcon(pDoc->sp.aliens.at(i).r.left,pDoc->sp.aliens.at(i).r.top,alien4);}
		if(pDoc->sp.aliens.at(i).i==1){
			dcMemory.DrawIcon(pDoc->sp.aliens.at(i).r.left,pDoc->sp.aliens.at(i).r.top,alien3);}
		if(pDoc->sp.aliens.at(i).i==2){
			dcMemory.DrawIcon(pDoc->sp.aliens.at(i).r.left,pDoc->sp.aliens.at(i).r.top,alien2);}
		if(pDoc->sp.aliens.at(i).i==3){
			dcMemory.DrawIcon(pDoc->sp.aliens.at(i).r.left,pDoc->sp.aliens.at(i).r.top,alien1);}
	}
	//drawscore&level
	dcMemory.TextOutW(200,pDoc->sp.border.bottom-20,pDoc->sp.llvl);
	dcMemory.TextOutW(250,pDoc->sp.border.bottom-20,pDoc->sp.lvl);
	dcMemory.TextOutW(300,pDoc->sp.border.bottom-20,pDoc->sp.lliv);
	dcMemory.TextOutW(350,pDoc->sp.border.bottom-20,pDoc->sp.liv);
	dcMemory.TextOutW(400,pDoc->sp.border.bottom-20,pDoc->sp.str);
	dcMemory.TextOutW(450,pDoc->sp.border.bottom-20,pDoc->sp.scr);
	//drawend
 

	if(pDoc->sp.gameOver==true){
		dcMemory.TextOutW(320,240,pDoc->sp.scr);
	}
	
	pDC->BitBlt(pDoc->sp.border.left,pDoc->sp.border.top,640,480,&dcMemory,0,0,SRCCOPY);	
}
Example #12
0
void CCJOutlookBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
    CDC*            pDC = CDC::FromHandle( lpDrawItemStruct->hDC );
    CRect           rcItem(lpDrawItemStruct->rcItem);
    CRect           rClient(rcItem);
    CRect           rText;
    CPoint          Pt(((rcItem.Width() - 32) /2 ), rcItem.top + 15);
    CContentItems   pContents = m_pContents[ lpDrawItemStruct->itemID ];
    HICON           hIcon = m_ImageListNormal.ExtractIcon( pContents.GetImageID());

	// deflate the client rect, and set up item and
	// text rect's.
	rClient.DeflateRect( 8, 5 );
	rcItem.CopyRect( rClient );
    rText.CopyRect( rClient );
    rText.top += 45;
	rText.bottom += 10;

    // set the text color to white, and background mode
	// to transparent.
	pDC->SetTextColor( ::GetSysColor( COLOR_WINDOW ) );
	pDC->SetBkMode( TRANSPARENT );

	// draw the button icon and text.
	if( lpDrawItemStruct->itemAction& ODA_DRAWENTIRE ) {
        pDC->DrawIcon( Pt, hIcon );
        pDC->DrawText( pContents.GetText(), rText,
			DT_CENTER | DT_WORDBREAK );
    }

    // if the left mouse button is pressed, offset
	// the button icon.
	if( m_bLBDown ) {
        Pt.x += 2;
        Pt.y += 2;
        rcItem.OffsetRect( 2, 2 );
    }

	// deflate the button rect, and move up.
	rcItem.DeflateRect( 4, 16 );
	rcItem.top -= 8;

	// Draw the button icon and text, if the mouse is over the
	// button, draw the 3d rect, either pressed,
	// or not pressed depending on left mouse button.
	if(( lpDrawItemStruct->itemState& ODS_SELECTED ) &&
		( lpDrawItemStruct->itemAction& ( ODA_SELECT | ODA_DRAWENTIRE ))) {
        
		rcItem.left = ( rcItem.Width()/2 )-5;
		rcItem.right = rcItem.left+37;

		if( m_bHilight ) {
            if( m_bLBDown ) {
              pDC->Draw3dRect( rcItem, ::GetSysColor( COLOR_3DDKSHADOW ),
				  ::GetSysColor( COLOR_BTNFACE ) );
			}
            else {
              pDC->Draw3dRect( rcItem, ::GetSysColor( COLOR_BTNFACE ),
				  ::GetSysColor( COLOR_3DDKSHADOW ) );
			}
        }

        pDC->DrawIcon( Pt, hIcon );
        pDC->DrawText( pContents.GetText(), rText,
			DT_CENTER | DT_WORDBREAK );
	}

	if( !( lpDrawItemStruct->itemState& ODS_SELECTED ) &&
		( lpDrawItemStruct->itemAction& ODA_SELECT )) {
        pDC->FillSolidRect( rClient, ::GetSysColor( COLOR_3DSHADOW ) );
        pDC->DrawIcon(Pt, hIcon);
        pDC->DrawText(pContents.GetText(), rText, DT_CENTER|DT_WORDBREAK);
    }
}
Example #13
0
void CTrashSkipCtrl::_DrawSoftItem(CDC& dc, CRect& rcDraw, int nItemIndex)
{
    TRASH_SKIP_ITEM item = m_vecItems[nItemIndex];
    HICON hIcon = NULL;
    CRect rcCloseBtn(rcDraw);
    int xSrc;

    _DrawItemBackgnd(dc, rcDraw, nItemIndex);

    Gdiplus::Graphics graphics(dc);

    rcCloseBtn.left = rcDraw.right - 25;
    rcCloseBtn.bottom = rcDraw.top + 25;
    if (m_nHoverIndex == nItemIndex && m_nSelectIndex == -1)
    {
        xSrc = 25;
    }
    else if (m_nSelectIndex == nItemIndex)
    {
        xSrc = 50;
    }
    else
    {
        xSrc = 0;
    }
    graphics.DrawImage(m_imgSoftOff, rcCloseBtn.left, rcCloseBtn.top, xSrc, 0, 25, 25, Gdiplus::UnitPixel);

    ::CopyRect(m_vecItems[nItemIndex].rcItem, rcCloseBtn);


    _GetItemIcon(item.strIconPath, hIcon);

    CRect rcIcon(rcDraw);

    rcIcon.left += (DEF_ITEM_WIDTH - 6 - 32) / 2;
    rcIcon.top += 24;

    if (!hIcon)
    {            
        KAppRes& res = KAppRes::Instance();

        if (item.nItemID == BROWER_IE)
        {
            hIcon = m_iconIE;
        }
        else
        {
            hIcon = m_iconUnknow;
        }
        dc.DrawIcon(rcIcon.left, rcIcon.top, hIcon);
    }
    else
    {
        dc.DrawIconEx(rcIcon.left, rcIcon.top, hIcon, 32, 32);
    }

    _DrawItemText(dc, rcDraw, item.strName);

    if (hIcon && (hIcon != m_iconIE && hIcon != m_iconUnknow))
    {
        DestroyIcon(hIcon);
    }
}