Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to extract coordinates from a region Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
03-Oct-02
Category
Win API
Language
Delphi 2.x
Views
140
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Jonas Bilinkevicius

I am trying to do regioning backwards. I am writing an application that will read 
in a bitmap, allow the user to set a transparent colour, and then calculate the 
point set that would be needed to make that region transparent. I then want to 
supply the user with the coordinates as a set of coordinates, i.e. I want to 
extract it from a region format. Why? Because that's how Winamp takes the data in 
to make its custom shaped forms. But I can't seem to figure out how to pull the 
data out.

Answer:

One thing I found is that you must create a region prior to GetWindowRgn. I thought 
that one was created by default. I made a function that does what you need:

1   procedure TForm1.ShowRgnInfo(Rgn: HRGN);
2   type
3     RgnRects = array[0..1000] of TRect;
4     PRgnRect = ^RgnRects;
5   var
6     RgnData: PRgnData;
7     Size: DWORD;
8     i: Integer;
9     R: TRect;
10    RgnPtr: PRgnRect;
11  begin
12    Size := GetRegionData(Rgn, 0, nil);
13    Memo1.Lines.Add('Size = ' + IntToStr(Size));
14    GetMem(RgnData, Size);
15    GetRegionData(Rgn, Size, RgnData);
16    Memo1.Lines.Add('Number of Rectangles = ' + IntToStr(RgnData.rdh.nCount));
17    RgnPtr := @RgnData.Buffer;
18    for i := 0 to RgnData.rdh.nCount - 1 do
19    begin
20      R := RgnPtr[i];
21      Memo1.Lines.Add('Rect ' + IntToStr(i));
22      Memo1.Lines.Add(IntToStr(R.Left) + ', ' + IntToStr(R.Top) + ', ' +
23        IntToStr(R.Right) + ', ' + IntToStr(R.Bottom));
24    end;
25  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC