vc高手帮小弟解决一个问题吧。。。

tyscon 2004-07-29 07:43:05
http://community.csdn.net/Expert/topic/3216/3216124.xml?temp=.5510065

两个100分都给你了 。

感激不尽
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
名牌大灰狼 2004-07-29
  • 打赏
  • 举报
回复
The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth).

To specify additional formatting options, use the DrawTextEx function.

int DrawText(
HDC hDC, // handle to DC
LPCTSTR lpString, // text to draw
int nCount, // text length
LPRECT lpRect, // formatting dimensions
UINT uFormat // text-drawing options
);


DT_BOTTOM底部对齐 Specifies bottom-justified text. This value must be combined with DT_SINGLELINE.


DT_CALCRECT计算指定文字时所需要矩形尺寸 Determines the width and height of the rectangle. If there are multiple lines of text, DrawText will use the width of the rectangle pointed to by lpRect and extend the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText will modify the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text, but does not draw the text.


DT_CENTER中部对齐 Centers text horizontally.


DT_END_ELLIPSIS or DT_PATH_ELLIPSIS Replaces part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle. The given string is not modified unless the DT_MODIFYSTRING flag is specified.
You can specify DT_END_ELLIPSIS to replace characters at the end of the string, or DT_PATH_ELLIPSIS to replace characters in the middle of the string. If the string contains backslash (\) characters, DT_PATH_ELLIPSIS preserves as much as possible of the text after the last backslash.

DT_EXPANDTABS Expands tab characters. The default number of characters per tab is eight.


DT_EXTERNALLEADING Includes the font抯 external leading in the line height. Normally, external leading is not included in the height of a line of text.


DT_LEFT左对齐 Aligns text flush-left.


DT_MODIFYSTRING Modifies the given string to match the displayed text. This flag has no effect unless the DT_END_ELLIPSIS or DT_PATH_ELLIPSIS flag is specified.
Note Some uFormat flag combinations can cause the passed string to be modified. Using DT_MODIFYSTRING with either DT_END_ELLIPSIS or DT_PATH_ELLIPSIS may cause the string to be modified, causing an assertion in the CString override.


DT_NOCLIP Draws without clipping. DrawText is somewhat faster when DT_NOCLIP is used.


DT_NOPREFIX禁止使用&前缀 Turns off processing of prefix characters. Normally, DrawText interprets the ampersand (&) mnemonic-prefix character as a directive to underscore the character that follows, and the two-ampersand (&&) mnemonic-prefix characters as a directive to print a single ampersand. By specifying DT_NOPREFIX, this processing is turned off.


DT_PATH_ELLIPSIS


DT_RIGHT右对齐 Aligns text flush-right.


DT_SINGLELINE单行输出 Specifies single line only. Carriage returns and linefeeds do not break the line.


DT_TABSTOP设置TAB字符所占宽度 Sets tab stops. The high-order byte of nFormat is the number of characters for each tab. The default number of characters per tab is eight.


DT_TOP定部对齐 Specifies top-justified text (single line only).


DT_VCENTER中部对齐 Specifies vertically centered text (single line only).


DT_WORDBREAK每行只在单词间被折行 Specifies word-breaking. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by lpRect. A carriage return杔inefeed sequence will also break the line.
名牌大灰狼 2004-07-29
  • 打赏
  • 举报
回复
DrawText可以指定在一个矩形中输出单行或多行文字,并且可以规定对齐方式和使用何种风格。nFormat可以是多种以下标记的组合(利用位或操作)以达到选择输出风格的目的
CDC::SetTextColor( COLORREF crColor )进行设置,如果你希望改变背景色就利用CDC::SetBkColor( COLORREF crColor ),很多时候你可能需要透明的背景色你可以利用CDC::SetBkMode( int nBkMode )设置,可接受的参数
交差使用以上函数了,应该可以实现吧.
tyscon 2004-07-29
  • 打赏
  • 举报
回复
楼上的,我要的不是字体旋转,是行间距啊。同时实现行间距,还不破坏stringFormat的
stringAlignment,lineAlignment以及你说的旋转等方法。
名牌大灰狼 2004-07-29
  • 打赏
  • 举报
回复
你应该在这边也写问题.就不用传过去在看你那张贴子了.在这答吧.站个一楼
BOOL CreateFont( int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename );

  其中各个参数的含义如下:

nHeight // 字体的高度
nWidth // 字体的宽度
nEscapement // 字体旋转的角度
nWeight // 字体的轻重
bItalic // 是否为斜体
bUnderline // 是否有下划线
cStrikeOut // 是否有强调线
nCharSet // 字符集
nOutPrecision // 输出精度
nClipPrecision // 剪裁精度
nQuality // 输出质量
nPitchAndFamily // 间距和字体族
lpszFacename //字体名,可为空
  利用这些参数,可以方便地设置各种字体参数,比如高度、宽度等。也许细心人已经看出来了,在这些参数中,同我们所要讨论的问题关系最大的是nEscapement,它表示字符的基线同坐标的X轴之间的旋转角度,从X轴正方向开始沿逆时针方向旋转,以十分之一度为单位。lpszFacename指明字体的名称,如“宋体”、“行楷”。需要指出的是,个别字体不支持字体旋转,主要是字体宽度不可变的种类。有了这些基础,实现字体旋转就是一件简单的事了。在VC 6.0下新建一工程,然后在视类的OnDraw(CDC pDC)中添加如下代码:

  CFont NewFont;

   NewFont.CreateFont(50,50,300,0,0,0,0,0,

GB2312—CHARSET,OUT—TT—PRECIS,

CLIP—DEFAULT—PRECIS,DEFAULT—QUALITY, FIXED—PITCH,″″);

  //创建一逻辑字体,高50、宽50、倾斜30度,其他参数请查阅文档

CFont pOldFont=pDC-〉SelectObject(&NewFont);//选进设备描述表

pDC-〉SetTextColor(RGB(0,0,0));

  //设置字体颜色,这里是黑色

pDC-〉TextOut(0,250,″旋转的字体″);//在(0,250)处显示

pDC-〉SelectObject(pOldFont);

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