当前位置: 首页>>代码示例>>C++>>正文


C++ StringFormat::SetAlignment方法代码示例

本文整理汇总了C++中StringFormat::SetAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ StringFormat::SetAlignment方法的具体用法?C++ StringFormat::SetAlignment怎么用?C++ StringFormat::SetAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringFormat的用法示例。


在下文中一共展示了StringFormat::SetAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawButton

// 绘制按钮
void CDUIButton::DrawButton( Gdiplus::Graphics&  graphics)
{
	// 获取按钮图片信息
	UINT iCount = m_nImageCount;
	int	iButtonIndex = 0;
	if(m_bDisabled && iCount >= 4) iButtonIndex = 3;
	else if(m_bPressed && iCount >= 3)iButtonIndex = 2;
	else if(m_bHovering && iCount >= 2)iButtonIndex = 1;
	else iButtonIndex = 0;

	// 在指定位置绘制按钮
	int iWidth = m_pImage->GetWidth()/iCount;
	int iHeight = m_pImage->GetHeight();
	RectF grect;
	grect.X=(Gdiplus::REAL)m_rcRect.left;
	grect.Y=(Gdiplus::REAL)m_rcRect.top;
	grect.Width = (Gdiplus::REAL)m_rcRect.Width();
	grect.Height = (Gdiplus::REAL)m_rcRect.Height();

	graphics.DrawImage(m_pImage, grect, (Gdiplus::REAL)iWidth*iButtonIndex,0,(Gdiplus::REAL)iWidth,(Gdiplus::REAL)iHeight, UnitPixel);

	StringFormat stringFormat;

	if (m_pIcon)
	{
		PointF ptIcon(m_ptIcon.x,m_ptIcon.y);
		graphics.DrawImage(m_pIcon,ptIcon);

		grect.X=(Gdiplus::REAL)m_ptIcon.x + m_pIcon->GetWidth() + 2;
		grect.Width = (Gdiplus::REAL)m_rcRect.Width() - m_pIcon->GetWidth() - 2;

		stringFormat.SetFormatFlags( StringFormatFlagsDirectionVertical);
		stringFormat.SetAlignment(StringAlignmentCenter);
		stringFormat.SetLineAlignment(StringAlignmentNear);
	}
	else
	{
		//stringFormat.SetFormatFlags( StringFormatFlagsDirectionVertical);
		stringFormat.SetAlignment(StringAlignmentCenter);
		stringFormat.SetLineAlignment(StringAlignmentCenter);
	}

	if (!m_strCaption.IsEmpty())
	{
		//绘制文字
		FontFamily fontFamily(L"宋体");
		Gdiplus::Font font(&fontFamily, 10, FontStyleRegular, UnitPoint);


		CStringW strTitle(m_strCaption);
		SolidBrush brush((ARGB)Color::White);
		if (m_bDisabled)
		{
			brush.SetColor((ARGB)Color::Gray);
		}

		graphics.DrawString(strTitle, strTitle.GetLength(), &font,grect,&stringFormat, &brush);
	}

}
开发者ID:Chingliu,项目名称:WTLControl,代码行数:61,代码来源:DUIButton.cpp

示例2: DrawText

