Article View: borland.public.cppbuilder.nativeapi
Article #9181Reading pxl from another application - Not Working!
From: Henry
Date: Thu, 22 Jul 2004 07:48
Date: Thu, 22 Jul 2004 07:48
88 lines
3626 bytes
3626 bytes
Thanks for the answer. I developed the following code that copies a portion
of the target application form to an image within my test application:
// ---------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{ RECT MyRect;
HDC dc;
Graphics::TCanvas *ScreenCanvas;
// Edit1->Text contains the handler of the target application
Target_Hwnd = (HWND)StrToInt(Edit1->Text);
if (!IsWindow(Target_Hwnd))
Target_Hwnd = 0;
ScreenCanvas = new Graphics::TCanvas();
dc = GetDC(Target_Hwnd);
ScreenCanvas->Handle = dc;
MyRect = Rect(0, 0, 200, 200);
Image1->Canvas->CopyRect(MyRect, ScreenCanvas, MyRect);
delete ScreenCanvas;
ReleaseDC(Target_Hwnd, dc);
}
// ---------------------------------------------------------------
My test program works correctly only when the target application is normally
visible; if the target form is covered by another window, my program copies
a portion of that windows (not a portion of the target application form). Is
there something wrong with my code ? (By the way: I am using Windows XP Pro,
and BCB 6).
Thanks again for help.
Henry
"Henry" <eangelo@libero.it> ha scritto nel messaggio
news:40fd37c8@newsgroups.borland.com...
> Hi to all!
>
> I am working on a supervisor program that waits for an area within another
> application to become red. As a first solution I tried the following code:
>
> HDC dc;
> Graphics::TCanvas ScreenCanvas;
>
> ScreenCanvas = new Graphics::TCanvas();
> dc = GetDC(NULL);
> ScreenCanvas->Handle = dc;
>
> If (ScreenCanvas->Pixels[_DNS_Mike_St_X_Coord_][_DNS_Mike_St_Y_Coord_] ==
> clRed)
>
> which worked correctly. My problem is: what if the target windows is
covered
> by another windows or it is minimized ? Is there an API to be used to
> directly read pixel from another application? Can anybody provide me with
a
> piece of code ?
> Thank un advance.
>
> Henry - Italy
----- Original Message -----
From: "Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Sent: Tuesday, July 20, 2004 7:35 PM
Subject: Re: Reading pixel from another application
>
> "Henry" <eangelo@libero.it> wrote in message
> news:40fd37c8@newsgroups.borland.com...
>
> > which worked correctly. My problem is: what if the target
> > windows is covered by another windows or it is minimized ?
>
> Specify an actual window handle when calling GetDC() instead of getting
the
> screen's DC. The screen DC only contains the pixels that are actually
> visible onscreen, whereas a window DC contains all of the pixels for a
> particular window regardless of what's on top of it..
>
>
> Gambit
>
>
Technical Details
Message-ID:
<40ff7145@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,edce39f81cd44cc9,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Henry" <eangelo@libero.it> From: "Henry" <eangelo@libero.it> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Reading pxl from another application - Not Working! Date: Thu, 22 Jul 2004 09:48:20 +0200 Lines: 90 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 151.30.192.225 Message-ID: <40ff7145@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1090482501 151.30.192.225 (22 Jul 2004 00:48:21 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail