Accurate Detection of Graphic Area of Shape Object

G

Greg

Hi all:

REQUEST:
I need to accurately detect only the graphic region of shape objects in Excel. There will be several overlapping shapes that I need to accurately discriminate. I am not a professional programmer.

PROBLEM:
Shapes in general in Excel have a zone around them (roughly 4 pixels wide) that form part of the object. ActiveWindow.RangeFromPoint returns the object even though not directly referencing a point over the graphic region. Freeforms apparently have longer and unpredictable projections from sharp points.

CURRENT APPROACH
So far all I can come up with is a kludge that uses RangeFromPoint in combination with GetPixel. I conduct a pixel walk between two clicked points captured using PeekMessage. When I detect a new shape I capture its fill forecolor and change it to a reserved forecolor. I then continue the walk and record the start and end points where I detect the reserved forecolor using GetPixel. When I get past the shape I reset the forecolor. The manner in which I sort out overlapping shapes is a complex loop and recursive process. Obviously, if using GetPixel, I cannot turn off screen updating (or use LockWindowUpdate). So, you see the whole thing flash and flicker and it takes awhile if there are a lot of shapes.

Best regards,

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top