void CRenderUtility::DrawText( HDC hDC,LPCTSTR lpszText,RECT& rctSrc,COLORREF color/*= RGB(0,0,0)*/, LPCTSTR lpszFontFamily /*=L"΢ÈíÑźÚ"*/,int nFontSize /*= 12*/,DWORD dwAlignStyle /*= SS_CENTER*/,DWORD dwFontStyle /*= FontStyleRegular*/, int nAlpha /*= 255*/ )
{
	if(0 == nAlpha || NULL == lpszText) return;

	Graphics graphics(hDC);
	FontFamily fontFamily(lpszFontFamily);
	FontStyle fontStyle = (FontStyle)dwFontStyle;

	Gdiplus::Font font(&fontFamily,(float)nFontSize,fontStyle,UnitPixel);
	RectF rcText((float)rctSrc.left,(float)rctSrc.top,(float)RECT_WIDTH(rctSrc),(float)RECT_HEIGHT(rctSrc));
	SolidBrush brush(Color(nAlpha,GetRValue(color),GetGValue(color),GetBValue(color)));
	StringFormat txtFormat;
	if(dwAlignStyle & SS_CENTERIMAGE)
	{
		txtFormat.SetLineAlignment(StringAlignmentCenter);
	}
	if(dwAlignStyle & SS_CENTER){
		txtFormat.SetAlignment(StringAlignmentCenter);
	}
	else if(dwAlignStyle & SS_RIGHT){
		txtFormat.SetFormatFlags(StringFormatFlagsDirectionRightToLeft);
		txtFormat.SetAlignment(StringAlignmentNear);
	}

	graphics.DrawString(lpszText,-1,&font,rcText,&txtFormat,&brush);
}
开发者ID:aliu927,项目名称:LayerWndTest,代码行数:26,代码来源:RenderUtility.cpp

示例3: CalculateWidth

int CNotification::CalculateWidth(int defaultSize)
{
	CString s;
	GetWindowText(s);
	
	CDIB dib;
	dib.Resize(1, 1);
	if(!dib.Ready())
	{
		return defaultSize;
	}
	Graphics g(dib.dc);
	g.SetCompositingMode(CompositingModeSourceOver);
	g.SetSmoothingMode(SmoothingModeAntiAlias);

	RectF rf(0, 0, 0, 0);

	Font font(L"Arial", defaultSize * 0.6f, FontStyleRegular, UnitPixel);
	StringFormat *stringFormat = new StringFormat();
	stringFormat->SetAlignment(StringAlignmentCenter);
	stringFormat->SetLineAlignment(StringAlignmentCenter);
	stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);
	stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);

	g.MeasureString(s.GetBuffer(), s.GetLength(), &font, rf, stringFormat, &rf);

	delete stringFormat;

	defaultSize += (int)rf.Width - defaultSize / 2;
	return defaultSize;
}
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:31,代码来源:notifications.cpp

示例4: Draw

void LeftAxesGrid::Draw()
{
	Font font(L"Arial", (REAL)chart.fontHeight, FontStyleBold);
	Color color(chart.colorAxes);
	Pen pen(color, 2);
	SolidBrush fontColor(chart.colorAxes);
	StringFormat format;
	format.SetAlignment(StringAlignmentNear);
	double height;
	double minAA = ((int)minA * 1000) / 1000;
	double maxAA = ((int)maxA * 1000) / 1000;
	int maxLen = 0;
	chart.offsetAxesLeft = 7 + chart.GetCountDigit(minAA, maxAA, height, font, maxLen);
	int x = chart.rect.left + chart.offsetAxesLeft;
	int bottom = chart.rect.bottom - chart.offsetAxesBottom;
	chart.g->DrawLine(&pen, x, chart.rect.top + chart.offsetAxesTop, x, bottom);
 //   char buf[32];
	wchar_t wbuf[32];
	PointF origin;
	RectF rect;	
	double deltaTick = 0;
	double deltaDigit = 0;
	double digit = 0;
	double minTick = 0;
	OffsetAxes(
		int(height * 2.5)
		, chart.rect.bottom - chart.rect.top - chart.offsetAxesBottom - chart.offsetAxesTop
		, chart.minAxesY
		, chart.maxAxesY
		, deltaDigit
		, deltaTick
		, digit
		, minTick
		);
	minA = digit;
	double offs = chart.offsetGridY = chart.rect.bottom - chart.offsetAxesBottom + minTick;	
	chart.deltaDigitY = deltaDigit;
	chart.deltaTickY = deltaTick;
	while(bottom < offs)
	{
		offs -= deltaTick;
		digit += deltaDigit;
	}
	origin.X = (REAL)chart.rect.left;
	int len;
	digit += deltaDigit;
	int int_d = 0;
	while(offs > chart.rect.top + chart.offsetAxesTop + deltaTick / 2)
	{
		chart.g->DrawLine(&pen, (REAL)x - 5, (REAL)offs, (REAL)x, (REAL)offs);
		_itow((int)digit, wbuf, 10);
		len = wcslen(wbuf);
		chart.g->MeasureString(wbuf, len, &font, origin, &format, &rect);
		origin.Y = REAL(offs  - deltaTick);
		chart.g->DrawString(wbuf, len, &font, origin, &fontColor);
		offs -= deltaTick;
		digit += deltaDigit;
	}	
	maxA = digit;
}
开发者ID:Andrew90,项目名称:def,代码行数:60,代码来源:GridChart.cpp

