void CShipDesignMenuView::OnDraw(CDC* dc)
{
	CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);

	if (!pDoc->m_bDataReceived)
		return;

	// TODO: add draw code here
	// Doublebuffering wird initialisiert
	CMyMemDC pDC(dc);
	CRect client;
	GetClientRect(&client);

	// Graphicsobjekt, in welches gezeichnet wird anlegen
	Graphics g(pDC->GetSafeHdc());

	g.Clear(Color::Black);
	g.SetSmoothingMode(SmoothingModeHighSpeed);
	g.SetInterpolationMode(InterpolationModeLowQuality);
	g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
	g.SetCompositingQuality(CompositingQualityHighSpeed);
	g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

	DrawShipDesignMenue(&g);

	g.ReleaseHDC(pDC->GetSafeHdc());
}
Exemplo n.º 2
0
void CGuiFolder::DrawFolder(CFolderBar* cfb,Style m_Style)
{
	CRect rc=cfb->m_rect;
	CBrush cb;
	CClientDC pDC(this);
	cb.CreateSysColorBrush(COLOR_BTNFACE);
	rc.top+=1;
	rc.right-=1;
	pDC.FillRect(&rc,&cb);
	if (m_typel!=mOutlook)
	{
		rc.right-=30;
	}
		
	if (m_Style == mNormal)
	{
				
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow());
		rc.DeflateRect(1,1);
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorShadow());
	}
	else if (m_Style == mFlat)
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow());
	else if (m_Style == mPush)
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorBTNHigh());
	int OldMode=pDC.SetBkMode(TRANSPARENT);
	cfont = pDC.SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
	CString m_cadBreak=cfb->m_lpMsg;
	int cont=m_cadBreak.GetLength();
	CSize coor=pDC.GetTextExtent(m_cadBreak,m_cadBreak.GetLength());
	if ( coor.cx > rc.Width())
	{
		rc.left+=1;
		while(cont > 1 )
		{
			CString m_scadtemp=m_cadBreak+"...";
			CSize coor=pDC.GetTextExtent(m_scadtemp,m_scadtemp.GetLength());
			if(coor.cx > rc.Width())
				m_cadBreak=m_cadBreak.Left(m_cadBreak.GetLength()-1);
			else
				break;
			cont--;
		}
		m_cadBreak+=_T("...");
		rc.right+=3;
		
			pDC.DrawText(m_cadBreak,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
	}
	else
	{
	  if (m_typel!=mOutlook)
			pDC.DrawText(cfb->m_lpMsg,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
	  else	
			pDC.DrawText(cfb->m_lpMsg,rc,DT_WORDBREAK|DT_SINGLELINE|DT_CENTER|DT_VCENTER);
	}

   	pDC.SetBkColor(OldMode);
	// Modified By SunZhenyu
	pDC.SelectObject(cfont);
}
Exemplo n.º 3
0
void CChildView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	FlickerFree::CMemDC pDC(&dc);

	try
	{
		m_mfcHandler.draw(pDC);
		m_mfcHandler2.draw(pDC);
	}
	catch (...)
	{
		CString errorText(EXCEPTION_MSG);
		AfxMessageBox(errorText);
		this->GetParentFrame()->PostMessage(WM_CLOSE);
	}
	//dc.FillRect(CRect(10, 10, 555, 555), (CBrush*) GetStockObject(BLACK_BRUSH));

	//pDC->LineTo(pt);
/*	CRect rtlp;
	CBrush cbrush;

	rtlp.left = 0;
	rtlp.top = 0;
	rtlp.right = 555;
	rtlp.bottom = 555;

	cbrush.CreateSolidBrush(RGB(255,0,0));
	dc.FillRect(rtlp, &(cbrush));*/
	
	// Do not call CWnd::OnPaint() for painting messages
}
Exemplo n.º 4
0
void COBDPNDDlgData::OnPaint()
{
	if (m_dwBkResID !=NULL && m_memdcBkBmp != NULL)
	{
		CClientDC pDC(this);

		CRect rect; 
		CDC   memDC; 

		GetWindowRect(&rect); 	
		memDC.CreateCompatibleDC(&pDC); 	

		CBitmap* pOldMemBmp = NULL; 
		pOldMemBmp = memDC.SelectObject(&m_cBitmapBkBmp);
		memDC.BitBlt(0,0,rect.Width(),rect.Height(),&m_memdcBkBmp,0,0,SRCCOPY);

		memDC.SetBkMode(TRANSPARENT);	
		memDC.SetTextColor(theMainDlg->m_clrTitle);

		//将背景位图复制到窗口客户区 
		pDC.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY); 

		if(pOldMemBmp)   
			memDC.SelectObject(pOldMemBmp); 

		DeleteObject(pOldMemBmp);	
		DeleteDC(memDC);

	}
	CDialog::OnPaint();
}
Exemplo n.º 5
0
void CMainFrame::OnPaint()
{
	CPaintDC pDC(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
#if 1
	CFont NewFont; 
	NewFont.CreateFont(16,      // nHeight 字体高度
					0,			// nWidth  字体宽度
					0,			// nEscapement 字体显示的角度
					0,			// nOrientation  字体的角度
					FW_NORMAL,	//FW_NORMAL,//FW_BOLD,	// nWeight 字体的磅数
					            //FW_MEDIUM
					FALSE,		// bItalic    斜体字体
					FALSE,		// bUnderline带下划线的字体
					0,			// cStrikeOut 带删除线的字体
					GB2312_CHARSET,		//ANSI_CHARSET,	// nCharSet 所需的字符集
					OUT_DEFAULT_PRECIS,	// nOutPrecision  输出的精度
					CLIP_DEFAULT_PRECIS,	// nClipPrecision  裁减的精度
					DEFAULT_QUALITY,	// nQuality逻辑字体与输出设备的实际  
                                                          //字体之间的精度  
					DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily 字体间距和字体集  
					_T("幼圆")            	    //Arial 字体名称
					); 
	CFont *pOldFont = pDC.SelectObject(&NewFont);
	pDC.SetBkMode(TRANSPARENT);		//选进设备描述表
	pDC.SetTextColor(RGB(255,0,0));         //设置字体颜色,这里是红色
	pDC.TextOut(100,10,_T("西南科技大学视频监控系统"));
	pDC.SelectObject(&pOldFont);            // 回复到旧字体
	NewFont.DeleteObject();                 // 删除新创建的字体
	// 不为绘图消息调用CBkDialogST::OnPaint()
#endif

}
Exemplo n.º 6
0
void CHeaderDockPane::OnDraw(CDC* dc) // pDC
{
	CRealMemDC pDC(dc);
	CRect rect;
	GetClientRect(&rect);
	//pDC->DPtoLP(&rect);

}
Exemplo n.º 7
0
void CDComView::OnDraw(CDC* dc)
{
    CRect rcBounds;
    GetClientRect(&rcBounds);
    int nFirstLine;
    int nLastLine;
    CRect rcClient;
    CDComDoc* pDoc = GetDocument();
    CPoint ptScroll;
    SDComCfg *pDComCfg;
    CFont font;
    CMainFrame *pMainFrm = (CMainFrame *)AfxGetMainWnd();

    if (dc->IsPrinting())
    {
        dc->SetMapMode(MM_LOENGLISH);
    }
    else
    {
        dc->SetMapMode(MM_TEXT);
    }
    ASSERT_VALID(pMainFrm);
    if (!pMainFrm)
    {
        return;
    }
    ASSERT_VALID(pDoc);
    if (!pDoc)
    {
        return;
    }

    pDComCfg = pMainFrm->GetConfig();
    if (!dc->IsPrinting())
    {
        dc->SetBkColor(pDComCfg->m_crBack);
    }

    CMyMemDC pDC(dc);

    font.CreateFontIndirect(&pDComCfg->m_logfont);
    pDC->SelectObject(font);
    font.DeleteObject();

    pDoc->m_cLineBuffer.Enter();

    ptScroll = GetDeviceScrollPosition();
    GetClientRect(&rcClient);

    nFirstLine = ptScroll.y / m_sizeCharDimensions.cy;
    nLastLine = nFirstLine + (rcClient.Height() / m_sizeCharDimensions.cy) + 1;

    DrawLines(nFirstLine, nLastLine, pDComCfg, pDC);
    pDoc->m_cLineBuffer.Exit();
}
Exemplo n.º 8
0
void COBDPNDDlgErrLog::OnPaint()
{
	if (m_memdcBkBmp != NULL)
	{
		CClientDC pDC(this);

		CRect rect; 
		CDC   memDC; 

		GetWindowRect(&rect); 	
		memDC.CreateCompatibleDC(&pDC); 	

		CBitmap* pOldMemBmp = NULL; 
		pOldMemBmp = memDC.SelectObject(&m_cBitmapBkBmp);
		memDC.BitBlt(0,0,rect.Width(),rect.Height(),&m_memdcBkBmp,0,0,SRCCOPY);

		memDC.SetBkMode(TRANSPARENT);	
		memDC.SetTextColor(theMainDlg->m_clrTitle);

		fDrawTitleText(&memDC);


		memDC.SelectObject(&m_fontStatus); 
		memDC.SetTextColor(m_clrText);   
		CString	strText =theMainDlg->fGetBinText(DS_CONFIG_ERR_LOG_TEXT2);
		if (m_bIsOpenErrLog)
			strText += theMainDlg->fGetBinText(DS_BTN_OPEN);
		else
			strText += theMainDlg->fGetBinText(DS_BTN_CLOSE);
		memDC.DrawText(strText,m_rectStatus, DT_LEFT|DT_VCENTER);

		memDC.SelectObject(&m_fontText); 
		memDC.SetTextColor(m_clrText);   
		strText =theMainDlg->fGetBinText(DS_CONFIG_ERR_LOG_TEXT1);
		CRect temp = m_rectText;
		int height = memDC.DrawText(strText,temp,DT_LEFT| DT_TOP| DT_WORDBREAK | DT_CALCRECT | DT_EDITCONTROL); // 获得文本高度
		m_rectText.DeflateRect(0,(m_rectText.Height() - height) / 2); // 改变rect
		memDC.DrawText(strText,m_rectText, DT_LEFT| DT_TOP | DT_EDITCONTROL | DT_WORDBREAK);

		fDrawFootText(&memDC);

		//将背景位图复制到窗口客户区 
		pDC.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY); 

		if(pOldMemBmp)   
			memDC.SelectObject(pOldMemBmp); 

		DeleteObject(pOldMemBmp);	
		DeleteDC(memDC);

	}
	CDialog::OnPaint();
}
Exemplo n.º 9
0
void COBDPNDDlgMini::OnPaint()
{
	if (m_memdcBkBmp != NULL)
	{
		CClientDC pDC(this);

		CRect rect; 
		CDC   memDC; 

		GetWindowRect(&rect); 	
		memDC.CreateCompatibleDC(&pDC); 	

		CBitmap* pOldMemBmp = NULL; 
		pOldMemBmp = memDC.SelectObject(&m_cBitmapBkBmp);
		memDC.BitBlt(0,0,rect.Width(),rect.Height(),&m_memdcBkBmp,0,0,SRCCOPY);

		memDC.SetBkMode(TRANSPARENT);	
		memDC.SetTextColor(theMainDlg->m_clrTitle);

		//速度
		if (m_strData == _T("------"))
			m_strData = _T("---");
		DWORD dSSPecent =_ttoi(m_strData);
		CString str; 
		str.Format(_T("%0.0f"),dSSPecent);
		if (dSSPecent>=100)
			memDC.SetTextColor(theMainDlg->m_clrTitle);	//RGB(255,0,0)
		else if (dSSPecent>=80)
			memDC.SetTextColor(theMainDlg->m_clrTitle);	//RGB(244,78,6)
		else 
			memDC.SetTextColor(RGB(0,255,0));	
		memDC.SelectObject(&m_fontData);
		memDC.DrawText(m_strData, -1, &m_rectData, DT_CENTER|DT_VCENTER);	

		memDC.SetTextColor(theMainDlg->m_clrTitle);
		memDC.SelectObject(&m_fontText);
		memDC.DrawText(m_strText, -1, &m_rectText, DT_CENTER|DT_VCENTER);	

		//将背景位图复制到窗口客户区 
		pDC.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY); 

		if(pOldMemBmp)   
			memDC.SelectObject(pOldMemBmp); 

		DeleteObject(pOldMemBmp);	
		DeleteDC(memDC);

	}
	CDialog::OnPaint();
}
Exemplo n.º 10
0
void CMySliderCtrl::OnPaint() {
    // without this first check it gets the background(s)
    // before they've been painted
    static BOOL first = TRUE;
    if (first) {
        first = FALSE;
        return;
    }

    CPaintDC pDC(this);
    PaintBk(&pDC);
    DrawTheBitmap(&pDC, m_ChannelRect, 0);
    DrawTheBitmap(&pDC, m_ThumbRect, 3);
}
Exemplo n.º 11
0
//****************************************************************************
BOOL CContainer::OnEraseBkgnd(HDC hDC) 
{
	// TODO: Add your message handler code here and/or call default
	CGDI pDC(hDC);
	if (m_Numtabs == 0)
	{
		CBrush cbr;
		cbr.CreateSysColorBrush(COLOR_BTNFACE);
		CRect m_rect;
		GetClientRect(m_rect);
		pDC.FillRect(m_rect,&cbr);
		cbr.DeleteObject();
		
	}
	return TRUE;
}
Exemplo n.º 12
0
void COBDPNDDlgShowText::OnPaint()
{
	if (m_memdcBkBmp != NULL)
	{
		CClientDC pDC(this);

		CRect rect; 
		CDC   memDC; 

		GetWindowRect(&rect); 	
		memDC.CreateCompatibleDC(&pDC); 	

		CBitmap* pOldMemBmp = NULL; 
		pOldMemBmp = memDC.SelectObject(&m_cBitmapBkBmp);
		memDC.BitBlt(0,0,rect.Width(),rect.Height(),&m_memdcBkBmp,0,0,SRCCOPY);

		memDC.SetBkMode(TRANSPARENT);	
		memDC.SetTextColor(theMainDlg->m_clrTitle);

		fDrawTitleText(&memDC);

		memDC.SelectObject(&m_fontText); 
		memDC.SetTextColor(m_clrText);   
		
		CRect temp = m_rectText;
		int height = memDC.DrawText(m_strText,temp,DT_LEFT| DT_TOP| DT_WORDBREAK | DT_CALCRECT | DT_EDITCONTROL); // 获得文本高度
		m_rectText.DeflateRect(0,(m_rectText.Height() - height) / 2); // 改变rect
		memDC.DrawText(m_strText,m_rectText, DT_LEFT| DT_TOP | DT_EDITCONTROL | DT_WORDBREAK);

		fDrawFootText(&memDC);

		//将背景位图复制到窗口客户区 
		pDC.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY); 

		if(pOldMemBmp)   
			memDC.SelectObject(pOldMemBmp); 

		DeleteObject(pOldMemBmp);	
		DeleteDC(memDC);

	}
	CDialog::OnPaint();
}
Exemplo n.º 13
0
void CMyToolBar::OnPaint ()
{
	
    CPaintDC pDC(this);
    
    //CRect rect;
    //GetClientRect (&rect);

	int progress_x = 1;
	int progress_y = 4;
	CPoint prorgess_border_points[5];
	prorgess_border_points[0] = CPoint(progress_x, progress_y);
	prorgess_border_points[1] = CPoint(progress_x, progress_y + 5);
	prorgess_border_points[2] = CPoint(progress_x+75, progress_y + 5);
	prorgess_border_points[3] = CPoint(progress_x+75, progress_y);
	prorgess_border_points[4] = CPoint(progress_x, progress_y);
	CPen penOutline(PS_SOLID,1,RGB(204,204,204));
	pDC.SelectObject(&penOutline);
	pDC.Polyline(prorgess_border_points, 5);
}
Exemplo n.º 14
0
void CColorButton::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ) 
{
	ASSERT( 0 != lpDrawItemStruct );

	CDC* pDC( CDC::FromHandle( lpDrawItemStruct->hDC ) );
	ASSERT( 0 != pDC );

	DWORD style = GetStyle();

	UINT uiDrawState( DFCS_ADJUSTRECT );	
	UINT state( lpDrawItemStruct->itemState );

	CRect rc; 
	rc.CopyRect( &lpDrawItemStruct->rcItem );

	if(((state & ODS_DEFAULT) || (state & ODS_FOCUS)) )
	{
		pDC->Draw3dRect(rc, GetSysColor(COLOR_WINDOWFRAME), GetSysColor(COLOR_WINDOWFRAME));
		rc.DeflateRect(1, 1);
	}

	if(style & BS_FLAT)
	{
		pDC->Draw3dRect(rc, GetSysColor(COLOR_WINDOWFRAME), GetSysColor(COLOR_WINDOWFRAME));
		rc.DeflateRect(1, 1);
		pDC->Draw3dRect(rc, GetSysColor(COLOR_WINDOW), GetSysColor(COLOR_WINDOW));
		rc.DeflateRect(1, 1);
	}
	else
	{
		if(state & ODS_SELECTED)
		{
			pDC->Draw3dRect(rc, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DSHADOW));
			rc.DeflateRect(1, 1);
		}
		else
		{
			pDC->Draw3dRect(rc, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW));
			rc.DeflateRect(1, 1);
		}
	}

	if(state & ODS_SELECTED)
	{
		pDC->SetBkMode(TRANSPARENT);
		pDC->FillSolidRect( &rc, m_color );
	}
	else
	{
		pDC->SetBkMode(TRANSPARENT);
		pDC->FillSolidRect( &rc, m_color );
	}
	
	if( false != m_showText )
	{
		CString wndText;
		GetWindowText( wndText );

		if (!wndText.IsEmpty())
		{
			pDC->SetTextColor( m_textColor );
			pDC->DrawText( wndText, &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
		}
	}
}
Exemplo n.º 15
0
void CTimeEv::OnTeTakePict() 
{
//	CWnd*		pWnd = CWnd::GetDesktopWindow();
	CWindowDC	dc(this);
	CDC			memDC;
	CRect		rect;
	CBitmap		bitmap;
	CClientDC	pDC(this);


//	pWnd->GetWindowRect(rect);
	GetWindowRect(rect);
	memDC.CreateCompatibleDC(&dc);
//	bitmap.CreateCompatibleBitmap(&dc,rect.right,rect.bottom);
	bitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());

	CBitmap *oldBM = memDC.SelectObject(&bitmap);
