View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Greg[_43_] Greg[_43_] is offline
external usenet poster
 
Posts: 1
Default Accurate Detection of Graphic Area of Shape Object

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 a while if there are a lot of shapes.

Best regards,

Greg