By the way, describe the whole problem there, possibly list of rectangles is better as algorithm input than region data.
Main Topics
Browse All TopicsUsing VisualBasic
I have currently created alot of PolyPolygon regions which i use to fill and outline alot of reservation, now what i need is to add text to these. I figured that by using the CreateFont, SelectObject and SetTextColor, i can print different types of font and colors on my grid.
Then by using DrawText API i can select a rectangle to clip the text within. So this is where iam stuck i now need to get the largest Rectangle from within a PolyPolygon area, actually what i need is to find the largest horizontal rectangle within every part of the PolyPolygon region which are not connected.
Can someone give me an example of doing both or just the first ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Please do look up on GetRegionData <--
http://msdn.microsoft.com/
it does ecsactly what i need i just can't find out how to get it working... it does do it...
COPIED FROM MSDN
GetRegionData
The GetRegionData function fills the specified buffer with data describing a region. This data includes the dimensions of the rectangles that make up the region.
DWORD GetRegionData(
HRGN hRgn, // handle to region
DWORD dwCount, // size of region data buffer
LPRGNDATA lpRgnData // region data buffer
);
Parameters
hRgn
[in] Handle to the region.
dwCount
[in] Specifies the size, in bytes, of the lpRgnData buffer.
lpRgnData
[out] Pointer to a RGNDATA structure that receives the information. The dimensions of the region are in logical units. If this parameter is NULL, the return value contains the number of bytes needed for the region data.
Return Values
If the function succeeds and dwCount specifies an adequate number of bytes, the return value is always dwCount. If dwCount is too small or the function fails, the return value is 0. If lpRgnData is NULL, the return value is the required number of bytes.
If the function fails, the return value is zero.
Windows NT/2000/XP: To get extended error information, call GetLastError.
Remarks
The GetRegionData function is used in conjunction with the ExtCreateRegion function.
Iam using Visual basic
And well if i get returned all rectangles which is used to create my rectangular structure
www.scoding.dk/needThis.JP
cant i then quite easily figure out whether they are connected and not and which are the biggest ???
'It looks like the easiest way to provide a buffer for this
'function would be using an array of Longs.
Dim RgnData() as Long
'Now, you're going to have to call this function twice, with
'different argument types each time. You can either use As Any or
'use two different declarations. Using two declarations is
'probably safer.
Private Declare Function GetRegionDataSize lib "gdi32" alias "GetRegionData" (byval hRgn as Long, byval Zero1 as Long, byval Zero2 as Long) as Long
Private Declare Function GetRegionData lib "gdi32" (byval hRgn as Long, byval BufferSize as Long, byref FirstLong as Long) as Long
'We need to call the function once to find the size of the buffer.
Redim RgnData(1 to GetRegionDataSize(hRgn, 0, 0) / 4)
'We need to call it again to fill in the buffer.
Call GetRegionData(hRgn, LenB(RgnData), RgnData(1))
'Now, RgnData(1) to RgnData(8) are header information you probably
'don't need. RgnData(9) is a Left, RgnData(10) is a Top,
'RgnData(11) is a Right, and RgnData(12) is a Bottom for a single
'rectangle, and the rest of the array will continue that pattern.
I beleive you can get list of rectangles using the way provided by JMoon5FTM. Having this, consider the following algorithm:
Input - list of rectangles (GetRegionData output).
Output - the largest horizontal rectangle within every part of the input list region which are not connected.
Algorithm may be implemented in VB, for example, using dynamic arrays. Written using pseudo-code.
Consider array (A) of elements (G). Each element (G) is array of rectangles. This is temporary variable used in algorithm. G is group of intersecting rectangles, number of elements in A is number of non-intersecting groups.
Let's call input array or rectangles I, output array of rectangles O.
For each rectangle r in I
For each group g in A
For each rectangle r1 in g
if r1 and r are intersecting, add r to g and go to next r (external loop)
Next
Next
Add new group to A which contains r (we are here if r doesn't intersect with any of existing rectangles)
Next
For each group g in A
Find maximal rectangle in g and add it to O
Next
Business Accounts
Answer for Membership
by: AlexFMPosted on 2004-05-10 at 07:50:38ID: 11031631
I see that you ask this question number of times without success. There is no Windows API which can do this. I suggest you to ask this question in the Math area: http://www.experts-exchang e.com/Misc ellaneous/ Math_Scien ce/
Since Math experts are not Windows programmers, describe GetRegionData API for them to give idea what is input for algorithm you need. I got number of excellent answers from Math experts, possibly they can help also in this case.