错在哪里?
建1个form,设置:
autoredraw=true
scalemode=3 ' pixel
加入command1
在command1_click事件中:
------------------------
Dim x As String, RT As RECT, i As Long
x = "我们爱祖国...."
i = Len(x)
RT.Top = 20
RT.Left = 20
RT.Bottom = 300
RT.Right = 300
Call ExtTextOut(Me.hdc, 0, 0, 4, RT, x, i, 0&)
----------------------------
为什么Form显示什么也没有?
exttextout 返回值为1
问题点数:0、回复次数:10Top
1 楼xxfeiyu(潇湘飞雨)回复于 2004-09-04 00:02:47 得分 0
???Top
2 楼James0001(虾米—什么时候成大虾?)回复于 2004-09-04 03:49:51 得分 0
ExtTextOut 后
me.refreshTop
3 楼BlueBeer(1win)回复于 2004-09-04 05:36:10 得分 0
'Start a new project, and add this code to Form1
Const ETO_OPAQUE = 2
Private Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal wOptions As Long, ByVal lpRect As Any, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
Private Sub Form_Paint()
Dim Arr(0 To 5) As Long
Const mStr = "Hello !"
'API uses pixels
Me.ScaleMode = vbPixels
'Set distance between characters
For x = 0 To 5
If x Mod 2 = 0 Then
Arr(x) = 25
Else
Arr(x) = 10
End If
Next x
'call ExtTextOut
ExtTextOut Me.hdc, 0, 0, ETO_OPAQUE, ByVal 0&, mStr, Len(mStr), Arr(0)
End Sub
【函数】
ExtTextOut
【操作系统】
Win9X:Yes
WinNT:Yes
【声明】
ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal wOptions As Long, lpRect As Rect, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
【说明】
经过扩展的文本描绘函数。也请参考SetTextAlign函数
【返回值】
Long,非零表示成功,零表示失败。会设置GetLastError
【其它】
【参数表】
hdc ------------ Long,设备场景的句柄
x,y ------------ Long,以逻辑坐标表示的一个点,指定了绘图起点
wOptions ------- Long,下述标志常数的任意组合
ETO_CLIPPED
将文本剪切出指定的矩形
ETO_GLPYH_INDEX
lpRect --------- Rect,指定一个矩形,用于对文本进行格式化处理。可指定长整数0,在不用矩形区域的前提下描绘文本
lpString
String,欲描绘的字串
lpString是一个字样索引表。参考对GetCharacterPlacement函数的说明。只适用于Win95 - ETO_OPAQUE
在正式描绘文本前,用当前的背景色填充矩形
nCount --------- Long,字串中要显示出来的字符数
lpDx ----------- Long,如果不是零,这个参数就代表指向一个Long值数组的指针。该数组对每一对字符的间距进行了说明(采用逻辑单位)。其中第一个条目是第一和第二个字符的间距;第二个条目是第二和第三个字符的间距;以此类推。如果为零,函数就使用字体的默认间距设置Top
4 楼rainstormmaster(暴风雨 v2.0)回复于 2004-09-04 08:36:10 得分 0
ExtTextOut
The ExtTextOut function draws a character string by using the currently selected font. An optional rectangle may be provided, to be used for clipping, opaquing, or both.
VB4-32,5,6
Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal wOptions As Long, lpRect As Rect, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
VB.NET
System.Drawing.Graphics.DrawString
Operating Systems Supported
Requires Windows NT 3.1 or later; Requires Windows 95 or later
Library
Gdi32
Parameter Information
?hdc
Identifies the device context.
?X
Specifies the logical x-coordinate of the reference point used to position the string.
?Y
Specifies the logical y-coordinate of the reference point used to position the string.
?fuOptions
Specifies how to use the application-defined rectangle. This parameter can be a combination of the following values:
ETO_CLIPPED
The text will be clipped to the rectangle.
ETO_GLYPH_INDEX
Windows 95 only: The lpString array refers to an array returned from GetCharacterPlacement and should be parsed directly by GDI as no further language-specific processing is required. Glyph indexing only applies to TrueType fonts, but the flag can be used for Windows bitmap and vector fonts to indicate no further language processing is necessary and GDI should process the string directly. Note that all glyph indices are 16-bit values even though the string is assumed to be an array of 8-bit values for raster fonts.
ETO_OPAQUE
The current background color should be used to fill the rectangle.
ETO_RTLREADING
Windows 95 only: If this value is specified and a Hebrew or Arabic font is selected into the device context, the string is output using right-to-left reading order. If this value is not specified, the string is output in left- to-right order. The same effect can be achieved by setting the TA_RTLREADING value in SetTextAlign. This value is preserved for backward compatability.
The ETO_GLYPH_INDEX and ETO_RTLREADING values cannot be used together. Because ETO_GLYPH_INDEX implies that all language processing has been completed, the function ignores the ETO_RTLREADING flag if also specified.
?lprc
Points to an optional RECT structure that specifies the dimensions of a rectangle that is used for clipping, opaquing, or both.
?lpString
Points to the character string to be drawn. The string does not need to be zero-terminated, since cbCount specifies the length of the string.
?cbCount
Specifies the number of characters in the string.
?lpDx
Points to an optional array of values that indicate the distance between origins of adjacent character cells. For example, lpDx[i] logical units separate the origins of character cell i and character cell i + 1.
Return Values
If the string is drawn, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Top
5 楼xxfeiyu(潇湘飞雨)回复于 2004-09-04 17:26:28 得分 0
ExtTextOut 后
me.refresh
-------------------------------
测试无效
Top
6 楼xxfeiyu(潇湘飞雨)回复于 2004-09-04 23:42:16 得分 0
up .........Top
7 楼DemonLoveLizzy(^_^)!!! 用户中文昵称 ? 是什么东东 ? :)回复于 2004-09-05 00:14:32 得分 0
//Dim x As String, RT As RECT, i As Long
RECT是个结构,你声明了没有?
Top
8 楼xxfeiyu(潇湘飞雨)回复于 2004-09-05 00:58:45 得分 0
申明没问题
程序没报错
就是不在窗体上写字Top
9 楼xxfeiyu(潇湘飞雨)回复于 2004-09-05 10:27:03 得分 0
up ...Top
10 楼xxfeiyu(潇湘飞雨)回复于 2004-09-05 22:17:56 得分 0
upTop




