VB 怎么将文本框中的文字旋转任意角度后打印到图片框中去
VB 如何将文本框中的文字旋转任意角度后打印到图片框中去
如题所示。VB 如何将文本框中的文字旋转任意角度后打印到图片框中去。给个思路或者模块。谢谢
------解决方案--------------------
在VB中建立可旋转的文本特效
在VB中利用Windows的API函数可以实现很多的VB无法实现的扩展功能,下面的程序介绍的是如何通过调用Windows中的API函数实现文本旋转显示的特级效果。
首先建立一个工程文件,然后选菜单中的Project
------解决方案--------------------
Add Class Module 加入一个新的类文件,并将这个类的Name属性改变为APIFont,然后在类的代码窗口中加入以下的代码:
Option Explicit
Private Declare Function SelectClipRgn Lib “gdi32”(ByVal hdc As Long, ByVal hRgn As _
Long) As Long
Private Declare Function CreateRectRgn Lib “gdi32”(ByVal X1 As Long, ByVal Y1 As _
Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetTextColor Lib “gdi32”(ByVal hdc As Long, ByVal crColor As _
Long) As Long
Private Declare Function DeleteObject Lib “gdi32”(ByVal hObject As Long) As Long
Private Declare Function CreateFontIndirect Lib “gdi32” Alias “CreateFontIndirectA” _
(lpLogFont As LOGFONT) As Long
Private Declare Function SelectObject Lib “gdi32”(ByVal hdc As Long, ByVal hObject As _
Long) As Long
Private Declare Function TextOut Lib “gdi32” Alias “TextOutA” (ByVal hdc As Long, _
ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As _
Long) As Long
Private Declare Function SetTextAlign Lib “gdi32”(ByVal hdc As Long, ByVal wFlags _
As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const TA_LEFT = 0
Private Const TA_RIGHT = 2
Private Const TA_CENTER = 6
Private Const TA_TOP = 0
Private Const TA_BOTTOM = 8
Private Const TA_BASELINE = 24
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * 50
End Type
Private m_LF As LOGFONT
Private NewFont As Long
Private OrgFont As Long
Public Sub CharPlace(o As Object, txt$, X, Y)
Dim Throw As Long
Dim hregion As Long
Dim R As RECT
R.Left = X
R.Right = X + o.TextWidth(txt$) * 2
如题所示。VB 如何将文本框中的文字旋转任意角度后打印到图片框中去。给个思路或者模块。谢谢
VB 图像处理 文字 旋转
------解决方案--------------------
在VB中建立可旋转的文本特效
在VB中利用Windows的API函数可以实现很多的VB无法实现的扩展功能,下面的程序介绍的是如何通过调用Windows中的API函数实现文本旋转显示的特级效果。
首先建立一个工程文件,然后选菜单中的Project
------解决方案--------------------
Add Class Module 加入一个新的类文件,并将这个类的Name属性改变为APIFont,然后在类的代码窗口中加入以下的代码:
Option Explicit
Private Declare Function SelectClipRgn Lib “gdi32”(ByVal hdc As Long, ByVal hRgn As _
Long) As Long
Private Declare Function CreateRectRgn Lib “gdi32”(ByVal X1 As Long, ByVal Y1 As _
Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetTextColor Lib “gdi32”(ByVal hdc As Long, ByVal crColor As _
Long) As Long
Private Declare Function DeleteObject Lib “gdi32”(ByVal hObject As Long) As Long
Private Declare Function CreateFontIndirect Lib “gdi32” Alias “CreateFontIndirectA” _
(lpLogFont As LOGFONT) As Long
Private Declare Function SelectObject Lib “gdi32”(ByVal hdc As Long, ByVal hObject As _
Long) As Long
Private Declare Function TextOut Lib “gdi32” Alias “TextOutA” (ByVal hdc As Long, _
ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As _
Long) As Long
Private Declare Function SetTextAlign Lib “gdi32”(ByVal hdc As Long, ByVal wFlags _
As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const TA_LEFT = 0
Private Const TA_RIGHT = 2
Private Const TA_CENTER = 6
Private Const TA_TOP = 0
Private Const TA_BOTTOM = 8
Private Const TA_BASELINE = 24
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * 50
End Type
Private m_LF As LOGFONT
Private NewFont As Long
Private OrgFont As Long
Public Sub CharPlace(o As Object, txt$, X, Y)
Dim Throw As Long
Dim hregion As Long
Dim R As RECT
R.Left = X
R.Right = X + o.TextWidth(txt$) * 2