Drawing a text on a picturebox using API

  • Thread starter Thread starter fantavir
  • Start date Start date
F

fantavir

Hi.
I'm developing an application for pocket PC using VB .NET.
I can draw polygons using this API:
Private Declare Function Polygon Lib "Coredll" (ByVal hdc As Integer,
ByVal lpPoint() As POINTAPI, ByVal nCount As Integer) As Integer

and calling

Polygon(hdc, Points, UBound(Points)+1)

Now I want to draw colored and rotated text.

In VB6 I can use SetTextColor, CreateFontIndirect, TextOut

I tried this declaration:

Private Declare Function ExtTextOut Lib "Coredll" Alias "ExtTextOutA"
(ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, ByVal
wOptions As Integer, ByVal lpRect As System.IntPtr, ByVal lpString() As
Byte, ByVal nCount As Integer, ByVal lpDx As System.IntPtr) As Integer

or

Private Declare Function DrawText Lib "Coredll" Alias "DrawTextA"
(ByVal hdc As Integer, ByVal lpStr() As Byte, ByVal nCount As Integer,
ByVal lpRect As RECT, ByVal wFormat As Integer) As Integer

but it doesn't work (NotSupportedException).

What are the right declarations for SetTextColor, CreateFontIndirect,
TextOut?

Thanks.
Francesco.
 
OpenNETCF has the solution in the SDF (definitions in Core.cs IIRC), but I
have to ask why you're trying to do it through the APIs rather than through
managed methods. It's really rare you'd need to do this.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate
 
NotSupportedException is caused by ByVal lpRect As RECT - should be ByRef
(provided that you defined it as struct)
lpStr would be better declared as String
Also, forget about xxxA functions. Windows CE is a Unicode OS. Use either
xxxxW functions or omit the suffix completely - instead of ExtTextOutA
either ExtTextOutW or ExtTextOut
 
Thanks,
I solved my problem with this declaration.

Private Declare Function ExtTextOut Lib "Coredll" (ByVal hdc As
Integer, ByVal x As Integer, ByVal y As Integer, ByVal wOptions As
Integer, ByRef lpRect As RECT, ByVal lpString As String, ByVal nCount
As Integer, ByVal lpDx As Integer) As Integer

Where can I find a correct list of APIs for VB .NET under Windows CE?
Usually I find the declaration only in C or in VB6.

Thanks a lot,
Francesco.

PS: in this case I prefer to use API instead of managed method because
I have to translate VB6 code (that uses a lot of API) in VB .NET.

Alex Feinman [MVP] ha scritto:
 
There is no "central repository" for VB P/Invoke declarations, however if
you're going to be caliing them, you really need to learn to translate the
from C.

Chris
 
Back
Top