The full list of the
WIN32API functions I need to reference in .NET is this: CreateSolidBrush,
ScrollDC, FillRect, DrawText, InvalidateRect, DrawEdge, GetSysColorBrush,
InvertRect, GetSysColor, FrameRect, SelectObject, and
DeleteObject.
I found some MSDN
articles that explained how to get RichTextBoxes to print their contents in
.NET, and tried to use those as a template for my changes. I am currently
attempting to just get 2 from the above list working, DrawText and FillRect (and
hopefully once I get those two working I'll understand it well enough to do the
others.)
Here are the VB6
declarations of the two:
Public Declare
Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hbrush
As Long) As Long
Public Declare Function DrawText Lib "user32" Alias
"DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long,
lpRect As RECT, ByVal wFormat As Long) As Long
Here is what I am
trying to use in .NET:
<DllImport("User32.dll",
EntryPoint:="FillRect", SetLastError:=True,
CharSet:=CharSet.Unicode, _
Exactspelling:=True,
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function FillRect(ByVal hDC
As IntPtr, ByRef lpRect
As STRUCT_RECT, ByVal
hbrush As Int32) As
Int32
End Function
<DllImport("user32.dll",
entrypoint:="DrawTextA", SetLastError:=True,
CharSet:=CharSet.Unicode, _
exactspelling:=True,
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function DrawText(ByVal hDC
As IntPtr, ByVal lpStr
As String, ByVal nCount As Int32, ByRef lpRect
As STRUCT_RECT, _
ByVal wFormat As Int32) As
Int32
End Function
Here is
STRUCT_RECT:
<StructLayout(LayoutKind.Sequential)>
_
Public Structure
STRUCT_RECT
Public left
As
Int32
Public top
As
Int32
Public right
As
Int32
Public bottom
As
Int32
End Structure
Currently neither one
of them is working, and they both return zero. Anything that jumps out at you
that I am going wrong?