Drawing Text 
Author Message
 Drawing Text

OK this is what I need to do, I need to be able to draw text on a given
program at a given location with a transparent background.  I've tried
DrawText and TextOut API's, I've even tried making a transparent form and
label and just placing it in front of the other window.  Nothing seems to
work correctly.  The two API commands, if you move a window over the text it
has drawn, then move it out of the way, the text is gone.  What I'm trying
to draw the text on is a bitmap, is there any way to modify the bitmap so it
has the text on it?  Maybe I'm approaching this the wrong way all
together...  Any help or guidance would be greatly appreciated...

Thanks,



Sun, 18 Mar 2001 03:00:00 GMT  
 Drawing Text
Two ways to get the text to stay:

1) Set the AutoRedraw property = True for the form or picturebox you're
displaying the bitmap & text on.

2) Put the code to draw the text in the form or picturebox _Paint()
routine.

Jim Deutch
MS Dev MVP



Quote:
> OK this is what I need to do, I need to be able to draw text on a given
> program at a given location with a transparent background.  I've tried
> DrawText and TextOut API's, I've even tried making a transparent form and
> label and just placing it in front of the other window.  Nothing seems to
> work correctly.  The two API commands, if you move a window over the text
it
> has drawn, then move it out of the way, the text is gone.  What I'm
trying
> to draw the text on is a bitmap, is there any way to modify the bitmap so
it
> has the text on it?  Maybe I'm approaching this the wrong way all
> together...  Any help or guidance would be greatly appreciated...

> Thanks,




Mon, 19 Mar 2001 03:00:00 GMT  
 Drawing Text
That's the 3rd response I've gotten that said the exactly the same thing.
=)  I appreciate your help, but I guess I didn't explaine myself very well.
The picturebox is outside my program, it is a picture on a program written
in a different programming language.  And I need to use VB to put the text
on that picture box.  In other words, I can't change the AutoRedraw
property.  I've used DrawText and TextOut API's but I don't know how to get
the background transparent...

Thanks anyway!
Jeremy...


Quote:
>Two ways to get the text to stay:

>1) Set the AutoRedraw property = True for the form or picturebox you're
>displaying the bitmap & text on.

>2) Put the code to draw the text in the form or picturebox _Paint()
>routine.

>Jim Deutch
>MS Dev MVP



Mon, 19 Mar 2001 03:00:00 GMT  
 Drawing Text
Try setting autoredraw to true
Alex E

Quote:

>OK this is what I need to do, I need to be able to draw text on a given
>program at a given location with a transparent background.  I've tried
>DrawText and TextOut API's, I've even tried making a transparent form and
>label and just placing it in front of the other window.  Nothing seems to
>work correctly.  The two API commands, if you move a window over the text
it
>has drawn, then move it out of the way, the text is gone.  What I'm trying
>to draw the text on is a bitmap, is there any way to modify the bitmap so
it
>has the text on it?  Maybe I'm approaching this the wrong way all
>together...  Any help or guidance would be greatly appreciated...

>Thanks,




Mon, 19 Mar 2001 03:00:00 GMT  
 Drawing Text

Quote:
>That's the 3rd response I've gotten that said the exactly the same thing.
>=)  I appreciate your help, but I guess I didn't explaine myself very well.
>The picturebox is outside my program, it is a picture on a program written
>in a different programming language.

The reason you were misunderstood is that a "picturebox" is a Visual Basic
control.  You actually want to draw text on another program's window, right?

Quote:
>I've used DrawText and TextOut API's but I don't know how to get
>the background transparent...

The transparent background part should be easy.  You need to call
SetBkMode()

Dim oldBkMode as Long

oldBkMode = SetBkMode( hdc, TRANSPARENT )

Then call your text APIs.  You should restore the old BkMode when you are
finished.  The declares for SetBkMode() should be in the API viewer as well
as the TRANSPARENT constant.

However, you will still have the persistence problem unless you subclass the
window and redraw the text everytime the window receives a WM_PAINT message.
This is not a safe or easy thing to do across processes.

HTH,

Ray Mercer
http://i.am/shrinkwrapvb



Tue, 20 Mar 2001 03:00:00 GMT  
 Drawing Text

[...]
:However, you will still have the persistence problem unless you subclass
the
:window and redraw the text everytime the window receives a WM_PAINT
message.
:This is not a safe or easy thing to do across processes.

There is a way to subclass across process boundaries. However, you can do it
only in NT :)

You need to create a DLL which "injects" your window procedure into the
process which you want to subclass. It's too hard to explain here, but
basically:

(1) Call CreateRemoteThread() to create a thread in the target process.
(2) Suspend the created thread (using SuspendThread()).
(3) Use VirtualAllocEx() to create space for the window procedure.
(4) Call WriteProcessMemory() to set the thread's starting address to be the
address of the window procedure.
(5) Resume the thread (using ResumeThread()).

Jeffrey Richter describes how to do so in Chapter 18 of Advanced Windows
(3rd edition, MS Press). His code injects a DLL into Explorer to perform
resolution switching (a la NT Powertoys).
--
Damit Senanayake
Microsoft MVP - Visual Basic
ICQ#: 6930718



Tue, 20 Mar 2001 03:00:00 GMT  
 Drawing Text

Quote:

>There is a way to subclass across process boundaries. However, you can do
it
>only in NT :)

>You need to create a DLL which "injects" your window procedure into the
>process which you want to subclass. It's too hard to explain here, but

[...]

Damit, why don't you actually implement an idea like this as a useful DLL
with tested examples?  Then you could put it on your web page <?> and share
it.  Otherwise it's less than useless.  I have the first edition Advanced
Windows and I've read chapter 16 and looked at the InjectLib function too,
but that doesn't help anybody here, so I don't mention it.

BTW, you can buy a cross-process subclasser at www.desaware.com , but I
would be the first to DL yours if you can come up with one ;-)

Ray Mercer



Tue, 20 Mar 2001 03:00:00 GMT  
 Drawing Text
Ray,

Quote:
>Damit, why don't you actually implement an idea like this as a useful DLL
>with tested examples?  Then you could put it on your web page <?> and share
>it.  [...]

You can (now) download it from my web site at http://members.xoom.com/damit/
under the Components section. Note that there are no samples and no
documentation yet. I just finished writing this DLL at around 3 a.m. this
morning :) The filename is SubCls.dll.

Quote:
>BTW, you can buy a cross-process subclasser at www.desaware.com , but I
>would be the first to DL yours if you can come up with one ;-)

Mine works only on NT4 or higher, for now. I'm trying to think of how to
come up with a Win9x solution.

--
Damit Senanayake
ICQ #: 6930718
Microsoft MVP - Visual Basic



Thu, 22 Mar 2001 03:00:00 GMT  
 Drawing Text
Hi Damit,

Why does your Website not support IE3.x? At least put some useable links on
it!!!!

Later.....

David S.



Quote:
> Ray,


> >Damit, why don't you actually implement an idea like this as a useful
DLL
> >with tested examples?  Then you could put it on your web page <?> and
share
> >it.  [...]

> You can (now) download it from my web site at

http://members.xoom.com/damit/
Quote:
> under the Components section. Note that there are no samples and no
> documentation yet. I just finished writing this DLL at around 3 a.m. this
> morning :) The filename is SubCls.dll.

> >BTW, you can buy a cross-process subclasser at www.desaware.com , but I
> >would be the first to DL yours if you can come up with one ;-)

> Mine works only on NT4 or higher, for now. I'm trying to think of how to
> come up with a Win9x solution.

> --
> Damit Senanayake
> ICQ #: 6930718
> Microsoft MVP - Visual Basic



Sat, 24 Mar 2001 03:00:00 GMT  
 Drawing Text
David,

:Why does your Website not support IE3.x? At least put some useable links on
:it!!!!

I've just updated it to support other browsers (IE3, Netscape, Opera). Take
a look and see if the auto-redirect gets you. If it doesn't, just open this
URL: http://members.xoom.com/damit/other/

--
Damit Senanayake
Microsoft MVP - Visual Basic
ICQ#: 6930718
http://members.xoom.com/damit/



Sun, 25 Mar 2001 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Adding text to Drawing Text box via VBA

2. Draw Text on an angle

3. drawing text and true type

4. drawing text in bitmaps

5. How to draw text to the screen?

6. Draw Text..Hmm

7. Drawing text on PictureBox

8. draw text in image?

9. resize and draw text in picturebox

10. resize and draw text in picturebox, need help!

11. Drawing Text in a PictureBox Control

12. Drawing text in a picture box

 

 
Powered by phpBB® Forum Software