示例5: DrawMessage

static REAL DrawMessage(Graphics &g, const WCHAR *msg, REAL y, REAL dx, Color color)
{
    ScopedMem<WCHAR> s(str::Dup(msg));

    Font f(L"Impact", 16, FontStyleRegular);
    RectF maxbox(0, y, dx, 0);
    RectF bbox;
    g.MeasureString(s, -1, &f, maxbox, &bbox);

    bbox.X += (dx - bbox.Width) / 2.f;
    StringFormat sft;
    sft.SetAlignment(StringAlignmentCenter);
    if (trans::IsCurrLangRtl())
        sft.SetFormatFlags(StringFormatFlagsDirectionRightToLeft);
#if DRAW_MSG_TEXT_SHADOW
    {
        bbox.X--; bbox.Y++;
        SolidBrush b(Color(0xff, 0xff, 0xff));
        g.DrawString(s, -1, &f, bbox, &sft, &b);
        bbox.X++; bbox.Y--;
    }
#endif
    SolidBrush b(color);
    g.DrawString(s, -1, &f, bbox, &sft, &b);

    return bbox.Height;
}
开发者ID:qingzhengzhuma,项目名称:sumatrapdf,代码行数:27,代码来源:Installer.cpp

示例6: Draw

//-----------------------------------------------------------------------------------
void LeftAxes::Draw()
{
	Font font(L"Arial", (REAL)chart.fontHeight, FontStyleBold);
	Color color(chart.colorAxes);
	Pen pen(color, 2);
	SolidBrush fontColor(chart.colorAxes);
	StringFormat format;
	format.SetAlignment(StringAlignmentNear);
	double height;
	
	int maxLen = 0;
	chart.offsetAxesLeft = 10 + chart.GetCountDigit(chart.minAxesY, chart.maxAxesY, height, font, maxLen);
	maxLen += 2;
	int x = chart.rect.left + chart.offsetAxesLeft;
	int bottom = chart.rect.bottom - chart.offsetAxesBottom;
	chart.g->DrawLine(&pen, x, chart.rect.top + chart.offsetAxesTop, x, bottom);
	char buf[32];
	wchar_t wbuf[32];
	PointF origin;
	RectF rect;	
	double deltaTick = 0;
	double deltaDigit = 0;
	double digit = 0;
	double minTick = 0;
	OffsetAxes(
		int(height * 2)
		, chart.rect.bottom - chart.rect.top - chart.offsetAxesBottom - chart.offsetAxesTop
		, chart.minAxesY
		, chart.maxAxesY
		, deltaDigit
		, deltaTick
		, digit
		, minTick
		);
	double offs = chart.offsetGridY = chart.rect.bottom - chart.offsetAxesBottom + minTick;
	chart.deltaTickY = deltaTick;
	chart.deltaDigitY = deltaDigit;
	while(bottom < offs)
	{
		offs -= deltaTick;
		digit += deltaDigit;
	}
	origin.X = (REAL)chart.rect.left;
	int len;
	while(offs > chart.rect.top + chart.offsetAxesTop)
	{
		chart.g->DrawLine(&pen, (REAL)x - 5, (REAL)offs, (REAL)x, (REAL)offs);
		gcvt(digit, 5, buf);
		mbstowcs(wbuf, buf, 32);
		len = wcslen(wbuf);
		if(len <= maxLen)
		{
			chart.g->MeasureString(wbuf, len, &font, origin, &format, &rect);
			origin.Y = REAL(offs - deltaTick + deltaTick/2);
			chart.g->DrawString(wbuf, len, &font, origin, &fontColor);
		}
		offs -= deltaTick;
		digit += deltaDigit;
	}	
}
开发者ID:Andrew90,项目名称:def,代码行数:61,代码来源:Chart.cpp

