Perimeter Selection

G

Gil_H

Hello EV1,

I need to know if there is a way to get the Values
(Left,Top,Bottom,Right) of the Selection Rectangle created by user on a
slide.

My Task is to create a macro who knows to select a shape even if it
isn't completely Covered by the selection, but a part of it.

Thanx,
Gil H
 
C

ciw2otv

While working in the normal view the following can glean the
information that you requested.
Public Sub ltwhShp()
With ActiveWindow.Selection.ShapeRange
MsgBox "The shape named " & .Name & Chr(13) & _
"has left by " & .Left & " and " & _
"tops out at " & .Top & ". " & Chr(13) & _
"It's width stretches to " & .Width & Chr(13) & _
" while lofting to a height of " & .Height & "."
End With
End Sub

If you do much with macros a very valuable addin to have at your
disposal is "Starter Set" at http://www.rdpslides.com/pptools/
 
G

Gil_H

Thanx,

But i already know what you wrote, and there is no macro in the link
you sent that fit my requirements.

I need to create a macro that will know to select a shape when the
selection perimeter doesn't surround the shape.
Regulary, when you surround a shape - you select it, and my wish is to
surround a part of it and it will become selected.

For a start, i'll need to know what is the Selection Values - then it
will be a piece of cake to create the macro.

I really need it, even just a tip.

Regards,
Gil H.
 
C

ciw2otv

I need to create a macro that will know to select a shape when the
selection perimeter doesn't surround the shape.

If the shape is clicked on, it can be selected, it doesn't necessarily
need to be surrounded. If a press mouse button and drag is done then it
won't be selected.
Regulary, when you surround a shape - you select it, and my wish is to
surround a part of it and it will become selected.

If the user is doing this in slide show view, a macro can be written
and action set to any number of shapes on the slide. Again a click on
the shape will fire the macro.
***begin code***
Public Sub shpSelect(oShp As Shape)
MsgBox "Shape """ & oShp.Name & "'s" & _
"""" & " values are:" & Chr(13) & _
"Left, Top, Width, Height, respectively " & _
Chr(13) & oShp.Left & ", " & _
oShp.Top & ", " & _
oShp.Width & ", " & oShp.Height
End Sub
***end code***
 
C

Chirag

PowerPoint only selects the shapes that are completely covered within a
perimeter. Yu seem to want to change this behavior to also select the shapes
that are partially covered.

A couple of ways to go about it:
1. Perfect way:
Perfect ways are lot harder to implement at times but the end result is
quite satisfying. Here it goes:
It may not be a simple macro there. You can subclass the slide pane of the
active window. This will allow you to receive the mouse messages that arrive
for the slide pane. Handle the mousedown, mousemove and mouseup messages to
know the rectangular selection. Number of cases arise that need to be
handled. For instance, if Ctrl key is held when mousedown message was
received, then it means that the user wants to the new shape selection to
add to an existing selection. But if Ctrl is depressed before mouseup
message, then its a different behavior. A mousedown and a mouseup without a
mousemove would mean a mouse click and the code needs to handle that case as
well. Basically, you are on your own to provide proper semantics to all of
these cases and also provide proper feedback (like changing the mouse cursor
to include a plus sign when Ctrl is pressed) to the user on all of such
cases. I hope all this helps you understand the complexity of the task at
hand before you venture into it.

To start with, you need to know the slide pane to be able to subclass it.
All panes are of the window class called "paneClassDC". Get the handle to
the pane that matches the dimensions and location of the slide pane.

2. Probabilistic way:
This is not perfect and a different route may also end up with you selecting
other shapes. The basic idea is to look at the shapes that are in a
selection and determine if they got selected were because of a perimeter
selection. Try to determine the largest bounding rectangle that includes all
the selected shapes. If the shapes included within this rectangle are all
within the selected shapes collection, then there is a high probability that
the shapes were selected by perimeter selection. In such a case, include the
shapes that overlap this bounding rectangle. But make sure your code
understands that the new bounding rectangle that will get created because of
this activity is your doing and not the user's. Otherwise your code could
eventually end up always selecting all shapes on the slide.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
G

Gil_H

Thanx Chirag,

I have read your two solutions, and i was planning to implement the
second (and easiest way).
To my opinion, there is no fear to make any calculating mistakes with
rectangles - because it's a basic math. ( even if we talk about
Polygons - there are specified Algorithms for that ).
But how do i get the rectangle Values?
That was my question from the beginning. I got to find a way to
discover rectangle values - and then i run a loop on all shapes on
slide and ask them the "Is part of you inside" question.


Gil H.
 

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