关于逻辑字体的问题(高手进)

天狼皓月 2005-09-13 03:57:13
首先说一下,下面是完整代码可以直接运行(在调用上没有任何错误,换别的函数都可以正常运行。就这一个不行)。首先说一下错在哪里,错就错在传结构上面 在CreateFontIndirect(ByVal lpLogFont As LOGFONT) As Long 函数中 包含一个描述自定义字体的结构体。在vb 6.0里 可以用 Type 的方法来声明,在delphi 里面 本身就带有一个logfont 类型的结构体 可以直接声明。我在 vb 6.0 和 delphi 里面都实现了。但是在vb.net 里就不行了 ,在vb.net 里不再支持 Type了 要用 Structure方法来 写结构体,但是在传送的时候就会出错.可能.net 也有类似logfont的结构体只是我不知道,也可能是和vb.net里面的字体是只读属性有关。但是我怎么也调试不出来,请高手指正。可能大家和我一样也是在vb.net里第一次用这个函数,但是我希望大家能一起来试一试,学习一下。 在调用方面没有错误,我是按照MSDN上面的调用非托管的dll实例代码改的.以下是源代码
'源代码
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(136, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Label1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dd As New HelloWorld
dd.Main()

End Sub
End Class
Public Class Win32
Structure LOGFONT '声明结构体
Dim lfHeight As Long '字体的高度
Dim lfWidth As Long '字符平均宽度
Dim lfEscapement As Long '行与水平页角度
Dim lfOrientation As Long '基线与水平角度
Dim lfWeight As Long '笔划的粗细
Dim lfItalic As Byte '非零为斜体
Dim lfUnderline As Byte '非零为下划线
Dim lfStrikeOut As Byte '非零为中划线
Dim lfCharSet As Byte '指定字符集
Dim lfOutPrecision As Byte '输出精度
Dim lfClipPrecision As Byte '裁剪精度
Dim lfQuality As Byte '输出质量
Dim lfPitchAndFamily As Byte '字体的字距和族
Dim lfFaceName As String '选择DC中字体的名称

End Structure

Public Declare Function CreateFontIndirectA Lib "gdi32" (ByVal lpLogFont As LOGFONT) As Long
Public Declare Function SelectObject Lib "gdi32.dll" Alias "SelectObject" (ByVal hdc As Long, ByVal hObject As Long) As Long
End Class

Public Class HelloWorld

Public Shared Sub Main()

Dim LF As Win32.LOGFONT
Dim hFont As Long
Dim MyFont As New Win32

With LF
.lfHeight = 100 '字符高度
.lfWidth = 50 '字符宽度
.lfEscapement = 0 '文本倾斜度,逆时针方向为正,一圈总角度为3600
.lfOrientation = 0 '字符倾斜角度
.lfWeight = 0 '字体的轻重
.lfUnderline = 0 '是否加下划线
.lfStrikeOut = 0 '是否加删除线
.lfCharSet = 1 '指定字符集
.lfOutPrecision = 0 '输出、输入精度
.lfClipPrecision = 0 '剪辑精度
.lfQuality = 0 '设置输出质量
.lfPitchAndFamily = 0 '字间距
.lfFaceName = "宋体" '字体名称
End With


MyFont.CreateFontIndirectA(LF) '就是这里传结构的时候出错了

End Sub
End Class
...全文
295 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
pupo 2005-09-19
  • 打赏
  • 举报
回复
Dim bitmap As Bitmap = bitmap.FromFile("D:\1.jpg")
Dim g As Graphics = Graphics.FromImage(bitmap)
Dim lf As Win32.LOGFONT

With lf
.lfHeight = 300 '字符高度
.lfWidth = 50 '字符宽度
.lfEscapement = 0 '文本倾斜度,逆时针方向为正,一圈总角度为3600
.lfOrientation = 0 '字符倾斜角度
.lfWeight = 0 '字体的轻重
.lfUnderline = 0 '是否加下划线
.lfStrikeOut = 0 '是否加删除线
.lfCharSet = 1 '指定字符集
.lfOutPrecision = 0 '输出、输入精度
.lfClipPrecision = 0 '剪辑精度
.lfQuality = 0 '设置输出质量
.lfPitchAndFamily = 0 '字间距
.lfFaceName = "宋体" '字体名称
End With
Dim hFont As Integer = Win32.CreateFontIndirect(lf)
hFont = Win32.CreateFontIndirect(lf)
Dim dc As IntPtr = g.GetHdc
Win32.SelectObject(dc, hFont)
Win32.TextOut(dc, 0, 0, "OK", 2)
Win32.DeleteObject(hFont)
g.ReleaseHdc(dc)
bitmap.Save("D:\2.jpg")
g.Dispose()
Me.PictureBox1.Image = bitmap
天狼皓月 2005-09-19
  • 打赏
  • 举报
回复
太厉害了 高手 谢谢了
天狼皓月 2005-09-17
  • 打赏
  • 举报
回复
'完整原代码
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(120, 216)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'PictureBox1
'
Me.PictureBox1.Location = New System.Drawing.Point(32, 24)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(288, 152)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBox1.TabIndex = 2
Me.PictureBox1.TabStop = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(376, 245)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bitmap As Bitmap = bitmap.FromFile("D:\1.jpg")
Dim g As Graphics = Graphics.FromImage(bitmap)
Dim lf As Win32.LOGFONT
Dim hDC As IntPtr
With lf
.lfHeight = 200 '字符高度
.lfWidth = 50 '字符宽度
.lfEscapement = 0 '文本倾斜度,逆时针方向为正,一圈总角度为3600
.lfOrientation = 0 '字符倾斜角度
.lfWeight = 0 '字体的轻重
.lfUnderline = 0 '是否加下划线
.lfStrikeOut = 0 '是否加删除线
.lfCharSet = 1 '指定字符集
.lfOutPrecision = 0 '输出、输入精度
.lfClipPrecision = 0 '剪辑精度
.lfQuality = 0 '设置输出质量
.lfPitchAndFamily = 0 '字间距
.lfFaceName = "宋体" '字体名称
End With
Dim hFont As Integer = Win32.CreateFontIndirect(lf)
hFont = Win32.CreateFontIndirect(lf)
Dim dc As IntPtr = Win32.GetDC(Me.PictureBox1.Handle) '就是这里什么设置了句柄
Win32.SelectObject(dc, hFont) '写上去的时候却不管用
' Win32.TextOut(dc, 0, 0, "OK", 2)


g.DrawString("I am a Boy", Me.PictureBox1.Font, Brushes.Black, 0, 0)
bitmap.Save("D:\2.jpg")
Me.PictureBox1.Image = bitmap
Win32.DeleteObject(hFont)
End Sub


End Class
Public Class Win32

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Public Structure LOGFONT
Public lfHeight As Integer
Public lfWidth As Integer
Public lfEscapement As Integer
Public lfOrientation As Integer
Public lfWeight As Integer
Public lfItalic As Byte
Public lfUnderline As Byte
Public lfStrikeOut As Byte
Public lfCharSet As Byte
Public lfOutPrecision As Byte
Public lfClipPrecision As Byte
Public lfQuality As Byte
Public lfPitchAndFamily As Byte
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public lfFaceName As String
End Structure

Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (ByRef lpLogFont As LOGFONT) As Integer
Public Declare Function SelectObject Lib "gdi32.dll" Alias "SelectObject" (ByVal hdc As IntPtr, ByVal hObject As Integer) As Integer
Public Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As IntPtr) As IntPtr
Public Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal lpString As String, ByVal nCount As Integer) As Integer
Public Declare Function DeleteObject Lib "gdi32" Alias "DeleteObject" (ByVal hObject As Integer) As Integer

