本文整理汇总了C++中StringFormat::SetFormatFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ StringFormat::SetFormatFlags方法的具体用法?C++ StringFormat::SetFormatFlags怎么用?C++ StringFormat::SetFormatFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringFormat
的用法示例。
在下文中一共展示了StringFormat::SetFormatFlags方法的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);
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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);
}
示例5: 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;
}
示例6: 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);
}
示例7: Draw
void TextRenderGdiplus::Draw(const WCHAR *s, size_t sLen, RectF& bb, bool isRtl) {
PointF pos;
bb.GetLocation(&pos);
if (!isRtl) {
gfx->DrawString(s, (INT)sLen, currFont->font, pos, nullptr, textColorBrush);
} else {
StringFormat rtl;
rtl.SetFormatFlags(StringFormatFlagsDirectionRightToLeft);
pos.X += bb.Width;
gfx->DrawString(s, (INT)sLen, currFont->font, pos, &rtl, textColorBrush);
}
}
示例8: Draw
void CEventColonization::Draw(Graphics* g, CGraphicPool* graphicPool) const
{
CEventScreen::Draw(g, graphicPool);
CString fontName = "";
Gdiplus::REAL fontSize = 0.0;
StringFormat fontFormat;
SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));
CBotEDoc* pDoc = resources::pDoc;
AssertBotE(pDoc);
CMajor* pMajor = dynamic_cast<CMajor*>(pDoc->GetRaceCtrl()->GetRace(m_sRace));
AssertBotE(pMajor);
CFontLoader::CreateGDIFont(pMajor, 5, fontName, fontSize);
fontFormat.SetAlignment(StringAlignmentCenter);
fontFormat.SetLineAlignment(StringAlignmentCenter);
fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);
Gdiplus::Color color;
CFontLoader::GetGDIFontColor(pMajor, 3, color);
fontBrush.SetColor(color);
g->DrawString(CComBSTR(m_strHeadline), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(0,0,1280,96), &fontFormat, &fontBrush);
CFontLoader::CreateGDIFont(pMajor, 3, fontName, fontSize);
fontFormat.SetAlignment(StringAlignmentCenter);
fontFormat.SetLineAlignment(StringAlignmentCenter);
fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
g->DrawString(CComBSTR(m_strText), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(100,96,1080,128), &fontFormat, &fontBrush);
// Buttons zeichnen
CFontLoader::GetGDIFontColor(pMajor, 2, color);
fontBrush.SetColor(color);
for (int i = 0; i < m_Buttons.GetSize(); i++)
m_Buttons.GetAt(i)->DrawButton(*g, graphicPool, Gdiplus::Font(CComBSTR(fontName), fontSize), fontBrush);
}
示例9: SetStringFormat
void ProcessDateTime::SetStringFormat(StringFormat &format)
{
UINT formatFlags;
formatFlags = Gdiplus::StringFormatFlagsNoFitBlackBox
| Gdiplus::StringFormatFlagsMeasureTrailingSpaces;
format.SetFormatFlags(formatFlags);
format.SetTrimming(Gdiplus::StringTrimmingWord);
format.SetAlignment(Gdiplus::StringAlignmentNear);
}
示例10: DrawControl
void CLinkButton::DrawControl(CDC &dc, CRect rcUpdate)
{
int nWidth = m_rc.Width();
int nHeight = m_rc.Height();
if(!m_bUpdate)
{
UpdateMemDC(dc, nWidth * 4, nHeight);
for(int i = 0; i < 4; i++)
{
m_memDC.BitBlt(i * nWidth, 0, nWidth, nHeight, &dc, m_rc.left ,m_rc.top, SRCCOPY);
}
Color clrText[4] = {m_clrTextNormal, m_clrTextHover, m_clrTextDown, m_clrTextDisable};
Graphics graphics(m_memDC);
BSTR bsFont = m_strFont.AllocSysString();
FontFamily fontFamily(bsFont);
Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );
::SysFreeString(bsFont);
StringFormat strFormat;
strFormat.SetAlignment(StringAlignmentNear);
strFormat.SetFormatFlags( StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);
Size sizeText = GetTextBounds(font, strFormat, m_strTitle);
CPoint point = GetOriginPoint(nWidth, nHeight, sizeText.Width, sizeText.Height,
GetGDIAlignment(m_uAlignment), GetGDIVAlignment(m_uVAlignment));
m_rcText.SetRect(m_rc.left, m_rc.top + point.y, m_rc.left + sizeText.Width, m_rc.top + point.y + sizeText.Height);
for(int i = 0; i < 4; i++)
{
SolidBrush solidBrush(clrText[i]);
RectF rect((Gdiplus::REAL)(i * nWidth), (Gdiplus::REAL)point.y, (Gdiplus::REAL)nWidth, (Gdiplus::REAL)sizeText.Height);
BSTR bsTitle = m_strTitle.AllocSysString();
graphics.DrawString(bsTitle, (INT)wcslen(bsTitle), &font, rect, &strFormat, &solidBrush);
::SysFreeString(bsTitle);
}
}
dc.BitBlt(m_rc.left,m_rc.top, m_rc.Width(), m_rc.Height(), &m_memDC, m_enButtonState * nWidth, 0, SRCCOPY);
}
示例11: GetMaxItemWidth
int CLMenu::GetMaxItemWidth()
{
int w = 0;
HDC dc = CreateCompatibleDC(0);
Graphics g(dc);
RectF r;
Font font(L"Arial", FONT_SIZE);
StringFormat *stringFormat = new StringFormat();
stringFormat->SetAlignment(StringAlignmentNear);
stringFormat->SetLineAlignment(StringAlignmentCenter);
stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);
stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);
POSITION p = items.GetHeadPosition();
while(p)
{
r.X = 0;
r.Y = 0;
r.Width = 0;
r.Height = 0;
CLMenuItem *item = items.GetAt(p);
if(item->visible)
{
g.MeasureString(item->text.GetBuffer(), item->text.GetLength(), &font, r, &r);
if(r.Width > w)
{
w = (int)r.Width;
}
}
items.GetNext(p);
}
delete stringFormat;
DeleteObject(dc);
return w;
}
示例12: GetTextBounds
// 获取文字需要的显示区域(使用非换行的默认格式)
Size GetTextBounds(const Font& font,const CString& strText)
{
StringFormat strFormat;
strFormat.SetAlignment(StringAlignmentNear);
strFormat.SetFormatFlags( StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);
GraphicsPath path;
FontFamily fontfamily;
font.GetFamily(&fontfamily);
BSTR bsText = strText.AllocSysString();
path.AddString(bsText,-1,&fontfamily,font.GetStyle(),font.GetSize(),PointF(0,0),&strFormat);
::SysFreeString(bsText);
RectF rcBound;
path.GetBounds(&rcBound);
REAL rHeight = font.GetHeight(0.0f);
return Size((int)(rcBound.Width > (int)rcBound.Width ? rcBound.Width + 1 : rcBound.Width),
(int)(rHeight > (int)rHeight ? rHeight + 4 : rHeight + 1));
//return Size((int)(rcBound.Width > (int)rcBound.Width ? rcBound.Width + 1 : rcBound.Width),
// (int)(rcBound.Height > (int)rcBound.Height ? rcBound.Height + 2 : rcBound.Height + 1));
}
示例13: AddMenu
int CDuiMenu::AddMenu(CString strText, UINT uMenuID, CString strImage, BOOL bSelect, int nIndex)
{
CControlBase * pControlBase = NULL;
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( StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);
Size size = GetTextBounds(font, strFormat, strText);
if(size.Width > m_nWidth - m_nLeft - 4)
{
m_nWidth = size.Width + m_nLeft + 4;
}
pControlBase = new CMenuItem(GetSafeHwnd(),this, uMenuID, CRect(0, 0, 0, 0), strText, m_nLeft, bSelect);
((CControlBaseFont*)pControlBase)->SetFont(m_strFont, m_nFontWidth, m_fontStyle);
if(!strImage.IsEmpty())
{
((CMenuItem *)pControlBase)->SetBitmap(strImage);
}
if(nIndex >= 0 && nIndex < (int)m_vecControl.size())
{
m_vecControl.insert(m_vecControl.begin() + nIndex, pControlBase);
}
else
{
m_vecControl.push_back(pControlBase);
}
SetMenuPoint();
return m_vecControl.size();
}
示例14: DrawControl
void CDuiGridCtrl::DrawControl(CDC &dc, CRect rcUpdate)
{
// 列表画图方法:
// 1.列表的虚拟高度为每一行高度*行数
// 2.列表显示的top坐标由scroll控件记录
// 3.重画时候,根据top坐标位置计算出显示的第一行的序号,根据显示高度计算出显示的最后一行的序号
// 4.根据计算出的显示的行,画相应的内容到内存dc中
// 5.计算出显示的top坐标进行内存dc的拷贝
int nTotalColumnWidth = GetTotalColumnWidth(); // 总的列宽度
int nViewWidth = m_rc.Width() - m_nScrollWidth; // 减去滚动条的显示区域宽度
CDuiScrollHorizontal* pScrollH = (CDuiScrollHorizontal*)m_pControScrollH;
int nCurPosH = pScrollH->GetScrollCurrentPos(); // 当前left位置
int nMaxRangeH = pScrollH->GetScrollMaxRange();
int nContentWidth = (nTotalColumnWidth > nViewWidth) ? nTotalColumnWidth : nViewWidth; // 内容部分的宽度(如果总的列宽小于显示区域宽度,则使用显示区域宽度)
m_nVirtualLeft = (nMaxRangeH > 0) ? (int)((double)nCurPosH*(nContentWidth-nViewWidth)/nMaxRangeH) : 0; // 当前滚动条位置对应的虚拟的left位置
int nHeightAll = m_vecRowInfo.size()*m_nRowHeight; // 总的虚拟高度 //m_rc.Height();
CDuiScrollVertical* pScrollV = (CDuiScrollVertical*)m_pControScrollV;
int nCurPosV = pScrollV->GetScrollCurrentPos(); // 当前top位置
int nMaxRangeV = pScrollV->GetScrollMaxRange();
m_nVirtualTop = (nMaxRangeV > 0) ? (int)((double)nCurPosV*(nHeightAll-m_rc.Height())/nMaxRangeV) : 0; // 当前滚动条位置对应的虚拟的top位置
if(m_nVirtualTop < 0)
{
m_nVirtualTop = 0;
pScrollV->SetScrollCurrentPos(0);
}
m_nFirstViewRow = m_nVirtualTop / m_nRowHeight; // 显示的第一行序号
m_nLastViewRow = (m_nVirtualTop + m_rc.Height() - m_nHeaderHeight) / m_nRowHeight; // 显示的最后一行序号
if(m_nLastViewRow >= (int)m_vecRowInfo.size())
{
m_nLastViewRow = m_vecRowInfo.size() - 1;
}
if(m_nLastViewRow < 0)
{
m_nLastViewRow = 0;
}
int nHeightView = (m_nLastViewRow - m_nFirstViewRow +1) * m_nRowHeight; // 显示涉及到的虚拟高度
int nYViewPos = m_nVirtualTop - (m_nFirstViewRow * m_nRowHeight); // 内存dc显示到屏幕时候的top位置
if(nYViewPos < 0)
{
nYViewPos = 0;
}
if(!m_bUpdate)
{
UpdateMemDC(dc, nTotalColumnWidth, nHeightView);
Graphics graphics(m_memDC);
m_memDC.BitBlt(m_nVirtualLeft, 0, nViewWidth, nHeightView, &dc, m_rc.left, m_rc.top, WHITENESS); // 画白色背景
DrawVerticalTransition(m_memDC, dc, CRect(m_nVirtualLeft, nYViewPos, nViewWidth+m_nVirtualLeft, m_rc.Height()+nYViewPos-m_nHeaderHeight), // 背景透明度
m_rc, m_nBkTransparent, m_nBkTransparent);
BSTR bsFontTitle = m_strFontTitle.AllocSysString();
FontFamily fontFamilyTitle(bsFontTitle);
Font fontTitle(&fontFamilyTitle, (REAL)m_nFontTitleWidth, m_fontTitleStyle, UnitPixel);
::SysFreeString(bsFontTitle);
BSTR bsFont = m_strFont.AllocSysString();
FontFamily fontFamily(bsFont);
Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
::SysFreeString(bsFont);
SolidBrush solidBrush(m_clrText); // 正常文字画刷
SolidBrush solidBrushH(m_clrTextHover); // 热点文字画刷
SolidBrush solidBrushD(m_clrTextDown); // 当前行画刷
SolidBrush solidBrushT(m_clrTitle); // 标题文字画刷
SolidBrush solidBrushS(m_clrSeperator); // 分割线画刷
graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );
// 设置普通文字的水平和垂直对齐方式
DUI_STRING_ALIGN_DEFINE();
strFormat.SetTrimming(StringTrimmingEllipsisWord); // 以单词为单位去尾,略去部分使用省略号
//strFormat.SetFormatFlags( StringFormatFlagsNoClip | StringFormatFlagsMeasureTrailingSpaces);
if(!m_bTextWrap)
{
strFormat.SetFormatFlags(StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces); // 不换行
}
// 标题字段采用中间对齐
StringFormat strFormatHeader;
strFormatHeader.SetAlignment(StringAlignmentCenter); // 中间对齐
strFormatHeader.SetLineAlignment(StringAlignmentCenter); // 中间对齐
if(!m_bTextWrap)
{
strFormatHeader.SetFormatFlags(StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces); // 不换行
}
// 画标题行
if((m_nHeaderHeight > 0) && (m_vecColumnInfo.size() > 0))
{
// 画单元格内容
int nPosItemX = 0;
for(size_t j = 0; j < m_vecColumnInfo.size(); j++)
{
GridColumnInfo &columnInfo = m_vecColumnInfo.at(j);
int nWidth = columnInfo.nWidth;
if(j == 0)
//.........这里部分代码省略.........
示例15: LayerDraw
void CNotification::LayerDraw(CDIB *dib)
{
if(!dib)
{
dib = CNotification::dib;
}
CRect rect;
GetWindowRect(&rect);
dib->Resize(rect.Width(), rect.Height());
if(!dib->Ready())
{
return;
}
RectF rf(0.0f, 0.0f, (REAL)dib->Width(), (REAL)dib->Height());
rf.Width -= SHADOW_SIZE;
rf.Height -= SHADOW_SIZE;
Graphics g(dib->dc);
g.SetCompositingMode(CompositingModeSourceOver);
g.SetSmoothingMode(SmoothingModeAntiAlias);
GraphicsPath *path = new GraphicsPath();
float radius = rf.Height;
path->AddArc(rf.X + rf.Width - radius, rf.Y + rf.Height - radius, radius - 1, radius - 1, 0, 90);
path->AddArc(rf.X, rf.Y + rf.Height - radius, radius - 1, radius - 1, 90, 90);
path->AddArc(rf.X, rf.Y, radius - 1, radius - 1, 180, 90);
path->AddArc(rf.X + rf.Width - radius, rf.Y, radius - 1, radius - 1, 270, 90);
path->CloseFigure();
g.TranslateTransform(SHADOW_SIZE, SHADOW_SIZE);
g.ScaleTransform((rf.Width - SHADOW_SIZE) / rf.Width, (rf.Height - SHADOW_SIZE) / rf.Height);
SolidBrush brush2(0xf0000000);
g.FillPath(&brush2, path);
g.ResetTransform();
dib->Blur(dib->Rect(), CRect(0, 0, 0, 0), SHADOW_SIZE);
brush2.SetColor(0xffffffff);
g.FillPath(&brush2, path);
rf.X += rf.Height * 0.1f;
rf.Y += rf.Height * 0.1f;
rf.Width -= rf.Height * 0.2f;
rf.Height -= rf.Height * 0.2f;
radius = rf.Height;
path->Reset();
path->AddArc(rf.X + rf.Width - radius, rf.Y + rf.Height - radius, radius - 1, radius - 1, 0, 90);
path->AddArc(rf.X, rf.Y + rf.Height - radius, radius - 1, radius - 1, 90, 90);
path->AddArc(rf.X, rf.Y, radius - 1, radius - 1, 180, 90);
path->AddArc(rf.X + rf.Width - radius, rf.Y, radius - 1, radius - 1, 270, 90);
path->CloseFigure();
LinearGradientBrush brush(rf, 0xff6fa6de, 0xff1e6cbb, LinearGradientModeVertical);
g.FillPath(&brush, path);
delete path;
Font font(L"Arial", rect.Height() * 0.6f, FontStyleRegular, UnitPixel);
StringFormat *stringFormat = new StringFormat();
stringFormat->SetAlignment(StringAlignmentCenter);
stringFormat->SetLineAlignment(StringAlignmentCenter);
stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);
stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);
CString s;
GetWindowText(s);
g.DrawString(s.GetBuffer(), s.GetLength(), &font, rf, stringFormat, &brush2);
delete stringFormat;
}