//	memDC.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);
	memDC.BitBlt(0, 0, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);
	
	BITMAP bm;
	bitmap.GetObject(sizeof(bm),&bm);

//	pDC.BitBlt(0, 0, rect.right, rect.bottom, &memDC, 0, 0, SRCCOPY);
	pDC.BitBlt(0, 0, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);

	

	CFile file;
	file.Open("a.pcx",CFile::modeWrite | CFile::modeCreate);
	CreatePCXHeader(&file,rect.Width(),rect.Height());
	
	short *bmBit;
	RGBQUAD *rgbQuad;
	bmBit = (short*) malloc (bm.bmHeight * bm.bmWidthBytes * 2);
	int n = bitmap.GetBitmapBits(bm.bmHeight * bm.bmWidthBytes, bmBit);

	rgbQuad = (RGBQUAD*) malloc (bm.bmHeight * bm.bmWidthBytes * sizeof(RGBQUAD));
	

	for (int y=0; y< rect.Height();y++)
	{
		for (char hl=0; hl<3; hl++)
		{
			for (int x=0; x < rect.Width();x++)
			{
				char byte; RGBQUAD rgb;
				rgb = QuadFromWord( bmBit[y*rect.Width() + x]);
				if (hl == 0)
					byte = rgb.rgbRed;
				if (hl == 1)
					byte = rgb.rgbGreen;
				if (hl == 2)
					byte = rgb.rgbBlue;
				char toWr;
				toWr = (char) 0xC1;
				file.Write(&toWr,1);
				file.Write(&byte,1);
			}
		}
	}		

	free(bmBit);
	free(rgbQuad);
	
	file.Close();

	char txt[300];
	sprintf(txt,"type:%d, width:%d, height:%d, widthbytes:%d, planes:%d, BitsPixel:%d,",
		bm.bmType, bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, bm.bmPlanes, bm.bmBitsPixel);