End Class
天狼皓月 2005-09-16
  • 打赏
  • 举报
回复
高手太厉害了 你没当版主 真是 CSDN的失败。小弟不才在这么好的例子上,怎么也没加到图片上,请问这是怎么回事呢。是不是Graphics的句柄不能用呢?

就象以这种方式来往图片上写东西的时候

Dim bitmap As Bitmap
Dim g As Graphics
bitmap = bitmap.FromFile(".\countryStandard.jpg")
g = Graphics.FromImage(bitmap)
g.DrawString(s_bus_NextName.Chars(0), New Font("汉仪长美黑简", 140), Brushes.Red, 800 + 113, 825)

逻辑字体 改用那一个句柄呢?请高手给最后指导一下。
pupo 2005-09-16
  • 打赏
  • 举报
回复
Dim lf As Win32.LOGFONT
Dim hDC As IntPtr
With lf
.lfHeight = 100 '字符高度
.lfWidth = 50 '字符宽度
.lfEscapement = 150 '文本倾斜度,逆时针方向为正,一圈总角度为3600
.lfOrientation = 0 '字符倾斜角度
.lfWeight = 0 '字体的轻重
.lfUnderline = 0 '是否加下划线
.lfStrikeOut = 0 '是否加删除线
.lfCharSet = 1 '指定字符集
.lfOutPrecision = 0 '输出、输入精度
.lfClipPrecision = 0 '剪辑精度
.lfQuality = 0 '设置输出质量
.lfPitchAndFamily = 0 '字间距
.lfFaceName = "宋体" '字体名称
End With
Dim hFont As Integer = Win32.CreateFontIndirect(lf)
hFont = Win32.CreateFontIndirect(lf)
Dim dc As IntPtr = Win32.GetDC(Me.Label1.Handle)
Win32.SelectObject(dc, hFont)
Win32.TextOut(dc, 0, 0, "OK", 2)
Win32.DeleteObject(hFont)