示例7: DrawControl

void CCheckButton::DrawControl(CDC &dc, CRect rcUpdate)
{
	int nWidth = m_rc.Width();
	int nHeight = m_rc.Height();

	if(!m_bUpdate)
	{
		UpdateMemDC(dc, nWidth * 6, nHeight);

		Graphics graphics(m_memDC);
		CRect  rcTemp(0, 0, nWidth, nHeight);

		for(int i = 0; i < 6; i++)
		{
			m_memDC.BitBlt(i * nWidth, 0, nWidth, nHeight, &dc, m_rc.left ,m_rc.top, SRCCOPY);

			graphics.DrawImage(m_pImage, Rect(rcTemp.left, rcTemp.top + (nHeight - m_sizeImage.cy) / 2,   m_sizeImage.cx, m_sizeImage.cy),
				i * m_sizeImage.cx, 0, m_sizeImage.cx, m_sizeImage.cy, UnitPixel);

			rcTemp.OffsetRect(nWidth, 0);
		}
		
		if(!m_strTitle.IsEmpty())
		{
			m_memDC.SetBkMode(TRANSPARENT);

			rcTemp.SetRect(0, 0, nWidth, nHeight);

			FontFamily fontFamily(m_strFont.AllocSysString());
			Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
			graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );

			StringFormat strFormat;
			strFormat.SetAlignment(StringAlignmentNear);
			strFormat.SetFormatFlags( StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);
			Size size = GetTextBounds(font, strFormat, m_strTitle);
			CPoint point = GetOriginPoint(nWidth - m_sizeImage.cx - 3, nHeight, size.Width, size.Height, m_uAlignment, m_uVAlignment);

			for(int i = 0; i < 6; i++)
			{
				SolidBrush solidBrush(enBSDisable == i ? Color(128, 128, 128) : m_clrText);

				RectF rect(m_sizeImage.cx + 3 + point.x + i * nWidth, point.y, nWidth - m_sizeImage.cx - 3 - point.x, size.Height);
				graphics.DrawString(m_strTitle.AllocSysString(), (INT)wcslen(m_strTitle.AllocSysString()), &font, 
					rect, &strFormat, &solidBrush);

				// 画焦点框(虚线框)
				if(m_bIsFocus)
				{
					Pen pen(Color(128, 128, 128), 1);
					pen.SetDashStyle(DashStyleDot);
					RectF rectFocus(point.x + i * nWidth, point.y, m_sizeImage.cx + 6 + size.Width, size.Height);
					graphics.DrawRectangle(&pen, rectFocus);
				}
			}
		}
	}

	dc.BitBlt(m_rc.left,m_rc.top, m_rc.Width(), m_rc.Height(), &m_memDC, m_enButtonState * nWidth, 0, SRCCOPY);
}
开发者ID:Runcy,项目名称:DuiVision,代码行数:60,代码来源:CheckButton.cpp

示例8: GPDrawShadowTextSimple

