ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accurate Detection of Graphic Area of Shape Object (https://www.excelbanter.com/excel-programming/446618-accurate-detection-graphic-area-shape-object.html)

Greg[_43_]

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


All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com