518抽奖软件源码之:GDI+上下左右中对齐
来源:互联网 发布:数据查询网站源码 编辑:程序博客网 时间:2024/05/16 15:49
518抽奖软件源码之:GDI+上下左右中对齐
GDIPLUS(gdi+)对齐处理的函数源码
//单行文本,rc内对齐,align是水平对齐,valign是垂直对齐//void Tapp::paint_str(HDC hDc, const WCHAR* str, LOGFONT& lf, COLORREF color, RECT& rc, WORD align, WORD valign){if (!str) return;if (rc.right - rc.left <= 1 || rc.bottom - rc.top <= 1) return;StringFormat fmt;fmt.SetFormatFlags(StringFormatFlagsNoWrap | StringFormatFlagsNoClip | StringFormatFlagsMeasureTrailingSpaces);if (align == ALIGN_NEAR) fmt.SetAlignment(StringAlignmentNear);else if (align == ALIGN_CENTER) fmt.SetAlignment(StringAlignmentCenter);else fmt.SetAlignment(StringAlignmentFar);fmt.SetLineAlignment(StringAlignmentNear);RectF rcF;rcF.X = rc.left;rcF.Y = rc.top;rcF.Width = rc.right - rc.left;rcF.Height = rc.bottom - rc.top;FontFamily ff(lf.lfFaceName);Font gfont(hDc, &lf);SolidBrush bru(Color(GetRValue(color), GetGValue(color), GetBValue(color)));Graphics g(hDc);int style = FontStyleRegular;if (lf.lfItalic) style = FontStyleItalic;if (lf.lfWeight == FW_BOLD) style = FontStyleBold;if (lf.lfItalic && lf.lfWeight == FW_BOLD) style = FontStyleBoldItalic;double r = (double)(ff.GetCellAscent(style) + ff.GetCellDescent(style)) / (double)ff.GetLineSpacing(style);if (align == ALIGN_NEAR) rcF.Width += 500.0;else if (align == ALIGN_FAR) { rcF.X -= 500.0; rcF.Width += 500.0; }else { rcF.X -= 500.0; rcF.Width += 1000.0; }if (valign == ALIGN_NEAR) rcF.Height += 500.0;else if (valign == ALIGN_CENTER) {rcF.Y -= 500.0;rcF.Height += 1000.0;rcF.Y += ((rcF.Height - gfont.GetHeight(&g)*r) / 2.0);}else {rcF.Y -= 500.0;rcF.Height += 500.0;rcF.Y += (rcF.Height - gfont.GetHeight(&g)*r);}SetTextRenderingHint(TextRenderingHintAntiAlias);g.DrawString(str, -1, &gfont, rcF, &fmt, &bru);}
阅读全文
0 0
- 518抽奖软件源码之:GDI+上下左右中对齐
- 518抽奖软件源码之:检查文件名合法性
- 518抽奖软件源码之:窗口化、全屏化、扩展屏
- 518抽奖软件源码之:删除文件夹及下面的所有文件
- 518抽奖软件源码之:使得除零异常可被捕获(VC++)
- 518抽奖软件源码之:主窗口上含对话框时如何最小化
- 518抽奖软件源码之:ImageStone显示处理透明PNG图片
- UILabel 上下左右对齐
- 抽奖软件
- 年会抽奖 抽奖软件 抽奖系统
- 用 PLuckyDraw(晚会抽奖之星) 软件,进行公司年会抽奖!
- 微博抽奖软件
- 随机抽奖软件
- java 抽奖软件
- 抽奖软件webapi开发
- 滚动照片抽奖软件
- HTML5超炫砸蛋抽奖源码
- 518抽奖软件——极简设计、极致体验
- csdn 直接粘贴待图片文章解决办法
- Makefile学习心得
- webservice 执行连接oracle报错32位不能运行64位系统
- FreeSWITCH学习笔记 第一场 第一个镜头 安装启动
- Trimble Inpho UASMaster 7.1.3.51242 1DVD
- 518抽奖软件源码之:GDI+上下左右中对齐
- 曲率-通俗讲解
- JAVA集合类基础知识
- 如何配置pip>python
- cocos2dx实现截屏并保存图片
- form与table
- Spring WebSocket
- Java-23种设计模式目录总览
- UVA 12661 Funny Car Racing