Re: POLYTEXTOUT problems..( including declarations )
- From: "Dan Hinrichs" <noreply@xxxxxxxxxxxx>
- Date: Tue, 4 Oct 2005 10:42:47 -0800
Hi J and Mike... thanks for replying...
So, if I am beginning to understand this correctly, it is OK for me to change
the declaration to fix this up?
ie: Change the declare from:
pptxt as POLYTEXT
to:
pptxt as Long
Is this correct?
When I was attempting to make this work, I tried using VarPtr(), but the compiler chucked it because the data type was incorrect
(struct vs. long)
I had thought that the declarations were Holy Scriptures, and that they could not be changed under any circumstances....
But now, if I am to understand this correctly, I can change the declaration to meet my requirements of sending different pointers?
Thanks a bunch,
Dan
(ORIGINAL CODE AT THE END OF THIS MESSAGE, FOR THOSE FOLLOWING ALONG)
"J French" <erewhon@xxxxxxxxxx> wrote in message news:434262ab.186362497@xxxxxxxxxxxxxxxxxxxxxxx
> On Tue, 4 Oct 2005 11:32:46 +0100, "Mike Williams"
> <Mike@xxxxxxxxxxxxxxxxx> wrote:
>
> >"Mike Williams" <Mike@xxxxxxxxxxxxxxxxx> wrote in message
> >news:dhtlfn$bcg$1@xxxxxxxxxxxxxxxxxxxxxxx
> >
> >. . . oops! I forgot to mention that in order to get the code working I had
> >to change the declaration to:
> >
> >Private Declare Function PolyTextOut& _
> > Lib "gdi32" Alias "PolyTextOutA" ( _
> > ByVal hdc As Long, _
> > pptxt As Rum, _
> > ByVal cStrings As Long)
> >
> >Having to do such a thing tells me for sure that I am going about all this
> >in a silly roundabout way, and that there is a far easier way of doing it,
> >but I haven't had my breakfast yet (slept in late today!). Never much good
> >before breakfast! (Probably simply changing your existing dynamic array for
> >a fixed size one will do the trick). Anyway, as I've said, there has got to
> >be a better way of doing this, but at least the example I posted shows that
> >the thing actually works ;-)
>
> Of course !
>
> You've spotted the problem, because the UDT contains Strings the UDT
> has to do a Unicode -> ANSI dance on the way down to the API
>
> Because the OP is just sending UDT(0) VB makes a converted copy of
> UDT(0) which is /not/ followed by UDT(1)
>
> By wrapping the lot in a UDT you are forcing conversion of a
> contiguous chunk of UDTs
>
> The other alternative is to send VarPtr( UDT(0) ) which sends the
> original memory, not a copy, but the problem with that is the Strings
> will still be in UniCrud
>
> However a quick check at MSDN reveals:
>
> Requirements
> Windows NT/2000/XP: Included in Windows NT 3.1 and later.
> Windows 95/98/Me: Unsupported.
> Header: Declared in Wingdi.h; include Windows.h.
> Library: Use Gdi32.lib.
> Unicode: Implemented as Unicode and ANSI versions.
>
> Which means changing "PolyTextOutA" to "PolyTextOutW" should sort
> out the problem, so VarPtr( UDT(0) ) is probably the way to go.
>
>
Original code:
'DECLARATIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
Private Type POLYTEXT
x As Long
y As Long
n As Long
lpStr As String
uiFlags As Long
rcl As RECT
pdx As Long
End Type
Private Declare Function PolyTextOut& _
Lib "gdi32" Alias "PolyTextOutA" ( _
ByVal hdc As Long, _
pptxt As POLYTEXT, _
ByVal cStrings As Long)
'THIS WORKS:~~ (using a single struct)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
Dim PT as POLYTEXT
Dim sBuf as String
Dim res as Long
sBuf$ = "My string"
PT.n = Len(sBuf$)
PT.lpStr = sBuf$
res& = PolyTextOut(My.hDC, PT, 1) 'this works..!!
'THIS DOES NOT WORK:~~ (uses an array in the call)~~~~~~~~~~~~~~~~~~~~~`
Dim aPT() as POLYTEXT
Dim sBuf1 as String
Dim sBuf2 as String
sBuf1$ = "String 1"
sBuf2$ = "String 2"
Redim aPT(0 to 1)
aPT(0).n = Len(sBuf1$)
aPT(0).lpStr = sBuf1$
aPT(1).n = Len(sBuf2$)
aPT(1).lpStr = sBuf2$
res& = PolyTextOut(My.hDC, aPT(0), 2) 'THIS HAS PROBLEMS..
.
- Follow-Ups:
- Re: POLYTEXTOUT problems..( including declarations )
- From: Mike Williams
- Re: POLYTEXTOUT problems..( including declarations )
- References:
- POLYTEXTOUT problems..
- From: Dan Hinrichs
- POLYTEXTOUT problems..( including declarations )
- From: Dan Hinrichs
- Re: POLYTEXTOUT problems..( including declarations )
- From: Mike Williams
- Re: POLYTEXTOUT problems..( including declarations )
- From: Mike Williams
- Re: POLYTEXTOUT problems..( including declarations )
- From: J French
- POLYTEXTOUT problems..
- Prev by Date: ActiveX component can't create object or return reference to this object (Error 429)
- Next by Date: Word Macro Help
- Previous by thread: Re: POLYTEXTOUT problems..( including declarations )
- Next by thread: Re: POLYTEXTOUT problems..( including declarations )
- Index(es):
Relevant Pages
|