Re: GetDC() overlapping window problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"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.


.



Relevant Pages

  • Re: Algorithm for "Windows Center" and "Windows Width"
    ... a typo in my example: window width should be 300 and window center 40. ... For 16 bit pixel values, you have a potential range of 65536 values but you have only a display range of 256 values, so some manipulation must be done. ... Finally the resultang y,How can i use this y to adjust W/l? ... identity (no rescale values or Modality LUT, ...
    (comp.protocols.dicom)
  • Re: capture screen even when workstation is locked
    ... /// Number of adjacent color bits for each pixel. ... PHYSICALWIDTH = 110, ... paper has a physical height value of 6600 device units. ... /// Only the client area of the window is copied. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Double hires mode color artifacts
    ... because areas with the same pattern ... pixel on host pixel boundaries. ... A filter of 4 bit width in hires (which ... to actually employ the wider window, nor do I have a convincing case ...
    (comp.sys.apple2)
  • Re: Algorithm for "Windows Center" and "Windows Width"
    ... y represents the output display level. ... For 16 bit pixel values, you have a potential range of 65536 values but you have only a display range of 256 values, so some manipulation must be done. ... As an extra challenge for you, I think you will find that performing this calculation for every pixel everytime the user changes the window settings will make your application run very slowly. ... identity (no rescale values or Modality LUT, ...
    (comp.protocols.dicom)