Custom shapes with special behaviour

J

Jac Tremblay

Hi,

I use Visio 2003 and 2007.

I want to know if it is possible to create a custom shape from two
rectangles (for example) grouped together and have only one rectangle be
resized when the custom shape is resized?

I do not want the user to have to ungroup the components to do the job.

Thanks for any help.
 
J

John... Visio MVP

Jac Tremblay said:
Hi,

I use Visio 2003 and 2007.

I want to know if it is possible to create a custom shape from two
rectangles (for example) grouped together and have only one rectangle be
resized when the custom shape is resized?

I do not want the user to have to ungroup the components to do the job.

Thanks for any help.


This can be done as a single shape or if you need two seperate rectangles
grouped together. If two grouped together, then the first rectangle can be
based on the W&H of the group while the second rectangle can be fixed or
something relative to the group shape.

So can you provide more details of what you would like?

John... Visio MVP
 
J

Jac Tremblay

Hi John,
As I can see, there is not much I can do. Actually, I wanted a rectangular
shape with a small rectangle at the top left corner. That small one would
always be the same size and would stay at the top left corner of the big
rectangle no matter how the big one is resized.
I guess I will forget about my idea.
Thank you for your answer, it is very appreciated.
 
J

Jac Tremblay

Hi John,
Are you the same John (Goldsmith)? If yes, sorry for the confusion. If not,
please see the answer I posted to the other one.
In any case, thanks for your asnwer, John. It is always a pleasure to get
MVPs comments.
 
J

John... Visio MVP

I am the old guy (John Marshall - Visio.mvps.org) who has been around since
Visio 1. The other John, John Goldsmith is the latest (and well deserved)
addition to the Visio MVP community.

John... Visio MVP
 
J

John Goldsmith_Visio_MVP

Hello Jac,

That's no problem to implement...

1) Draw your larger rectangle

2) Draw your smaller rectangle and position in the top left hand corner of
the previous one

3) With your smaller rectangle selected, click Format / Behavior /
Reposition only (on the Behavior tab)

4) Click OK to close the dialog

5) Select both rectangles and click Shape / Grouping / Group

This takes care of the resizing issue. Now to make sure the small rectangle
stays in the top left corner....

6) Sub-select the smaller rectangle (first click selects the group shape and
second the sub-shape)

7) Click Window / Show ShapeSheet (see this post for more info:
http://visualsignals.typepad.co.uk/vislog/2007/10/just-for-starte.html )

8) In the first section ('Shape Transform') change the following cells:

PinX = Sheet.3!Width*0
PinY = Sheet.3!Height*1
LocPinX = Width*0
LocPinY = Height*1

(Note the '3' in 'Sheet.3' above may be a different number for you - it's
refering to the group shape)

If you're interested in what all those Pin... things are then you might want
to have a look at this link:

http://msdn.microsoft.com/en-us/library/aa200965(office.10).aspx

Hope that helps

Best regards

John

PS - The other John is older (as an MVP) and wiser one :)


John Goldsmith (Visio MVP)
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
J

Jac Tremblay

Hi John Marshall,

I'm glad I noticed the difference. I will check your web reference and come
back with some more questions later onn (unless I find the answers by myself).

Thank you for your precious time and for helping all those people over the
years.
 
W

WapperDude

Just for the sake of having an optional way to do this, it is possible to do
it without grouping. The steps are basically the same as John indicated,
except you don't need to change the re-size mode, and you don't group. Let's
say the large rectangle has an ID =1, and small rectangle is ID=2.

Select and open small rectangle shape sheet.
Set PinX = guard(sheet.1!PinX)
Set PinY = guard(sheet.1!PinY).
Set LocPinX = width*0
Set LocPinY = height*1

Select and open large reectangle shape sheet
Set LocPinX = width*0
Set LocPinY = height*1.

This gives the same functionality as the grouping technique bit now either
shape is selectable with a single click.

HTH
Wapperdude
 
J

Jac Tremblay

