WM_PAINT question...

  • Thread starter Thread starter Kevin Dombroski
  • Start date Start date
K

Kevin Dombroski

Howdy - I would like my application to be able to read data from another
application. Specifically, I would like my to get the text from the "client
area" of another application's window whenever it's processing a WM_PAINT
message? Can I do that? I've been searching around MSDN and Google, but I'm
not really finding a way to do this. Please let me know if you have an
idea - thanks!
 
Not easily.
You might be able to forge a WM_PAINT and send that to the applicaiton,
providing a device context that you have initiated the recording of metadata
on, but that's only a theory and probably won't work in practice because of
calls to BeginPaint etc.

Other than using OCR I think you might be out of luck.

If you just want to do it occasionally, you could just get the application
to print the stuff, and have it print to a postscript printer (print to
file), then you could probably pull the data out of the file.

Hope that helps a little.
John
 
Kevin

If you know the HWND of the control in the other process, you can use the
SendMessage API call, with WM_GETTEXT.

regards
roy fine
 
Thanks for the reply... How about this off the wall theory: since the text
is being painted, can I obtain a bitmap of the client area (it's small, if
that helps my cause). I'm sure that's doable - now all I need is a
"ToString()" method for the bitmap object??? I'm sure I'm really reaching.
Not sure if this method exists for a Bitmap object!?!?!
 
Hi Kevin,

Yes, ToString exists for bitmap objects as it exisits for all objects
because it is defined in the Object class. You can call it and you will get
a string which contains the name of the class. Something like
"System.Drawing.Bitmap". Thing of it. As the name suggests it is only an
area of pixels, which has some color. There are not strings, rectangles,
lines or whatsoever. There are only pixels. That's why if you want to
extract the text from a picture you have to use some algorithm for image
recognition (OCR). Such algorithms are fairly complex and are definitely
not somethig, which can be implemented "first thing in the morning". With
meta files (as the others suggested) is kind of different. The metafiles are
list of gdi (or gdi+) commands which are executed (played) over some device
context. As such they can be enumerated and all the commands inside can be
regognized and parsed. So with some degree probability TextOut commands can
be catched and the arguments (the text) could be extracted. Again there are
some problems of letting the controls to paint into an arbitrary device
context. It can be done via WM_PRINT and WM_PRINTCLIENT if implemented by
the target control, which usually is not for controls different than the one
provided by micorosoft.
 
Back
Top