void GPDrawShadowTextSimple( Graphics&gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
	Gdiplus::Font& gcfont = fontIn;
	Rect rcText = CRect2Rect(rcIn);
	StringFormat fmt;
	fmt.SetAlignment(StringAlignmentCenter);
	fmt.SetTrimming(StringTrimmingEllipsisWord);
	fmt.SetLineAlignment(StringAlignmentCenter);
	StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;

	GraphicsContainer  gcContainer = gc.BeginContainer();
	gc.SetSmoothingMode(SmoothingModeAntiAlias);
	CComBSTR btrTxtIn(strTxtIn);

	SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
	RectF rfText = Rect2RectF(rcText);
	if (shadowBrushClrIn != 0)
	{
		rfText.Offset(1.0, 1.0);
		gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
	}

	textbrush.SetColor(ARGB2Color(BrushClrIn));
	gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
	gc.EndContainer(gcContainer);
}
开发者ID:tianyx,项目名称:TxUIProject,代码行数:26,代码来源:GDIDrawFunc.cpp

示例9: drawSpeed

int drawSpeed(Graphics *gra, int posX, int posY){

	// 速度表示部の背景を白くする
	SolidBrush b(Color(180,255,255,255));
	backGra->FillRectangle(&b, posX, posY, 200, 14);
	// フォント設定
	Font font(L"MS Pゴシック",10);
	// 文字色
	SolidBrush strBrush(Color::Black);
	// 文字列作成
	char tmp[256];
	sprintf(tmp, "R:%.1fkbps S:%.1fkbps", 
		BYTES_TO_KBPS(stats.getPerSecond(Stats::BYTESIN)-stats.getPerSecond(Stats::LOCALBYTESIN)),
		BYTES_TO_KBPS(stats.getPerSecond(Stats::BYTESOUT)-stats.getPerSecond(Stats::LOCALBYTESOUT)));
	_bstr_t bstr(tmp);
	// 文字表示範囲指定
	StringFormat format;
	format.SetAlignment(StringAlignmentCenter);
	RectF r((REAL)posX, (REAL)posY, (REAL)200, (REAL)14);
	// 文字描画
	gra->DrawString(bstr, -1, &font, r, &format, &strBrush);



	return posY + 15;
}
开发者ID:PyYoshi,项目名称:PeerCastIM-Mod,代码行数:26,代码来源:gui.cpp

示例10: GetVirtualHeight

// 计算显示的字符串总高度应该是多高
int CDuiText::GetVirtualHeight()
{
	BSTR bsFont = m_strFont.AllocSysString();
	FontFamily fontFamily(bsFont);
	Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
	::SysFreeString(bsFont);

	StringFormat strFormat;
	strFormat.SetAlignment(StringAlignmentNear);
	strFormat.SetFormatFlags( StringFormatFlagsNoClip | StringFormatFlagsMeasureTrailingSpaces);

	int nWidth = m_rc.Width();
	if(m_bScrollV)
	{
		nWidth -= 8;
	}
	
	Size size = GetTextBounds(font, strFormat, nWidth, m_strTitle);

	// 滚动条只有在需要的总高度大于文本框的高度时候才会显示
	m_pControScrollV->SetVisible(size.Height > m_rc.Height());
	((CDuiScrollVertical*)m_pControScrollV)->SetScrollMaxRange(size.Height);

	return size.Height;
}
开发者ID:caomw,项目名称:DuiVision,代码行数:26,代码来源:DuiText.cpp

示例11: DrawString

void DrawString( Graphics *graphics, int x, int y, const wstring &str)
{
	StringFormat format;
	format.SetAlignment(StringAlignmentCenter);

	graphics->DrawString( str.c_str(), -1, g_font,
		PointF((REAL)x, (REAL)y),
		&format, g_yellowBrush);
}
开发者ID:sgajaejung,项目名称:C-Cplusplus-Lecture-Beginner,代码行数:9,代码来源:gradius.cpp

示例12: Draw

