M
MyAlias
Can't solve this CallBack returning structures
Error message:
An unhandled exception of type 'System.NullReferenceException'
occurred in MyTest.exe
Additional information: Object reference not set to an instance of an
object.
Situation skeleton:
Private Declare Function EnumFontFamiliesASCII Lib "gdi32" Alias
"EnumFontFamiliesA" (ByVal hdc As Integer, ByVal lpszFamily As Integer,
ByVal lpEnumFontFamProc As effp, ByVal lParam As Integer) As Integer
Delegate Function effp(ByRef lpNLF As LOGFONT, ByRef lpNTM As
NEWTEXTMETRIC, ByVal FontType As Integer, ByRef lParam As Integer) As
Integer
Private Function EnumFontFamProc(ByRef lpNLF As LOGFONT, ByRef lpNTM
As NEWTEXTMETRIC, ByVal FontType As Integer, ByRef lParam As Integer) As
Integer
' MyNonRelatedCode here
return 1
End Function
Public Function EnumFontFamilies() As String()
Dim shdc As Integer = GetDC(0)
-> EnumFontFamiliesASCII(shdc, 0, AddressOf EnumFontFamProc, 0)
Call ReleaseDC(0, shdc)
End Function
The error occurs at line signaled by '->'
Error cause from the top level view:
The windows does not care about the NET framework, it does not notify
that the structures lpNLF and lpNTM where initialized
Why do I say that?:
Because there is no error when replacing in effp and EnumFontFamProc
ByRef lpNLF As LOGFONT, ByRef lpNTM As NEWTEXTMETRIC
by
ByVal lpNLF As Integer, ByVal lpNTM As Integer
What is the Attribute to use or any other workarround if available?
Thanks for taking you time
Error message:
An unhandled exception of type 'System.NullReferenceException'
occurred in MyTest.exe
Additional information: Object reference not set to an instance of an
object.
Situation skeleton:
Private Declare Function EnumFontFamiliesASCII Lib "gdi32" Alias
"EnumFontFamiliesA" (ByVal hdc As Integer, ByVal lpszFamily As Integer,
ByVal lpEnumFontFamProc As effp, ByVal lParam As Integer) As Integer
Delegate Function effp(ByRef lpNLF As LOGFONT, ByRef lpNTM As
NEWTEXTMETRIC, ByVal FontType As Integer, ByRef lParam As Integer) As
Integer
Private Function EnumFontFamProc(ByRef lpNLF As LOGFONT, ByRef lpNTM
As NEWTEXTMETRIC, ByVal FontType As Integer, ByRef lParam As Integer) As
Integer
' MyNonRelatedCode here
return 1
End Function
Public Function EnumFontFamilies() As String()
Dim shdc As Integer = GetDC(0)
-> EnumFontFamiliesASCII(shdc, 0, AddressOf EnumFontFamProc, 0)
Call ReleaseDC(0, shdc)
End Function
The error occurs at line signaled by '->'
Error cause from the top level view:
The windows does not care about the NET framework, it does not notify
that the structures lpNLF and lpNTM where initialized
Why do I say that?:
Because there is no error when replacing in effp and EnumFontFamProc
ByRef lpNLF As LOGFONT, ByRef lpNTM As NEWTEXTMETRIC
by
ByVal lpNLF As Integer, ByVal lpNTM As Integer
What is the Attribute to use or any other workarround if available?
Thanks for taking you time