加多两个函数定义
Public Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal lpString As String, ByVal nCount As Integer) As Integer
Public Declare Function DeleteObject Lib "gdi32" Alias "DeleteObject" (ByVal hObject As Integer) As Integer


天狼皓月 2005-09-15
  • 打赏
  • 举报
回复
最终的程序是用这种方式,把逻辑字体写在图片上.
Dim bitmap As Bitmap
Dim g As Graphics
g.DrawString(s_bus_NextName.Chars(0), New Font("汉仪长美黑简", 140), Brushes.Red, 800 + 113, 825)
天狼皓月 2005-09-15
  • 打赏
  • 举报
回复
高手这样不行,这样输出的不是我们所定义的逻辑字体.他没有按我们的要求输出,我可以设置高200 宽50 但是他输出的还是原来的比例,加上输出角度也不管用.我觉得不是用 Label1.Font.FontFamily 可以呢 但是他是只读属性的 重载还出错. 如果要是用 Label1.Font = Font.FromHdc(New IntPtr(hFont))的话就异常说"只支持 TrueType 字体,而这不是 TrueType 字体".这是怎么回事呢 是label这个控件不支持?还是其他的控件都不支持呢?麻烦你给指导一下
pupo 2005-09-15
  • 打赏
  • 举报
回复
设置字体不一样要用SelectObject,直接修改控件的Font属性就可以了
Dim hFont As Integer = Win32.CreateFontIndirect(lf)
hFont = Win32.CreateFontIndirect(lf)
Label1.Font = Font.FromHfont(New IntPtr(hFont))
Label1.Text = "OK"
pupo 2005-09-14
  • 打赏
  • 举报
回复
你的CreateFontIndirectA 函数定义错了
pupo 2005-09-14
  • 打赏
  • 举报
回复
Public Class Win32

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Public Structure LOGFONT
Public lfHeight As Integer
Public lfWidth As Integer
Public lfEscapement As Integer
Public lfOrientation As Integer
Public lfWeight As Integer
Public lfItalic As Byte
Public lfUnderline As Byte
Public lfStrikeOut As Byte
Public lfCharSet As Byte
Public lfOutPrecision As Byte
Public lfClipPrecision As Byte
Public lfQuality As Byte
Public lfPitchAndFamily As Byte
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public lfFaceName As String '我也不知道该定义为什么类型
End Structure

Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (ByRef lpLogFont As LOGFONT) As Integer
Public Declare Function SelectObject Lib "gdi32.dll" Alias "SelectObject" (ByVal hdc As Integer, ByVal hObject As Integer) As Integer

End Class


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lf As Win32.LOGFONT
With lf
.lfHeight = 100 '字符高度
.lfWidth = 50 '字符宽度
.lfEscapement = 0 '文本倾斜度,逆时针方向为正,一圈总角度为3600
.lfOrientation = 0 '字符倾斜角度
.lfWeight = 0 '字体的轻重
.lfUnderline = 0 '是否加下划线
.lfStrikeOut = 0 '是否加删除线
.lfCharSet = 1 '指定字符集
.lfOutPrecision = 0 '输出、输入精度
.lfClipPrecision = 0 '剪辑精度
.lfQuality = 0 '设置输出质量
.lfPitchAndFamily = 0 '字间距
.lfFaceName = "宋体" '字体名称
End With
MsgBox(Win32.CreateFontIndirect(lf))
End Sub
天狼皓月 2005-09-14
  • 打赏
  • 举报
