BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get GetPixel return values in a memo

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Alawna
Guest





PostPosted: Thu Mar 24, 2005 5:21 pm    Post subject: How to get GetPixel return values in a memo Reply with quote



Hi here is my code

PROCEDURE TForm1.Button2Click(Sender: TObject);
VAR
hdc1: integer;
khara:Tcolor;
BEGIN
hdc1 := GetDC(RichHwnd);
khara:=getpixel(hdc1,500,250);
memo1.Lines.Append(inttostr(khara));
END;

the handle is tested with other functions and is ok.
The value in the memo is -1 whatever the x and y are. It just does not
change.
I know inttostr(khara) is not true. But now looking for a way to get the
RGB returned by the getpixel into the memo

thanks
Back to top
Peter Below (TeamB)
Guest





PostPosted: Fri Mar 25, 2005 10:16 am    Post subject: Re: How to get GetPixel return values in a memo Reply with quote



In article <4242f719 (AT) newsgroups (DOT) borland.com>, Alawna wrote:
Quote:
PROCEDURE TForm1.Button2Click(Sender: TObject);
VAR
hdc1: integer;
khara:Tcolor;
BEGIN
hdc1 := GetDC(RichHwnd);
khara:=getpixel(hdc1,500,250);
memo1.Lines.Append(inttostr(khara));
END;

the handle is tested with other functions and is ok.
The value in the memo is -1 whatever the x and y are. It just does not
change.

GetPixel is documented to return -1 (CLR_INVALID) when the passed
coordinates are outside the current clipping region of the device context.
Which also means, by the way, that the part of the control you try to get
the color from has to be visible on screen. Is that the case for you? If
yes you can try to use GetDC(0) to obtain a hDC for the screen itself,
convert your coordinates to screen coordinates using the controls
ClientToScreen method, and apply GetPixel to the screen DC.

Your code contains a severe error, by the way: every DC you get via GetDC
*must* be returned to the system via ReleaseDC when you no longer need it.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.