//	sprintf(txt,"%d %d", rect.left,rect.right);
	pDC.TextOut(10,10,txt);

	memDC.SelectObject(oldBM);
	MessageBeep(0);
}
Exemplo n.º 16
0
void COBDPNDDlgMainIdle::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	if (m_memdcBkBmp != NULL)
	{
		CClientDC pDC(this);

		CRect rect; 
		CDC   memDC; 

		GetWindowRect(&rect); 	
		memDC.CreateCompatibleDC(&pDC); 	

		CBitmap* pOldMemBmp = NULL; 
		pOldMemBmp = memDC.SelectObject(&m_cBitmapBkBmp);
		memDC.BitBlt(0,0,rect.Width(),rect.Height(),&m_memdcBkBmp,0,0,SRCCOPY);

		memDC.SetBkMode(TRANSPARENT);	

		fDrawFill(&memDC,m_rectWater,(_ttoi(m_strWaterTempValue)/180.0)*100);

		memDC.SetTextColor(theMainDlg->m_clrTitle);

		CFont *pOldFont = memDC.SelectObject(&m_fontDate);
		memDC.DrawText(m_strDate,-1,m_rectDate,DT_VCENTER|DT_CENTER);

		pOldFont = memDC.SelectObject(&m_fontWeek);
		memDC.DrawText(m_strWeek,-1,m_rectWeek,DT_VCENTER|DT_CENTER);

		pOldFont = memDC.SelectObject(&m_fontTime);
		memDC.DrawText(m_strTime,-1,m_rectTime,DT_VCENTER|DT_CENTER);

		float fCurrCoolant = theMainDlg->fGetDataStreamValueF(0x00000500);
		if (fCurrCoolant == INVALID_DATASTREAM_VALUE)
			fCurrCoolant = 0;
		DWORD dwAlarmCoolatn = theMainDlg->m_pConfigReadWrite->fGetWaterTemperatureAlarmValue();
		float fPer = fCurrCoolant *100/dwAlarmCoolatn; //报警百分比

		if (fPer>=100)
			memDC.SetTextColor(RGB(255,0,0));	//红色
		else if (fPer>=90)
			memDC.SetTextColor(RGB(244,78,6));	//黄色
		else if (fPer>=45)
			memDC.SetTextColor(RGB(0,0,0));		//黑色
		else
			memDC.SetTextColor(RGB(19,162,10));	//绿色

		pOldFont = memDC.SelectObject(&m_fontWaterTempValue);
		memDC.DrawText(m_strWaterTempValue,-1,m_rectWaterTempValue,DT_VCENTER|DT_CENTER);

		pOldFont = memDC.SelectObject(&m_fontWaterTempText);
		memDC.SetTextColor(RGB(0,0,0));		//黑色
		memDC.DrawText(m_strWaterTempText,-1,m_rectWaterTempText,DT_VCENTER|DT_CENTER);

		memDC.SetTextColor(theMainDlg->m_clrTitle);

		for (int i=0;i<6;i++)
		{
			//没有单位居中显示
			if (theMainDlg->fGetUnitResID(m_tagDsInfo[i].strUnit) == NULL)
			{
				pOldFont = memDC.SelectObject(&m_fontDsDataValue);
				memDC.DrawText(m_tagDsInfo[i].strValue,-1,m_tagDsInfo[i].rectData,DT_BOTTOM|DT_CENTER);
				pOldFont = memDC.SelectObject(&m_fontDsDataText);
				memDC.DrawText(m_tagDsInfo[i].strText,-1,m_tagDsInfo[i].rectText,DT_VCENTER|DT_CENTER);
			}
			else
			{
				memDC.BitBlt(m_tagDsInfo[i].rectUnit.left,m_tagDsInfo[i].rectUnit.top,m_tagDsInfo[i].rectUnit.Width(),m_tagDsInfo[i].rectUnit.Height(),	
					&m_tagDsInfo[i].memdcUnit,0,0,SRCCOPY);

				CRect rectTemp = m_tagDsInfo[i].rectData;
				rectTemp.right =m_tagDsInfo[i].rectUnit.left;
				pOldFont = memDC.SelectObject(&m_fontDsDataValue);
				memDC.DrawText(m_tagDsInfo[i].strValue,-1,rectTemp,DT_BOTTOM|DT_RIGHT);
				pOldFont = memDC.SelectObject(&m_fontDsDataText);
				memDC.DrawText(m_tagDsInfo[i].strText,-1,m_tagDsInfo[i].rectText,DT_VCENTER|DT_CENTER);
			}
		}

		pOldFont = memDC.SelectObject(&theMainDlg->m_fontFootNormal);
		for (int i=0;i<MAX_FOOT_INDEX;i++)
		{
			if (theMainDlg->fGetCurrPanelIndex()== i)
				memDC.SetTextColor(theMainDlg->m_clrFootFocus);   
			else
				memDC.SetTextColor(theMainDlg->m_clrFootNormal); 		
			memDC.DrawText(theMainDlg->m_strFoot[i], -1, &theMainDlg->m_rectFoot[i], DT_CENTER);
		}

		//将背景位图复制到窗口客户区 
		pDC.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY); 

		if(pOldFont)  
			pDC.SelectObject(pOldFont);
		DeleteObject(pOldFont);

		if(pOldMemBmp)   
			memDC.SelectObject(pOldMemBmp); 
		DeleteObject(pOldMemBmp);

		DeleteDC(memDC);

	}
}
Exemplo n.º 17
0
bool CMenuSpawn::DrawItem(LPDRAWITEMSTRUCT lp)
{
	bool res = false;
	//pDC1.Draw3dRect(rcClient,CDrawLayer::GetRGBColorFace(),CDrawLayer::GetRGBColorShadow());
	if (lp->CtlType == ODT_MENU)
	{
		UINT id = lp->itemID;
		UINT state = lp->itemState;
		bool bEnab = !(state & ODS_DISABLED);
		bool bSelect = (state & ODS_SELECTED) ? true : false;
		bool bChecked = (state & ODS_CHECKED) ? true : false;
		bool bHotLight =(state & ODS_HOTLIGHT) ? true : false;
		CGDI  pDC(lp->hDC);
		SpawnItem * pItem = (SpawnItem *) lp->itemData;
		if (pItem)
		{
			CFont  pft=((HFONT) hMenuFont ? hMenuFont : hGuiFont);
			CFont  of=(pDC.SelectObject(pft));
			CRect rc=lp->rcItem;
			CRect rcImage(rc), rcText(rc);
			rcImage.right = rcImage.left + rc.Height();
			rcImage.bottom = rc.bottom;

			CBrush brush;
			brush.CreateSolidBrush(CDrawLayer::GetRGBColorFace());
			
			CRect rcImg=rcImage;
			rcImg.right+=1;
			pDC.FillRect(rcImg,&brush);
			if (pItem->iCmd != -4)
			{
				CGradient M(CSize(rcImg.Width(),rcImg.Height()));	
				M.PrepareHorizontal(&pDC,CDrawLayer::GetRGBColorWhite(),CDrawLayer::GetRGBColorFace());
				M.Draw(&pDC,rcImg.left,rcImg.top,0,0,rcImg.Width()+2,rcImg.Height(),SRCCOPY);	
			}
			if (bBackBitmap) 
			{
				CGDI tempDC;
				tempDC.CreateCompatibleDC(pDC);
				tempDC.FillSolidRect(rcText, crMenu);
				CBitmap  ob = tempDC.SelectObject(&bmpBack);
				pDC.FillSolidRect(rcText, crMenu);
				pDC.BitBlt(rc.left, rc.top, rc.Width(), rc.Height(), tempDC, rc.left, rc.top, SRCCOPY );
			}
			int obk = pDC.SetBkMode(TRANSPARENT);
			if (pItem->iCmd == -3) // is a separator
			{
				CBrush brush;
				CRect m_rc=rc;
				brush.CreateSolidBrush(CDrawLayer::GetRGBSkinMenu());
				rc.left+=rcImage.Width()+15;
				pDC.FillRect(rc,&brush);
				rc.top += rc.Height()>>1;	
				rc.left+= 5;
				brush.DeleteObject();
				pDC.DrawEdge(rc, EDGE_ETCHED, BF_TOP);	
				rcImg.right= rc.left-4;
				CGradient M(CSize(rcImg.Width(),rcImg.Height()));	
				M.PrepareHorizontal(&pDC);
				M.Draw(&pDC,rcImg.left,rcImg.top,0,0,rcImg.Width()-1,rcImg.Height(),SRCCOPY);	
				fltMenu.iCmd=-1;
		
			}
			else if (pItem->iCmd == -4) // is a title item
Exemplo n.º 18
0
void CGuiVisioFolder::DrawFolder(CFolderBar* cfb,Style m_Style)
{
	CRect rc=cfb->m_rect;
	CRect rcWin=cfb->m_rect;
	int nNuImage=cfb->m_img;
	CString szStringPoints=_T("...");
	CBrush cb;
	CClientDC pDC(this);
	cb.CreateSysColorBrush(COLOR_BTNFACE);
	rc.top+=1;
	pDC.FillRect(&rc,&cb);
	
	//se pintan  bordes que simulen un boton

	if (m_Style == mNormal)  //el folder no tiene el mouse 
	{
				
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow());
		rc.DeflateRect(1,1);
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorFace(),GuiDrawLayer::GetRGBColorShadow());
	}
	else if (m_Style == mFlat) //el mouse esta sobre el folder pero no presiona
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow());
	else if (m_Style == mPush) //el mouse esta sobre el folder y presiona
		pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorBTNHigh());
	int OldMode=pDC.SetBkMode(TRANSPARENT);
	cfont = pDC.SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
	CString m_cadBreak=cfb->m_lpMsg;
	int cont=m_cadBreak.GetLength();
	CSize coor=pDC.GetTextExtent(m_cadBreak,m_cadBreak.GetLength());
	CSize szImage=CSize(0,0);

	//se dibuja la imagen
	if(nNuImage != -1) 
	{
		IMAGEINFO pImageInfo;
		m_Img.GetImageInfo(nNuImage,&pImageInfo);
		CRect rcima =pImageInfo.rcImage;
		szImage=CSize(rcima.Width(),rcima.Height());
		CPoint pti=CPoint(rc.left+2,rc.top+3);
		m_Img.Draw(&pDC, nNuImage, pti, ILD_TRANSPARENT);
	}
	
	//guardar espacio para la imagen
	rc.left+=szImage.cx+4;
	rc.right-=8;
	if ( coor.cx > rc.Width())
	{
		rc.left+=1;
		while(cont > 1 )
		{
			CString m_scadtemp=m_cadBreak+szStringPoints;
			CSize coor=pDC.GetTextExtent(m_scadtemp,m_scadtemp.GetLength());
			if(coor.cx > rc.Width())
				m_cadBreak=m_cadBreak.Left(m_cadBreak.GetLength()-1);
			else
				break;
			cont--;
		}
		m_cadBreak+=szStringPoints;
		rc.right+=3;
		
			pDC.DrawText(m_cadBreak,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
	}
	else
		pDC.DrawText(cfb->m_lpMsg,rc,DT_WORDBREAK|DT_SINGLELINE|DT_CENTER|DT_VCENTER);
	
	//----se dibuja el gripper----------

	rcWin.top+=5;
	rcWin.right-=4;
	rcWin.left=rcWin.right-3;
	rcWin.bottom-=4;

	for (int i=0; i < rcWin.Height(); i+=2)
	{
		CRect rcWindow;
		CBrush cb;
		cb.CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
		rcWindow=rcWin;
		rcWindow.top=rcWin.top+i;
		rcWindow.bottom=rcWindow.top+1;
		pDC.FillRect(rcWindow,&cb);
		cb.DeleteObject();			
	}
	//-------------------------
	cb.DeleteObject();
   	pDC.SetBkColor(OldMode);
	
}
Exemplo n.º 19
0
//控件颜色
HBRUSH CPngButton::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if (!m_bHaveBitmaps)
	{
		//验证判断
		if(!m_pStdImage.m_pBitmap)	return NULL; 
	
		//变量声明
		CBitmap bmp,	*pOldBitmap;

		//获取区域
		CRect rect;
		GetClientRect(rect);

		//创建内存DC
		CMemDC2 pDC(pScreenDC,rect);

		Gdiplus::Graphics graphics(pDC->m_hDC);

		//背景DC
		if(m_dcBk.m_hDC==NULL)
		{
			CRect rect1;
			CClientDC clDC(GetParent());

			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC,rect.Width(),rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0,0,rect.Width(),rect.Height(),&clDC,rect1.left,rect1.top,SRCCOPY);
			bmp.DeleteObject();
		}

		//标准按钮
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(pDC);

			float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
			float height = (float)m_pStdImage.m_pBitmap->GetHeight();
			RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

			graphics.DrawImage(m_pStdImage,grect,0,0,width,height,UnitPixel);

			m_dcStd.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
			pOldBitmap=m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY);
			bmp.DeleteObject();

			// 按下状态
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(pDC);

				float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pStdImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pStdImage,grect,width*2,0,width,height,UnitPixel);

				m_dcStdP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY);
				bmp.DeleteObject();
			}

			// 盘旋状态  
			if(m_dcStdH.m_hDC == NULL)
			{     
				PaintBk(pDC);

				ColorMatrix HotMat = { 1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
					0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
					0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
					0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
					0.05f, 0.05f, 0.05f, 0.00f, 1.00f };

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pStdImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pStdImage, grect, width, 0, width, height, UnitPixel, &ia);

				m_dcStdH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// 无效状态   
			if(m_dcGS.m_hDC == NULL)
			{     
				PaintBk(pDC);

				ColorMatrix GrayMat = { 0.30f, 0.30f, 0.30f, 0.00f, 0.00f,
					0.59f, 0.59f, 0.59f, 0.00f, 0.00f,
					0.11f, 0.11f, 0.11f, 0.00f, 0.00f,
					0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
					0.00f, 0.00f, 0.00f, 0.00f, 1.00f };

				ImageAttributes ia;
				ia.SetColorMatrix(&GrayMat);

				float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pStdImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);
				m_dcGS.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}
		// 交替按钮
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{    
			PaintBk(pDC);

			float width = (float)m_pAltImage.m_pBitmap->GetWidth()/5;
			float height = (float)m_pAltImage.m_pBitmap->GetHeight();
			RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

			graphics.DrawImage(m_pAltImage,grect,0,0,width,height,UnitPixel);   

			m_dcAlt.CreateCompatibleDC(pDC);    
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());    
			pOldBitmap = m_dcAlt.SelectObject(&bmp);    
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);    
			bmp.DeleteObject();

			// 按下状态
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )    
			{     
				PaintBk(pDC);

				float width = (float)m_pAltImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pAltImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;
				
				graphics.DrawImage(m_pAltImage,grect,width*2,0,width,height,UnitPixel);

				m_dcAltP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// 盘旋状态
			if(m_dcAltH.m_hDC == NULL)
			{     
				PaintBk(pDC);

				ColorMatrix HotMat = { 1.05f, 0.00f, 0.00f, 0.00f, 0.00f,           
					0.00f, 1.05f, 0.00f, 0.00f, 0.00f,           
					0.00f, 0.00f, 1.05f, 0.00f, 0.00f,           
					0.00f, 0.00f, 0.00f, 1.00f, 0.00f,           
					0.05f, 0.05f, 0.05f, 0.00f, 1.00f };

				ImageAttributes ia;     
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pAltImage.m_pBitmap->GetWidth()/5; 
				float height = (float)m_pAltImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pAltImage, grect, 0, 0, width, height, UnitPixel, &ia);
				m_dcAltH.CreateCompatibleDC(pDC); 
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp); 
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}   
		}
		if(m_pCurBtn == NULL)   
		{    
			m_pCurBtn = &m_dcStd;  
		}
		m_bHaveBitmaps = TRUE;
	}
	return NULL;
}
Exemplo n.º 20
0
//=============================================================================
//
//	The framework calls this member function when a child control is about to 
//	be drawn.  All the bitmaps are created here on the first call. Every thing
//	is done with a memory DC except the background, which get's it's information 
//	from the parent. The background is needed for transparent portions of PNG 
//	images. An always on top app (such as Task Manager) that is in the way can 
//	cause it to get an incorrect background.  To avoid this, the parent should 
//	call the SetBkGnd function with a memory DC when it creates the background.
//				
//=============================================================================
HBRUSH CGdipButtonTile::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if(!m_bHaveBitmaps)
	{
		if(!m_pStdLeftImage || !m_pStdCenterImage || !m_pStdRightImage)
		{
			return NULL; // Load the standard image with LoadStdImage()
		}

		CBitmap bmp, *pOldBitmap;

		CRect rect;
		GetClientRect(rect);

		// do everything with mem dc
		CMemDCEx pDC(pScreenDC, rect);


		Gdiplus::Graphics graphics(pDC->m_hDC);

		// background
		if (m_dcBk.m_hDC == NULL)
		{
			CRect rect1;
			CClientDC clDC(GetParent());
			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
			bmp.DeleteObject();
		}

		// standard image
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(pDC);

			InterpolationMode  interMode = graphics.GetInterpolationMode();
			graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

			int		nCalPos = 0;
			int		nWidthLeft = m_pStdLeftImage->m_pBitmap->GetWidth();
			int		nWidthRight = m_pStdRightImage->m_pBitmap->GetWidth();
			graphics.DrawImage(*m_pStdLeftImage, 0, 0, nWidthLeft, m_pStdLeftImage->m_pBitmap->GetHeight());
			nCalPos += nWidthLeft;
			graphics.DrawImage(*m_pStdCenterImage, nCalPos, 0, (m_nButtonWidth-nWidthLeft-nWidthRight)*2, m_pStdCenterImage->m_pBitmap->GetHeight());
			nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
			graphics.DrawImage(*m_pStdRightImage, nCalPos, 0, nWidthRight, m_pStdRightImage->m_pBitmap->GetHeight());
			graphics.SetInterpolationMode(interMode);

			// 글자!
			FontFamily fontFamily(L"나눔고딕");
		    Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
			SolidBrush brush(Color(255, 72, 72, 72));
			StringFormat stringFormat;
			stringFormat.SetAlignment(StringAlignmentCenter);
			stringFormat.SetLineAlignment(StringAlignmentCenter);
			PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
			graphics.SetTextRenderingHint(TextRenderingHintAntiAliasGridFit);
			graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);


			m_dcStd.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			//m_dcStd.TransparentBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, rect.Width(), rect.Height(), RGB(255,255,255));
			bmp.DeleteObject();

			// standard image pressed
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(pDC);

				interMode = graphics.GetInterpolationMode();
				graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

				nCalPos = 1;
				graphics.DrawImage(*m_pStdLeftImage, nCalPos, 1, nWidthLeft, m_pStdLeftImage->m_pBitmap->GetHeight());
				nCalPos += nWidthLeft;
				graphics.DrawImage(*m_pStdCenterImage, nCalPos, 1, 2*(m_nButtonWidth-nWidthLeft-nWidthRight), m_pStdCenterImage->m_pBitmap->GetHeight());
				nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
				graphics.DrawImage(*m_pStdRightImage, nCalPos, 1, nWidthRight, m_pStdRightImage->m_pBitmap->GetHeight());
				graphics.SetInterpolationMode(interMode);

				// 글자!
				FontFamily fontFamily(L"나눔고딕");
				Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
				SolidBrush brush(Color(255, 0, 0, 255));
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
				graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);

				m_dcStdP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// standard image hot
			if(m_dcStdH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_nButtonWidth;
				float height = (float)m_nButtonHeight;

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				interMode = graphics.GetInterpolationMode();
				graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

				nCalPos = 0;
				grect.Width = (float)nWidthLeft;
				graphics.DrawImage(*m_pStdLeftImage, grect, 0, 0, (float)nWidthLeft, height, UnitPixel, &ia);
				nCalPos += nWidthLeft;
				grect.X = (float)nCalPos;
				grect.Width = (float)((m_nButtonWidth-nWidthLeft-nWidthRight)*2);
				graphics.DrawImage(*m_pStdCenterImage, grect, 0, 0, 1, height, UnitPixel, &ia);
				nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
				grect.X = (float)nCalPos;
				grect.Width = (float)nWidthRight;
				graphics.DrawImage(*m_pStdRightImage, grect, 0, 0, (float)nWidthRight, height, UnitPixel, &ia);
				graphics.SetInterpolationMode(interMode);

				// 글자!
				FontFamily fontFamily(L"나눔고딕");
				Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
				SolidBrush brush(Color(255, 72, 72, 72));
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
				graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);

				m_dcStdH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// grayscale image
			if(m_dcGS.m_hDC == NULL && m_bHaveAltImage)
			{
				int		nWidthLeft = m_pAltLeftImage->m_pBitmap->GetWidth();
				int		nWidthRight = m_pAltRightImage->m_pBitmap->GetWidth();

				PaintBk(pDC);

				interMode = graphics.GetInterpolationMode();
				graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

				nCalPos = 1;
				graphics.DrawImage(*m_pAltLeftImage, nCalPos, 1, nWidthLeft, m_pAltLeftImage->m_pBitmap->GetHeight());
				nCalPos += nWidthLeft;
				graphics.DrawImage(*m_pAltCenterImage, nCalPos, 1, 2*(m_nButtonWidth-nWidthLeft-nWidthRight), m_pAltCenterImage->m_pBitmap->GetHeight());
				nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
				graphics.DrawImage(*m_pAltRightImage, nCalPos, 1, nWidthRight, m_pAltRightImage->m_pBitmap->GetHeight());
				graphics.SetInterpolationMode(interMode);

				// 글자!
				FontFamily fontFamily(L"나눔고딕");
				Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
				SolidBrush brush(Color(255, 0, 0, 255));
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
				graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);

				m_dcGS.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

#if 0
		// alternate image
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{
			PaintBk(pDC);

		//	graphics.DrawImage(*m_pAltImage, 0, 0);
			graphics.DrawImage(*m_pAltImage, 0, 0, m_pAltImage->m_pBitmap->GetWidth(), m_pAltImage->m_pBitmap->GetHeight());
		
			m_dcAlt.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcAlt.SelectObject(&bmp);
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// alternate image pressed
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )
			{
				PaintBk(pDC);

				// 2012.02.24 frino - Alt 영상이 커지는 문제가 발생하여 수정함
//				graphics.DrawImage(*m_pAltImage, 1, 1);
				graphics.DrawImage(*m_pAltImage, 1, 1, m_pAltImage->m_pBitmap->GetWidth(), m_pAltImage->m_pBitmap->GetHeight());
			
				m_dcAltP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// alternate image hot
			if(m_dcAltH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pAltImage->m_pBitmap->GetWidth();
				float height = (float)m_pAltImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pAltImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcAltH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp);
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}
#endif

		if (m_pCurBtn == NULL)
		{
			m_pCurBtn = &m_dcStd;
		}

		m_bHaveBitmaps = TRUE;
	}

	return NULL;
}
Exemplo n.º 21
0
void CGuiFolder::DrawFolder(CFolderBar* cfb,Style m_Style)
{
	CRect rc=cfb->m_rect;
	CBrush cb;
	CClientDC pDC(this);
	cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace());
	rc.top+=1;
	rc.right-=1;
	
	
	if (m_StyleDisplay == GUISTYLE_2003)
	{
		
		CGradient M(CSize(rc.Width(),rc.Height()));	
		if(m_Style != mOutlook)
		{
			if (GuiDrawLayer::m_Theme)
				M.PrepareVertical(&pDC,m_StyleDisplay);
			else
				M.PrepareVertical(&pDC);
		}
		else
		{
			M.PrepareCaption(&pDC,m_StyleDisplay);
		}
		M.Draw(&pDC,rc.left-1,rc.top-1,0,0,rc.Width(),rc.Height(),SRCCOPY);
		
		CRect rcWin=rc;
		//rcWin.left= gripper.left;
		rcWin.top+=5;
		rcWin.left=rcWin.right-5;
		rcWin.right=rcWin.left+2;
		rcWin.bottom-=4;
		CRect rcBlack;

		for (int i=0; i < rcWin.Height()-1; i+=4)
		{
			CRect rcWindow;
			CBrush cb;
			cb.CreateSolidBrush(::GetSysColor(COLOR_BTNHIGHLIGHT));
			rcWindow=rcWin;
			rcWindow.top=rcWin.top+i;
			rcWindow.bottom=rcWindow.top+2;
			pDC.FillRect(rcWindow,&cb);
			rcBlack=rcWindow;
			rcBlack.left-=1;
			rcBlack.top=(rcWin.top+i)-1;
			rcBlack.bottom=rcBlack.top+2;
			rcBlack.right=rcBlack.left+2;
			cb.DeleteObject();
			cb.CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
			pDC.FillRect(rcBlack,&cb);
	
		}
		
			pDC.Draw3dRect(rc, m_Style != mOutlook? GuiDrawLayer::GetRGBColorBTNHigh():GuiDrawLayer::GetRGBPressBXP(),GuiDrawLayer::GetRGBColorShadow(GuiDrawLayer::m_Style));
			
	}

	if (m_StyleDisplay == GUISTYLE_XP)
	{
		pDC.FillRect(&rc,&cb);
		if (m_typel!=mOutlook)
		{
			rc.right-=30;
		}
			
		if (m_Style == mNormal)
		{
					
			pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow(m_StyleDisplay));
			rc.DeflateRect(1,1);
			pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style),GuiDrawLayer::GetRGBColorShadow(m_StyleDisplay));
		}
		else if (m_Style == mFlat)
			pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorBTNHigh(),GuiDrawLayer::GetRGBColorShadow(m_StyleDisplay));
		else if (m_Style == mPush)
			pDC.Draw3dRect(rc, GuiDrawLayer::GetRGBColorShadow(m_StyleDisplay),GuiDrawLayer::GetRGBColorBTNHigh());
	}

	int OldMode=pDC.SetBkMode(TRANSPARENT);
	cfont = pDC.SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)));
	CString m_cadBreak=cfb->m_lpMsg;
	int cont=m_cadBreak.GetLength();
	CSize coor=pDC.GetTextExtent(m_cadBreak,m_cadBreak.GetLength());
	if ( coor.cx > rc.Width()-20)
	{
		rc.left+=1;
		while(cont > 1 )
		{
			CString m_scadtemp=m_cadBreak+"...";
			CSize coor=pDC.GetTextExtent(m_scadtemp,m_scadtemp.GetLength());
			if(coor.cx > rc.Width())
				m_cadBreak=m_cadBreak.Left(m_cadBreak.GetLength()-1);
			else
				break;
			cont--;
		}
		m_cadBreak+=_T("...");
		rc.right+=3;
		
			pDC.DrawText(m_cadBreak,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
	}
	else
	{
	  if (m_typel!=mOutlook)
			pDC.DrawText(cfb->m_lpMsg,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
	  else	
			pDC.DrawText(cfb->m_lpMsg,rc,DT_WORDBREAK|DT_SINGLELINE|DT_CENTER|DT_VCENTER);
	}

   	pDC.SetBkColor(OldMode);

}
Exemplo n.º 22
0
/************************************************************************
OnNMCustomDraw
@PARAM  : 
@RETURN : 
@REMARK : 
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/custdraw/messages/nm_customdraw.asp
@AUTHOR : youngchang ([email protected])
@HISTORY :
    2006/01/02:CREATED
************************************************************************/
void CFishListCtrl::OnNMCustomDraw ( NMHDR* pNMHDR, LRESULT* pResult )
{
    NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
    static bool bHighlighted = false;
    
    *pResult = CDRF_DODEFAULT;

    //////////////////////////////////////////////////////////////////////////
    // REGION RESIZE
    switch(pLVCD->nmcd.dwDrawStage) {
	case CDDS_ITEMPREPAINT | CDDS_SUBITEM :     //Flag combined with CDDS_ITEMPREPAINT or CDDS_ITEMPOSTPAINT if a subitem is being drawn. This will only be set if CDRF_NOTIFYITEMDRAW is returned from CDDS_PREPAINT.
        {
            CDC* originalDC = CDC::FromHandle(pLVCD->nmcd.hdc);
            if( originalDC == NULL )    return;
            
            CRect rect;			
            GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_LABEL, rect);	
            if (pLVCD->iSubItem ==  FISH_VIEWINFO_LISTCTRL_ICON_INDEX)  {
                CRect tmpRT;
                GetClientRect(&tmpRT);
                rect.left   =   0;
                rect.right  =   1024;
            }

            CMemDC pDC(originalDC, &rect);     // 자동으로 더블 버퍼링을 처리하는 DC
            pDC->SetBkMode(TRANSPARENT);
            
            customdraw_DrawBkgnd(pDC, pLVCD);           // 배경그리기
            customdraw_DrawIcon(pDC, pLVCD);            // 아이콘 그리기
            customdraw_DrawText(pDC, pLVCD);            // 글 그리기
            customdraw_DrawProgressBar(pDC, pLVCD);     //  진행바 그리기
            *pResult = CDRF_SKIPDEFAULT;
            break;
        }
    case CDDS_POSTERASE:        //After the erasing cycle is complete.
        {
            break;
        }
    case CDDS_POSTPAINT:        //After the painting cycle is complete.
        {
            break;
        }
    case CDDS_PREERASE:         //Before the erasing cycle begins.
        {
            break;
        }
 	case CDDS_PREPAINT :        //Before the painting cycle begins.
		{
			*pResult = CDRF_NOTIFYITEMDRAW;
			break;
		}
	case CDDS_ITEMPREPAINT :    //Before an item is drawn.
		{
			*pResult = CDRF_NOTIFYSUBITEMDRAW;
			break;
		}
    default:
        *pResult = CDRF_DODEFAULT;
        break;
    }
    return;
}
Exemplo n.º 23
0
void COBDPNDDlgMainRace::OnPaint()
{
	if (m_memdcBkBmp != NULL)
	{
		CClientDC pDC(this);

		CRect rect; 
		CDC   memDC; 

		GetWindowRect(&rect); 	
		memDC.CreateCompatibleDC(&pDC); 	

		CBitmap* pOldMemBmp = NULL; 
		pOldMemBmp = memDC.SelectObject(&m_cBitmapBkBmp);
		memDC.BitBlt(0,0,rect.Width(),rect.Height(),&m_memdcBkBmp,0,0,SRCCOPY);

		memDC.SetBkMode(TRANSPARENT);	

		for (int i=0;i<7;i++)
		{
			if (i==0 || i==5)
			{
				memDC.SetTextColor(RGB(0,0,0));
				memDC.SelectObject(m_fontValue);
				memDC.DrawText(m_tagDsInfo[i].strValue,-1,m_tagDsInfo[i].rectData,DT_VCENTER|DT_CENTER);
				memDC.SelectObject(m_fontText);
				memDC.DrawText(m_tagDsInfo[i].strText,-1,m_tagDsInfo[i].rectText,DT_VCENTER|DT_CENTER);
			}
			else
			{
				memDC.SetTextColor(theMainDlg->m_clrTitle);
				//没有单位居中显示
				if (theMainDlg->fGetUnitResID(m_tagDsInfo[i].strUnit) == NULL)
				{
					memDC.SelectObject(m_fontDsDataValue);
					memDC.DrawText(m_tagDsInfo[i].strValue,-1,m_tagDsInfo[i].rectData,DT_BOTTOM|DT_CENTER);
					memDC.SelectObject(m_fontDsDataText);
					memDC.DrawText(m_tagDsInfo[i].strText,-1,m_tagDsInfo[i].rectText,DT_VCENTER|DT_CENTER);
				}
				else
				{
					CRect rectTemp = m_tagDsInfo[i].rectData;
					rectTemp.right =m_tagDsInfo[i].rectUnit.left; 
					memDC.SelectObject(m_fontDsDataValue);
					memDC.DrawText(m_tagDsInfo[i].strValue,-1,rectTemp,DT_BOTTOM|DT_RIGHT);
					memDC.SelectObject(m_fontDsDataText);
					memDC.DrawText(m_tagDsInfo[i].strText,-1,m_tagDsInfo[i].rectText,DT_VCENTER|DT_CENTER);

					memDC.BitBlt(m_tagDsInfo[i].rectUnit.left,m_tagDsInfo[i].rectUnit.top,m_tagDsInfo[i].rectUnit.Width(),m_tagDsInfo[i].rectUnit.Height(),	
						&m_tagDsInfo[i].memdcUnit,0,0,SRCCOPY);
				}
			}

		}

		//
		memDC.SelectObject(theMainDlg->m_fontFootNormal);
		for (int i=0;i<MAX_FOOT_INDEX;i++)
		{
			if (theMainDlg->fGetCurrPanelIndex()== i)
				memDC.SetTextColor(theMainDlg->m_clrFootFocus);   
			else
				memDC.SetTextColor(theMainDlg->m_clrFootNormal); 		
			memDC.DrawText(theMainDlg->m_strFoot[i], -1, &theMainDlg->m_rectFoot[i], DT_CENTER);
		}

		//将背景位图复制到窗口客户区 
		pDC.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY); 

		if(pOldMemBmp)   
			memDC.SelectObject(pOldMemBmp); 

		DeleteObject(pOldMemBmp);	
		DeleteDC(memDC);

	}
	CDialog::OnPaint();
}
Exemplo n.º 24
0
void CSkinButton2::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{	
	UINT lState = lpDrawItemStruct->itemState;	

	CRect rect;
	GetClientRect(rect);

	CMemDC pDC( CDC::FromHandle(lpDrawItemStruct->hDC), rect);
	Gdiplus::Graphics graphics(pDC->m_hDC);

	// get background
	CBitmap bmp, *pOldBitmap;
	if (m_dcBk.m_hDC == NULL)
	{
		CRect rect1;
		CClientDC clDC(GetParent());
		GetWindowRect(rect1);
		GetParent()->ScreenToClient(rect1);

		m_dcBk.CreateCompatibleDC(&clDC);
		bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
		pOldBitmap = m_dcBk.SelectObject(&bmp);
		m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
		bmp.DeleteObject();
	}
	// paint backGround

	pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &m_dcBk, 0, 0, SRCCOPY);

	if( m_bDisable )
	{
		DrawImage(graphics);
	}
	else
	{
		if (lState & ODS_DISABLED)
		{
			DrawImage(graphics, DRAW_GRAY);
		}
		else
		{
			if (m_bSelected )
			{
				DrawFrame(graphics,rect );
				DrawImage(graphics, DRAW_LIGHT);
			}
			else
			{
				if (lState & ODS_SELECTED)
				{
					DrawFrame(graphics,rect );
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics, DRAW_LIGHT);
					}
				}
				else if (m_bMouseOnButton)
				{
					DrawFrame(graphics,rect );
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics,DRAW_LIGHT);
					}	
				}
				else if (lState & ODS_FOCUS)
				{				
					if( m_enmuDrawType == NO_FRAME_SELECT )
					{
						DrawFrame(graphics,rect );
					}
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics);
					}
				}
				else
				{
					if( m_enmuDrawType == NO_FRAME_SELECT )
					{
						DrawFrame(graphics,rect );
					}
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics);
					}
				}
			}
			//graphics
		}
	}

	if( m_strText.GetLength() > 0 && m_pPngImage == NULL )
	{
		Gdiplus::Bitmap bmpText( rect.Width(), rect.Height(), &graphics );
		Graphics* Ptext=Graphics::FromImage(&bmpText);
		//	Ptext->SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);

		//Matrix mx(0.25f,0,0,0.25f,1,1);
		//Ptext->SetTransform(&mx);

		Gdiplus::RectF rc( rect.left, rect.top, rect.Width(), rect.Height() );

		WCHAR   wFile[1024];   
#ifndef   UNICODE   
		MultiByteToWideChar(CP_ACP,   0,   LPCTSTR(m_strText),   -1,   wFile,  1024 );   
#else   
		lstrcpy(wFile,   szFile);   
#endif 

		StringFormat format;
		format.SetAlignment( StringAlignmentCenter );

		Gdiplus::RectF rectText, rectBack;
		rectText.X = rc.X;
		rectText.Y = rc.Y+ ( rc.Height-m_nWidth)/2;
		rectText.Width = rc.Width;
		rectText.Height = m_nWidth + rc.Height/2;

		rectBack.X = rc.X+2;
		rectBack.Y = rc.Y+1+ ( rc.Height-m_nWidth)/2;
		rectBack.Width = rc.Width-2;
		rectBack.Height = m_nWidth + rc.Height/2-1;

		Ptext->DrawString( wFile,-1 ,mp_font,rectBack,&format,&SolidBrush(Color(100,0,0,0)) );
		//graphics.SetInterpolationMode( Gdiplus::InterpolationModeHighQualityBicubic);
		//graphics.SetTextRenderingHint(  Gdiplus::TextRenderingHintAntiAlias);
		graphics.DrawImage(&bmpText,rc,0,0,bmpText.GetWidth(),bmpText.GetHeight(),UnitPixel);
		graphics.DrawString(wFile,-1,mp_font,rectText,&format,&SolidBrush(Color(255,255,255,255)));
	}
}
Exemplo n.º 25
0
//=============================================================================
//
//	The framework calls this member function when a child control is about to 
//	be drawn.  All the bitmaps are created here on the first call. Every thing
//	is done with a memory DC except the background, which get's it's information 
//	from the parent. The background is needed for transparent portions of PNG 
//	images. An always on top app (such as Task Manager) that is in the way can 
//	cause it to get an incorrect background.  To avoid this, the parent should 
//	call the SetBkGnd function with a memory DC when it creates the background.
//				
//=============================================================================
HBRUSH CGdipButton::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if(!m_bHaveBitmaps)
	{
		if(!m_pStdImage)
		{
			return NULL; // Load the standard image with LoadStdImage()
		}

		CBitmap bmp, *pOldBitmap;

		CRect rect;
		GetClientRect(rect);

		// do everything with mem dc
		CMemDC pDC(pScreenDC, rect);

		Gdiplus::Graphics graphics(pDC->m_hDC);

		// background
		if (m_dcBk.m_hDC == NULL)
		{

			CRect rect1;
			CClientDC clDC(GetParent());
			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
			bmp.DeleteObject();
		}

		// standard image
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(pDC);

			graphics.DrawImage(*m_pStdImage, 0, 0);
		
			m_dcStd.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// standard image pressed
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(pDC);

				graphics.DrawImage(*m_pStdImage, 1, 1);

				m_dcStdP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// standard image hot
			if(m_dcStdH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pStdImage->m_pBitmap->GetWidth();
				float height = (float)m_pStdImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcStdH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// grayscale image
			if(m_dcGS.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix GrayMat = {	0.30f, 0.30f, 0.30f, 0.00f, 0.00f,
										0.59f, 0.59f, 0.59f, 0.00f, 0.00f,
										0.11f, 0.11f, 0.11f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&GrayMat);

				float width = (float)m_pStdImage->m_pBitmap->GetWidth();
				float height = (float)m_pStdImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcGS.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		// alternate image
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{
			PaintBk(pDC);

			graphics.DrawImage(*m_pAltImage, 0, 0);
		
			m_dcAlt.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcAlt.SelectObject(&bmp);
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// alternate image pressed
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )
			{
				PaintBk(pDC);

				graphics.DrawImage(*m_pAltImage, 1, 1);
			
				m_dcAltP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// alternate image hot
			if(m_dcAltH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pStdImage->m_pBitmap->GetWidth();
				float height = (float)m_pStdImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pAltImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcAltH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp);
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		if(m_pCurBtn == NULL)
		{
			m_pCurBtn = &m_dcStd;
		}

		m_bHaveBitmaps = TRUE;
	}

	return NULL;
}
Exemplo n.º 26
0
void CResearchBottomView::OnDraw(CDC* dc)
{
	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	if (!pDoc->m_bDataReceived)
		return;

	CMajor* pMajor = m_pPlayersRace;
	AssertBotE(pMajor);
	if (!pMajor)
		return;
	// TODO: add draw code here

	// Doublebuffering wird initialisiert
	CMyMemDC pDC(dc);
	CRect client;
	GetClientRect(&client);

	// Graphicsobjekt, in welches gezeichnet wird anlegen
	Graphics g(pDC->GetSafeHdc());

	g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
	g.SetSmoothingMode(SmoothingModeHighSpeed);
	g.SetInterpolationMode(InterpolationModeLowQuality);
	g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
	g.SetCompositingQuality(CompositingQualityHighSpeed);
	g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

	CString fontName = "";
	Gdiplus::REAL fontSize = 0.0;
	StringFormat fontFormat;
	SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));
	CRect rect;
	rect.SetRect(0,0,m_TotalSize.cx,m_TotalSize.cy);

	CString sPrefix = pMajor->GetPrefix();
	Color color;
	color.SetFromCOLORREF(pMajor->GetDesign()->m_clrGalaxySectorText);
	fontBrush.SetColor(color);
	Bitmap* graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Backgrounds\\" + sPrefix + "researchV3.boj");

	// gibt es keine Spezialforschung zur Auswahl, so wird auf Standardanzeige umgestellt
	if (m_nCurrentTech == 6 && pMajor->GetEmpire()->GetResearch()->GetUniqueReady() == TRUE)
		m_nCurrentTech = 0;

	// Grafik zeichnen
	if (graphic)
	{
		g.DrawImage(graphic, 0, 0, 1075, 249);
		graphic = NULL;
	}
	switch(m_nCurrentTech)
	{
	case 0:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\biotech.bop"); break;
	case 1:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\energytech.bop"); break;
	case 2:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\computertech.bop"); break;
	case 3:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\propulsiontech.bop"); break;
	case 4:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\constructiontech.bop"); break;
	case 5:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\weapontech.bop"); break;
	case 6:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\specialtech.bop"); break;
	}
	if (graphic)
	{
		g.DrawImage(graphic, 790, 25, 240, 200);
		graphic = NULL;
	}
	// Name und Beschreibung der Forschung anzeigen
	CFontLoader::CreateGDIFont(pMajor, 4, fontName, fontSize);
	fontFormat.SetAlignment(StringAlignmentNear);
	fontFormat.SetLineAlignment(StringAlignmentNear);
	fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);

	CString s;
	if (m_nCurrentTech != 6)
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetTechName(m_nCurrentTech);
	else
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetCurrentResearchComplex()->GetComplexName();
	g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 30, rect.right-325, rect.bottom), &fontFormat, &fontBrush);

	CFontLoader::CreateGDIFont(pMajor, 2, fontName, fontSize);
	fontBrush.SetColor(Color(200,200,250));
	fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
	if (m_nCurrentTech != 6)
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetTechDescription(m_nCurrentTech);
	else
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetCurrentResearchComplex()->GetComplexDescription();
	g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 100, rect.right-325, rect.bottom), &fontFormat, &fontBrush);

	g.ReleaseHDC(pDC->GetSafeHdc());
}
Exemplo n.º 27
0
void CIntelBottomView::OnDraw(CDC* dc)
{
	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	if (!pDoc->m_bDataReceived)
		return;

	CMajor* pMajor = m_pPlayersRace;
	AssertBotE(pMajor);
	if (!pMajor)
		return;
	// TODO: add draw code here

	// Doublebuffering wird initialisiert
	CMyMemDC pDC(dc);
	CRect client;
	GetClientRect(&client);

	// Graphicsobjekt, in welches gezeichnet wird anlegen
	Graphics g(pDC->GetSafeHdc());

	g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
	g.SetSmoothingMode(SmoothingModeHighSpeed);
	g.SetInterpolationMode(InterpolationModeLowQuality);
	g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
	g.SetCompositingQuality(CompositingQualityHighSpeed);
	g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

	CString fontName = "";
	Gdiplus::REAL fontSize = 0.0;
	StringFormat fontFormat;
	SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));

	Color color;
	color.SetFromCOLORREF(pMajor->GetDesign()->m_clrGalaxySectorText);

	fontBrush.SetColor(color);
	Bitmap* graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Backgrounds\\" + pMajor->GetPrefix() + "diplomacyV3.boj");

	// Grafik zeichnen
	if (graphic)
	{
		g.DrawImage(graphic, 0, 0, 1075, 249);
		graphic = NULL;
	}

	// Nur in bestimmten Submenüs werden in der View3 Berichte angezeigt
	BYTE curIntelSubMenu = resources::pMainFrame->GetSubMenu(RUNTIME_CLASS(CIntelMenuView));
	if (curIntelSubMenu == 4 || curIntelSubMenu == 5)
	{
		CRect r;
		r.SetRect(0,0,m_TotalSize.cx,m_TotalSize.cy);
		short n = pMajor->GetEmpire()->GetIntelligence()->GetIntelReports()->GetActiveReport();
		if (n != -1)
		{
			CFontLoader::CreateGDIFont(pMajor, 4, fontName, fontSize);
			fontFormat.SetAlignment(StringAlignmentNear);
			fontFormat.SetLineAlignment(StringAlignmentNear);
			fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);
			CIntelObject* report = pMajor->GetEmpire()->GetIntelligence()->GetIntelReports()->GetReport(n);
			CString s;
			if (report->GetIsSpy())
				s = CLoc::GetString("SPY");
			else
				s = CLoc::GetString("SABOTAGE");
			g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 40, r.right-100, r.bottom-20), &fontFormat, &fontBrush);

			CFontLoader::CreateGDIFont(pMajor, 2, fontName, fontSize);
			fontBrush.SetColor(Color(200,200,250));
			fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
			if (report->GetOwner() == pMajor->GetRaceID())
				s = *report->GetOwnerDesc();
			else
				s = *report->GetEnemyDesc();
			g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 100, r.right-250, r.bottom-20), &fontFormat, &fontBrush);
		}
	}
	g.ReleaseHDC(pDC->GetSafeHdc());
}
Exemplo n.º 28
0
void CDiplomacyBottomView::OnDraw(CDC* dc)
{
    CBotEDoc* pDoc = resources::pDoc;
    AssertBotE(pDoc);

    if (!pDoc->m_bDataReceived)
        return;

    CMajor* pMajor = m_pPlayersRace;
    AssertBotE(pMajor);
    if (!pMajor)
        return;
    // TODO: add draw code here

    // Doublebuffering wird initialisiert
    CMyMemDC pDC(dc);
    CRect client;
    GetClientRect(&client);

    // Graphicsobjekt, in welches gezeichnet wird anlegen
    Graphics g(pDC->GetSafeHdc());

    g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
    g.SetSmoothingMode(SmoothingModeHighSpeed);
    g.SetInterpolationMode(InterpolationModeLowQuality);
    g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
    g.SetCompositingQuality(CompositingQualityHighSpeed);
    g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

    CString fontName = "";
    Gdiplus::REAL fontSize = 0.0;
    StringFormat fontFormat;
    SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));

    // Soll was über die Diplomatie angezeigt werden
    CRect rect;
    rect.SetRect(0,0,m_TotalSize.cx,m_TotalSize.cy);

    CString sPrefix = pMajor->GetPrefix();
    Color color;
    color.SetFromCOLORREF(pMajor->GetDesign()->m_clrGalaxySectorText);
    fontBrush.SetColor(color);
    Bitmap* graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Backgrounds\\" + sPrefix + "diplomacyV3.boj");

    // Grafik zeichnen
    if (graphic)
    {
        g.DrawImage(graphic, 0, 0, 1075, 249);
        graphic = NULL;
    }

    CFontLoader::CreateGDIFont(pMajor, 4, fontName, fontSize);
    fontFormat.SetAlignment(StringAlignmentNear);
    fontFormat.SetLineAlignment(StringAlignmentNear);
    fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);
    g.DrawString(CComBSTR(m_strHeadLine), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 30, rect.right, rect.bottom), &fontFormat, &fontBrush);

    if (m_strText.IsEmpty())
        g.DrawString(CComBSTR(CLoc::GetString("NO_DIPLOMATIC_NEWS")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 30, rect.right, rect.bottom), &fontFormat, &fontBrush);
    m_strHeadLine = "";

    CFontLoader::CreateGDIFont(pMajor, 2, fontName, fontSize);
    fontBrush.SetColor(Color(200,200,250));
    fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
    g.DrawString(CComBSTR(m_strText), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 100, rect.right-250, rect.bottom), &fontFormat, &fontBrush);

    g.ReleaseHDC(pDC->GetSafeHdc());
}
Exemplo n.º 29
0
void CStartMenuView::OnDraw(CDC* dc)
{
	// TODO: Fügen Sie hier Ihren spezialisierten Code ein, und/oder rufen Sie die Basisklasse auf.
	AssertBotE((CBotEDoc*)GetDocument());

	CMyMemDC pDC(dc);
	CRect client;
	GetClientRect(&client);

	// Graphicsobjekt, in welches gezeichnet wird anlegen
	Graphics g(pDC->GetSafeHdc());

	g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
	g.SetSmoothingMode(SmoothingModeHighSpeed);
	g.SetInterpolationMode(InterpolationModeLowQuality);
	g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
	g.SetCompositingQuality(CompositingQualityHighSpeed);
	g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

	// zum Start nur einen schwarzen Hintergrund mit Welcome Nachricht anzeigen
	if (m_nLogoTimer < 2)
	{
		Gdiplus::Font font(L"Calibri", 25, FontStyleBold);
		StringFormat format;
		format.SetAlignment(StringAlignmentCenter);
		format.SetLineAlignment(StringAlignmentCenter);

		CString s= CLoc::GetString("PRESENTEDBY")+"\n\n"+CLoc::GetString("PRESENTED");
		g.DrawString(CComBSTR(s), -1, &font, RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy), &format, &SolidBrush(static_cast<Gdiplus::ARGB>(Color::WhiteSmoke)));

		g.ReleaseHDC(pDC->GetSafeHdc());
		// nichts weiter Zeichnen
		return;
	}

	// Hintergrundbild anzeigen
	g.DrawImage(m_pBkgndImg, 0, 0, m_TotalSize.cx, m_TotalSize.cy);

	Gdiplus::Font font(L"Calibri", 10, FontStyleBold);
	StringFormat format;
	format.SetAlignment(StringAlignmentFar);
	format.SetLineAlignment(StringAlignmentFar);

	CString sVersion = "Birth of the Empires Alpha7 V";
	sVersion += CString(VERSION_INFORMATION.c_str());
	sVersion += "\n© by Sir Pustekuchen 2014";
	g.DrawString(CComBSTR(sVersion), -1, &font, RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy), &format, &SolidBrush(static_cast<Gdiplus::ARGB>(Color::WhiteSmoke)));

	// Hintergrundbild langsam einblenden
	if (m_nTimeCounter < 255)
	{
		Color clr(255 - m_nTimeCounter, 0, 0, 0);
		g.FillRectangle(&Gdiplus::SolidBrush(clr), RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy));

		Gdiplus::Font font(L"Calibri", 25, FontStyleBold);
		StringFormat format;
		format.SetAlignment(StringAlignmentCenter);
		format.SetLineAlignment(StringAlignmentCenter);

		Color clr2(max(0, 255 - m_nTimeCounter * 1.2), 245,245,245);
		CString s= CLoc::GetString("PRESENTEDBY")+"\n\n"+CLoc::GetString("PRESENTED");
		g.DrawString(CComBSTR(s), -1, &font, RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy), &format, &SolidBrush(clr2));
	}

	g.ReleaseHDC(pDC->GetSafeHdc());
}
Exemplo n.º 30
0
void CRoundSliderCtrl::OnPaint() 
{
	const int nMin = GetRangeMin();
	const int nMax = GetRangeMax()+1;

	const bool bDisabled = !IsWindowEnabled();

	CPaintDC dc(this); // device context for painting

#ifdef USE_MEM_DC
	CMemDC pDC(&dc);
#else
	CDC* pDC = &dc;
#endif

	int nRadius = m_nRadius;

	// Draw (clear) the background
	CRect rc;
	GetClientRect(rc);
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->SelectStockObject(NULL_PEN);
	pDC->FillSolidRect(rc, ::GetSysColor(COLOR_BTNFACE));

	// Draw the sliders channel
	if(!m_bDrawRadioButton)
	{
		DrawCircle(pDC, m_ptCenter, nRadius--, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHIGHLIGHT));
		DrawCircle(pDC, m_ptCenter, nRadius, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT));
	}

	int nPos = (((GetPos()-nMin)*360/(nMax-nMin)) + m_nZero + 360) % 360;
	if(m_bInverted) nPos = 360-nPos;

	const double dPos = ((double)(nPos))*pi/180.0;
	CPoint ptKnobCenter;

#pragma warning(disable:4244) // Disable warning "Converting 'double' to 'int', possible loss of data"
	if(m_bDrawRadioButton)
	{
		ptKnobCenter = CPoint(m_ptCenter.x + (nRadius-m_nKnobRadius) * sin(dPos), m_ptCenter.y - (nRadius-m_nKnobRadius) * cos(dPos));
	}
	else
	{
		ptKnobCenter = CPoint(m_ptCenter.x + (nRadius) * sin(dPos), m_ptCenter.y - (nRadius) * cos(dPos));
	}
#pragma warning(default:4244)

	m_ptKnobCenter = ptKnobCenter;

	if(m_bDrawRadioButton)
	{
		nRadius += 2;
	}
	else
	{
		nRadius -= 2;
	}

	if(!bDisabled)
	{
		CBrush* pOldBrush = pDC->SelectObject(CBrush::FromHandle(m_hDialBrush));
		pDC->Ellipse(m_ptCenter.x - nRadius + 1, m_ptCenter.y - nRadius + 1, m_ptCenter.x + nRadius + 1, m_ptCenter.y + nRadius + 1);
		pDC->SelectObject(pOldBrush);
	}

	DrawCircle(pDC, m_ptCenter, nRadius--, ::GetSysColor(COLOR_3DHIGHLIGHT), ::GetSysColor(COLOR_3DDKSHADOW));
	DrawCircle(pDC, m_ptCenter, nRadius--, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW));

	// Draw the knob
	int nKnobRadius = m_nKnobRadius;

	if(m_bDrawRadioButton)
	{
		nKnobRadius *= 4;
		nKnobRadius /= 5;
	}

	const CRect rcKnob(ptKnobCenter.x - nKnobRadius + 2, ptKnobCenter.y - nKnobRadius + 2, ptKnobCenter.x + nKnobRadius, ptKnobCenter.y + nKnobRadius);

	CRgn rgnKnob;
	rgnKnob.CreateEllipticRgnIndirect(rcKnob);
	if(bDisabled)
	{
		pDC->FillRgn(&rgnKnob, CBrush::FromHandle(::GetSysColorBrush(COLOR_BTNFACE)));
	}
	else
	{
		pDC->FillRgn(&rgnKnob, CBrush::FromHandle(m_hKnobBrush));
	}
	rgnKnob.DeleteObject();

	if(m_bDrawRadioButton || m_bDragging)
	{
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHIGHLIGHT));
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT));
	}
	else
	{
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DHIGHLIGHT), ::GetSysColor(COLOR_3DDKSHADOW));
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW));
	}

	// Draw the focus circle on the inside of the knob
	if(!m_bDrawRadioButton && (GetFocus() == this))
	{
		DrawCircle(pDC, ptKnobCenter, nKnobRadius-2, RGB(0, 0, 0), TRUE);
	}

	// Draw the text
	const CString strFormattedText = OnFormatText();

	if(!strFormattedText.IsEmpty())
	{
		CFont* pOldFont = pDC->SelectObject(&m_font);

		const CSize szExtent = pDC->GetTextExtent(strFormattedText);
		const CPoint ptText = CPoint(m_ptCenter.x - szExtent.cx/2, m_ptCenter.y - szExtent.cy/2);
		const int nOldTextColor = pDC->SetTextColor(m_crText);

		pDC->SetBkMode(TRANSPARENT);
		if(bDisabled)
		{
			pDC->DrawState(ptText, szExtent, strFormattedText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
		}
		else
		{
			pDC->TextOut(ptText.x, ptText.y, strFormattedText);
		}

		// Clean up
		pDC->SelectObject(pOldFont);
		pDC->SetTextColor(nOldTextColor);
	}

	// Don't call CSliderCtrl::OnPaint()
}