回复
不过 在vb.net里的 SelectObject 和 Delphi 差别太大了。我怎么调用不成功呢 ,高手帮我看看哪里写错了。

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("华文中宋", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.Location = New System.Drawing.Point(32, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(128, 48)
Me.Label1.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(32, 96)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(304, 213)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim lf As Win32.LOGFONT
Dim hFont, newFont As Integer
Dim hDC As IntPtr

With lf
.lfHeight = 500 '字符高度
.lfWidth = 50 '字符宽度
.lfEscapement = 0 '文本倾斜度,逆时针方向为正,一圈总角度为3600
.lfOrientation = 0 '字符倾斜角度
.lfWeight = 0 '字体的轻重
.lfUnderline = 0 '是否加下划线
.lfStrikeOut = 0 '是否加删除线
.lfCharSet = 1 '指定字符集
.lfOutPrecision = 0 '输出、输入精度
.lfClipPrecision = 0 '剪辑精度
.lfQuality = 0 '设置输出质量
.lfPitchAndFamily = 0 '字间距
.lfFaceName = "宋体" '字体名称
End With
hDC = Win32.GetDC(Label1.Handle)
hFont = Win32.CreateFontIndirect(lf)
Win32.SelectObject(hDC, hFont)
Label1.Text = "OK"
End Sub


End Class
Public Class Win32

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Public Structure LOGFONT
Public lfHeight As Integer
Public lfWidth As Integer
Public lfEscapement As Integer
Public lfOrientation As Integer
Public lfWeight As Integer
Public lfItalic As Byte
Public lfUnderline As Byte
Public lfStrikeOut As Byte
Public lfCharSet As Byte
Public lfOutPrecision As Byte
Public lfClipPrecision As Byte
Public lfQuality As Byte
Public lfPitchAndFamily As Byte
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public lfFaceName As String
End Structure

Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (ByRef lpLogFont As LOGFONT) As Integer
Public Declare Function SelectObject Lib "gdi32.dll" Alias "SelectObject" (ByVal hdc As IntPtr, ByVal hObject As Integer) As Integer
Public Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As IntPtr) As IntPtr
End Class


天狼皓月 2005-09-14
  • 打赏
  • 举报
回复
高手就是高手太厉害了,完了我把我剩余分都给你。
天狼皓月 2005-09-13
  • 打赏
  • 举报
回复
我找一个例子 但是只是关键代码又一个地方报错没法运行 有几个地方看不大懂 望高手给看一下

<StructLayout(LayoutKind.Sequential, CharSet := CharSet.Auto)> _
Public Structure LOGFONT _
Public lfHeight As Integer _
Public lfWidth As Integer _
Public lfEscapement As Integer _
Public lfOrientation As Integer _
Public lfWeight As Integer _
Public lfItalic As Byte _
Public lfUnderline As Byte _
Public lfStrikeOut As Byte _
Public lfCharSet As Byte _
Public lfOutPrecision As Byte _
Public lfClipPrecision As Byte _
Public lfQuality As Byte _
Public lfPitchAndFamily As Byte _
<MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)> _ '就这不行说SizeConst没定义
Public lfFaceName As String_ '我也不知道该定义为什么类型
End Structure
Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" ( _
<MarshalAs(Unmanaged.LPStruc)> byval lpLogFont As LOGFONT) As Integers
dim lf as LOGFONT '在声明API的时候还用了 MarshalAs 属性 我也没看懂
dim hfont as intptr = createfontindirect(lf)


希望高手告诉我那个SizeConst该定义为什么类型, 好像在结构体里面也不用加换行继续符是吗?
天狼皓月 2005-09-13
  • 打赏
  • 举报
回复
而且 在vb.net 里 声明为结构体的数组成员不能用初始大小声明 Public lfFaceName(1 To LF_FACESIZE) As Byte 会报错. 谢谢大家 希望高手继续指导
天狼皓月 2005-09-13
  • 打赏
  • 举报
回复
不行阿 改了也是这个异常 在你的机器上可以运行吗? 异常(其他信息: 未将对象引用设置到对象的实例)
pupo 2005-09-13
  • 打赏
  • 举报
回复
Public Declare Function CreateFontIndirectA Lib "gdi32" (ByVal lpLogFont As LOGFONT) As Integer
Public Declare Function SelectObject Lib "gdi32.dll" Alias "SelectObject" (ByVal hdc As Integer, ByVal hObject As Integer) As Integer
pupo 2005-09-13
  • 打赏
  • 举报
回复
<StructLayout(LayoutKind.Sequential)>
Public Structure LOGFONT
Public lfHeight As Integer
Public lfWidth As Integer
Public lfEscapement As Integer
Public lfOrientation As Integer
Public lfWeight As Integer
Public lfItalic As Byte
Public lfUnderline As Byte
Public lfStrikeOut As Byte
Public lfCharSet As Byte
Public lfOutPrecision As Byte
Public lfClipPrecision As Byte
Public lfQuality As Byte
Public lfPitchAndFamily As Byte
Public lfFaceName(1 To LF_FACESIZE) As Byte
End Structure

在.net中Long要换成integer型

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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