At 3:13 PM -0700 5/7/99, Gabe Dalbec wrote:
>The example given here is not my real code.  It does something similar, but
>don't worry about pointing out minor bugs in the code given here.  The
>point is that using FldGetTextPtr(fieldP) and then using string operations
>on the text pointer work, but using DmWrite on the same pointer does
>not work - unless I use FldGetTextHandle / MemHandleLock.

That should never be the case.  You might insert a debug line in the code
that verifies that the pointer you get from FldGetTextPtr is the same as
the pointer you get from FldGetTextHandle / MemHandleLock.  It should be...
so the DmWrite is just reading from the same memory either way!

Fields keep their handles locked while they are being edited, so the
MemHandleLock doesn't really change anything.  Unless the code you didn't
post is inserting text into the field or something -- in that case the
field could have resized the handle, which would invalidate the pointer you
got.

Anyway, if the pointers are not the same, then you should find out why...

>what you are saying about the handle not always being correct.  Maybe
>what I should do in my code is copy out of the pointer from FldGetTextPtr
>and then pass the copy of the string to the DmWrite call?

There's nothing in DmWrite that cares about the location of the source.  It
just reads the specified number of bytes.  If Poser is complaining, odds
are there's something else going on that should be fixed.

                                --Bob

P.S. Tsk, tsk on posting with faked up source code... that makes it
impossible to see what's really going on!  Maybe it's just a typo!


Reply via email to