Hi John,
Sorry for the time I took to answer.
I really appreciate your comment and it is very useful. I checked the links
you provided and I noticed there are a lot of informations I have to master
before I go on with other interrogations.
In my solution, I would like to try to avoid VBA, but if it is needed, I
will not hesitate to use it.
I checked your answer, but there are a few drawbacks. One is that the user
can select the big rectangle in the group and resize it without resizing the
group which leads to some other problems.
A second drawback is that the user cannot enter text in either rectangles.
Another one yet is that if I want to create a master form from that group,
it does not work properly at all. Of course, I did not have the time to check
the creation of master forms. I certainly will in the next few days (I saw
the refencences in MSDN).
So that is it for now. Thanks again for your time, John.
 
J

Jac Tremblay

Hi WapperDude,
I like your solution. I will check it out a bit more and come back with a
more complete answer as soon as I can.
Thanks.
 
J

John... Visio MVP

You mention text in eiither rectangle. If you need multiple text blocks,
then you will need a group shape. A Visio shape can have only one text
block. Any shape that has multiple text blocks is a grouped shape.

You may want to consider entering custom properties in the main shape and
each shape can reference the appropriate custom property.

If you want a single text block, but that can appear in one of many
rectangles, this can be done with a single shape and the use of the Hide
Text cell.

John... Visio MVP

Jac Tremblay said:
Hi John,
Sorry for the time I took to answer.
I really appreciate your comment and it is very useful. I checked the
links
you provided and I noticed there are a lot of informations I have to
master
before I go on with other interrogations.
In my solution, I would like to try to avoid VBA, but if it is needed, I
will not hesitate to use it.
I checked your answer, but there are a few drawbacks. One is that the user
can select the big rectangle in the group and resize it without resizing
the
group which leads to some other problems.
A second drawback is that the user cannot enter text in either rectangles.
Another one yet is that if I want to create a master form from that group,
it does not work properly at all. Of course, I did not have the time to
check
the creation of master forms. I certainly will in the next few days (I saw
the refencences in MSDN).
So that is it for now. Thanks again for your time, John.
 
J

Jac Tremblay

Hi WapperDude,
I checked again your solution and find it very interesting. But if I place
that form on a stencil, instances created from it do not work the same way
the original did. The text cannot be edited any more. The repositioning are
ok though.
Another thing: the small rectangle in that solution is placed at the top
left corner of the big rectangle, inside of it. How should I modify the
formulas if I wanted the small rectangle to be outside the big one (the base
of it would be the top of the big rectangle)?
I will try to find the answer by myself in the mean time.
Thanks for comment and your time.
 
J

Jac Tremblay

Hi Again WapperDude,
I found out how to position the small rectangle at the top of the big one.
All I have to do is:
Select and open small rectangle shape sheet.
Set PinX = guard(sheet.1!PinX)
Set PinY = guard(sheet.1!PinY).
Set LocPinX = width*0
Set LocPinY = height*0
The rest is the same.
But my question is:
When I type the formula "= guard(sheet.1!PinX)", Visio changes it for "=
guard(Box!PinX)". Why?
Thanks
 
W

WapperDude

Great! Glad you worked it out. If you want to see a "graphic" illustration
of PinX vs LocPinX, see Visio Guy's post:
http://www.visguy.com/shapes/visio-art/, and scroll down to find: Pin and
LocPin Illustration.

As far as the "box" thing, had you renamed the shape to box? Sometimes
Visio will pick up the new name of a shape and use it. It seems to be quite
inconsistent with regards to this. Also, you mentioned problems editting the
text. My guess is that you grouped the shapes and then placed them on a
stencil. So, when you drag them from the stencil to the drawing, you'll need
to double click as per one of John Goldsmith's replies.

As far as the "box" goes, did you create the rectange by dragging a shape
named box onto the page? It's unclear why/when Visio jumps from a "friendly"
name to a "sheet.id" name. Generally, you can always use the shape.id form.
Easiest way to get a shape identity is to menu bar > Format > Special. The
pop up form gives the names. But you have to have developer mode turned on:
http://www.visguy.com/2008/08/04/top-9-reasons-for-turning-on-developer-mode/

HTH
Wapperdude
 
J

John... Visio MVP

Or Visio did it. When you drop a collection of shapes on a stencil, Visio
will group them.

John... Visio MVP
 

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