• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 849
  • Last Modified:

How FrameRgn works

var
   Rects  :array of TRect;
   Points :array of TPoint;

Rects is an array of rectangles that is filled indirectly by GetRegionData (and stored in the same order as they were found in the RGNDATA structure).

Points is an ordered array of points I will use to draw an outline of the region.  (This array will be identical to the array of points you would pass into CreatePolyPolygonRgn, if you were to create the region that way)

I can't use FrameRgn for two reasons:

1.  FrameRgn really isn't very powerful.  I want to draw marching ants and FrameRgn apparently only draws solid lines.
2.  I am not using the region for the purposes of directly drawing to a device context.

I would like to know the algorithm FrameRgn uses to draw the outline of a region, so I can convert Rects to Points.
0
scrapdog
Asked:
scrapdog
  • 5
  • 2
  • 2
1 Solution
 
intheCommented:
hi scrapdog,
dunno about FrameRgn but i have an example of marching ants if its any help (it doesnt use FrameRgn etc).
0
 
scrapdogAuthor Commented:
No thanks, got that one figured out. =)
0
 
scrapdogAuthor Commented:
But if your marching ants code takes it's input from a Windows region, that would be very helpful...
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
intheCommented:
nope ,just passes x,y of mouse to lineDDA()
all other examples i have are from tomes which dont look like they help here.

so just listening..
0
 
FengYuanCommented:
Simple algorithm:

1) Suppose you use (x1,y1,x2,y2) to represent a line to draw.
2) Create a set or sequence of lines.
3) For each rectangle in the region, adding its four edges to the line set using 4).
4) When adding each line to the set, search for lines in the set which intersects with the line to be added.
5) If no intersection is found, append the line.
6) If intersection is found, remove the matched line, add the disjoint portion of the two lines if any.

7) Draw what's left in the line set.

www.fengyuan.com
0
 
scrapdogAuthor Commented:
In #6, intersecting two lines will create four line segments...how do I know which line segments to discard (i.e., which of these segments are inside the region)?
0
 
FengYuanCommented:
I think you should only consider tw vertical lines or two horizontal lines intersect with each other.

In these cases, at most two new lines can be generated.
0
 
scrapdogAuthor Commented:
OK, thanks for the info.  I'll try it out.
0
 
scrapdogAuthor Commented:
Excellent.  It worked.  I thought everyone was stumped on this one.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now