Re: GetDC() overlapping window problem
- From: "Chris Becke" <chris.becke@xxxxxxxxx>
- Date: Thu, 26 Jul 2007 16:38:19 +0200
"Michael S" <Michael S@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:39671E50-41AC-46F6-BD9E-A3D94ECFD44F@xxxxxxxxxxxxxxxx
I need to read a pixel from a window. Because PrintWindow() is too slow I
use
GetDC(). However when using GetDC() the window needs to be visible. If the
window, or a pixel on the window, is not visisble the value written in the
pixel is 0xFFFFFFFF, so you can detect when something is blocking your
pixel.
When the pixel is blocked I call the SetForGroundWindow() function to get
the
window on top and read the pixel again. In most cases this works fine.
However it does not always work. After calling the SetForGroundWindow
function it takes some time for the window to be on top, if I call the
GetDC
/ GetPixel function to fast I will not read the correct pixel / blocked
pixel
but the value of the pixel that is blocking the correct pixel. In this way
I
can not know if I read the correct pixel or. Does any one have any idea
how
to solve it? Using PrintWindow is not an option.
First, SetForgroundWindow only works if executed from a thread that is
currently the forground thread. So, the first time you do this trick, youre
toast.
Next, SetForgroundWindow makes the remote thread the forground thread, and
tries to activate the window. Activating the window involves processing
multiple window messages. The remote application might be in some modal
loop, or might just reject the activation out-of-hand. It might be covered
by an owned popup window, it might be covered by a WS_EX_TOPMOST window, the
pixel youre interested in might be off screen. I presume your app is meant
to be running unattended, because the user clicking around might just
interrupt the whole process.
If there is a user involved, or the other applications position and
activation hasnt been under your apps control from the very beginning then
you are NOT going to succeed unless you use PrintWindow / WM_PRINT /
WM_PRINTCLIENT or some other means to ask the other window to synchronously
generate the pixel in question for you.
.
- Prev by Date: Re: Win32 HDC gone crazy
- Next by Date: Re: Creating a window on second display from second graphics card
- Previous by thread: Re: Win32 HDC gone crazy
- Next by thread: SetRop2 R2_XORPEN on PostScript printer
- Index(es):
Relevant Pages
|