void CElcNonWndButton::Draw(PVOID pvGraphics)
{
	if (!pvGraphics)
		return;

	Rect rect(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height());

	// draw background image 
	if (m_background.background.pImage) {
		thePainter.DrawImage(pvGraphics,
			&m_background.background,
			&rect,
			m_state,
			1,
			NULL);
	}

	// draw icon
	if (m_icon.pImage) {
		thePainter.DrawImage(pvGraphics,
			&m_icon,
			&rect,
			m_state,
			1,
			NULL);
	}

	if (!m_strText.IsEmpty()) {
		LOGFONT lf = {0};
		m_ftText.GetLogFont(&lf);

		FontFamily family(lf.lfFaceName);
		Font ftText(&family, 9);

		StringFormat stringfmt;
		stringfmt.SetAlignment(StringAlignmentCenter);
		stringfmt.SetLineAlignment(StringAlignmentCenter);
		stringfmt.SetHotkeyPrefix(HotkeyPrefixHide);

		Color crText;
		crText.SetFromCOLORREF(m_background.crTextNormal);

		RectF rcText;
		rcText.X = (REAL)m_rect.left;
		rcText.Y = (REAL)m_rect.top + 4;
		rcText.Width = (REAL)m_rect.Width();
		rcText.Height = (REAL)m_rect.Height();

		((Graphics *)pvGraphics)->DrawString(m_strText, 
			-1, 
			&ftText, 
			rcText, 
			&stringfmt, 
			&SolidBrush(crText));
	}
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:56,代码来源:ElcNonWndButton.cpp

示例13: drawSkin

void CPropSelUser::drawSkin(void)
{

	if(!imgDialog)
		return;
	CDC *pdc=this->GetWindowDC();
	if(!pdc)return;
	CRect rc;
	this->GetWindowRect(&rc);
	Graphics g(pdc->m_hDC);

	int topHeight=32;//GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYSIZE)+6;
	g.DrawImage(imgDialog,RectF(0.0f,0.0f,10.0f,topHeight),0.0f,0.0f,10.0f,topHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(10.0f,0.0f,rc.Width()-20,topHeight),9.0f,0.0f,1.0f,topHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF((REAL)rc.Width()-10,0.0f,10.0f,topHeight),imgDialog->GetWidth()-10,0.0f,10.0f,topHeight,UnitPixel);
	m_bkColor=pdc->GetPixel(9,topHeight-1);
	m_txtColor^=m_bkColor;
	int bottomHeight=10;
	g.DrawImage(imgDialog,RectF(0.0f,topHeight,10.0f,rc.Height()-topHeight-bottomHeight),0.0f,topHeight,10.0f,imgDialog->GetHeight()-topHeight-bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(rc.Width()-10.0f,topHeight,10.0f,rc.Height()-topHeight-bottomHeight),
		imgDialog->GetWidth()-10,topHeight,10.0f,1,UnitPixel);

	g.DrawImage(imgDialog,RectF(0,rc.Height()-bottomHeight,imgDialog->GetWidth()-5,bottomHeight),0,imgDialog->GetHeight()-bottomHeight,10,bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(10,rc.Height()-bottomHeight,rc.Width()-20,bottomHeight),10,imgDialog->GetHeight()-bottomHeight,1,bottomHeight,UnitPixel);
	g.DrawImage(imgDialog,RectF(rc.Width()-10,rc.Height()-bottomHeight,10,bottomHeight),imgDialog->GetWidth()-10,imgDialog->GetHeight()-bottomHeight,10,bottomHeight,UnitPixel);

	CString s="宋体";

	Font font(s.AllocSysString(),12,0,UnitPixel);
	SolidBrush brush(Color(255,255,255));
	s.Format("请选择道具 [%s] 使用对象,当前游戏中有 %d 个可用用户对象",propItemName,maxUser);
	g.DrawString(s.AllocSysString(),-1,&font,PointF(5,5),0,&brush);
	
	StringFormat sf;
	sf.SetAlignment(StringAlignmentCenter);

	m_bnClose.Invalidate(FALSE);
	brush.SetColor(Color(0,0,0));
	Pen pen(&brush);//20081128
	REAL x,y,w,h; //20081128,计算具体图片的位置
	for(int i=0;i<maxUser;i++)
	{
		x=userRect[i].left+(66-userImg[i]->GetWidth())/2;
		y=userRect[i].top+(105-userImg[i]->GetHeight())/2;
		w=userImg[i]->GetWidth();
		h=userImg[i]->GetHeight();
		g.DrawImage(userImg[i],x,y,w,h);//画头像,替换原来的画头像代码
		//画选择区域边框
		g.DrawRectangle(&pen,userRect[i].left , userRect[i].top , 
			userRect[i].Width() , userRect[i].Height());
		g.DrawString(userName[i].AllocSysString() ,-1 ,&font , 
			RectF(userRect[i].left,userRect[i].bottom+5,userRect[i].Width(),30),&sf,&brush);
	}
	g.ReleaseHDC(pdc->m_hDC);
}
开发者ID:lincoln56,项目名称:robinerp,代码行数:55,代码来源:PropSelUser.cpp

示例14: onPaintText

void UILabel::onPaintText(Graphics& graphics, Rect rect)
{
    StringFormat stringFormat;
    stringFormat.SetTrimming(m_font.m_trimming);
    stringFormat.SetAlignment(m_font.m_horizen);
    stringFormat.SetLineAlignment(m_font.m_vertical);

    Font font(m_font.m_family, m_font.m_size, m_font.m_style, m_font.m_unit);
    SolidBrush brush(getTrueColor(m_font.m_color));
    graphics.DrawString(m_font.m_text, -1, &font, m_font.m_rect, &stringFormat, &brush);
}
开发者ID:smithLiLi,项目名称:dev,代码行数:11,代码来源:UIComomCtrls.cpp

示例15: draw

// 绘制汽车
void Car::draw(Graphics* pGraphics)
{
    // 计算坐标
    RectF rcDest;
    Image *pImg = nullptr;
    
    switch (m_direction)
    {
    case UPWARD:
        rcDest.X = m_location.x * 50;
        rcDest.Width = 50;
        rcDest.Y = m_location.y * 50;
        rcDest.Height = 100;
        pImg = (*m_imgArray)[0];
        break;
    case DOWNWARD:
        rcDest.X = m_location.x * 50;
        rcDest.Width = 50;
        rcDest.Y = (m_location.y - 1) * 50;
        rcDest.Height = 100;
        pImg = (*m_imgArray)[1];
        break;
    case LEFT:
        rcDest.X = m_location.x * 50;
        rcDest.Width = 100;
        rcDest.Y = m_location.y * 50;
        rcDest.Height = 50;
        pImg = (*m_imgArray)[2];
        break;
    case RIGHT:
        rcDest.X = (m_location.x - 1) * 50;
        rcDest.Width = 100;
        rcDest.Y = m_location.y * 50;
        rcDest.Height = 50;
        pImg = (*m_imgArray)[3];
        break;
    }
    // 绘制图形
    pGraphics->DrawImage(pImg, rcDest);
    

    // 绘制编号
    WCHAR string[4] = { '\0' };
    swprintf_s(string, 4, L"%d", m_cardNum);
    FontFamily   fontFamily(L"Arial");
    Gdiplus::Font         font(&fontFamily, 16, FontStyleBold, UnitPoint);
    StringFormat stringFormat;
    SolidBrush   solidBrush(Color(0, 0, 0));
    stringFormat.SetAlignment(StringAlignmentCenter);
    stringFormat.SetLineAlignment(StringAlignmentCenter);

    pGraphics->DrawString(string, -1, &font, rcDest, &stringFormat, &solidBrush);
}
开发者ID:shimachao,项目名称:virtualPark,代码行数:54,代码来源:Car.cpp


注:本文中的StringFormat::SetAlignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。