Author Topic: Tab-Control like shape  (Read 6596 times)

0 Members and 1 Guest are viewing this topic.

paullox

  • Jr. Member
  • **
  • Posts: 10
Tab-Control like shape
« on: July 26, 2016, 12:51:41 PM »
Hi,

Very new to Visio but have some VBA experience in Excel.  I am working in a chemical research facility and would like to use Visio to represent chemical reactions.

I am trying to create a tabcontrol like shape to represent all the information associated with a particular chemical product.

Please see the first attachment for a picture of the 'tabcontrol' shape I am envisioning.

Each tab would contain text or images or objects associated with a chemical compound.  Of course, the overall tabcontrol would have the 'connection' points associated with Visio objects.  Ideally, the document viewer or creator would click on a tab and that tab comes to the 'foreground' and reveals itself while obscuring the other tabs.  This is probably trivial but I can't seem to find the eventprocedures, for example, 'onclick' nor the method for wiring a "bringtofront" macro.  Not sure if once created how specifically to save the object either, that is, as a custom stencil or otherwise.

Any help or clues appreciated.  :)

Sincerely,

Paul Pineau
Eastern Michigan University
« Last Edit: July 26, 2016, 02:06:07 PM by paullox »

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: Tab-Control like shape
« Reply #1 on: July 27, 2016, 05:25:04 AM »
I cannot find any good solution than my poor one.
To try my shape, select any tab, and key press Shift + Ctrl + f, or simply double click any tab.
DCMD(1046) works when you double click.
« Last Edit: July 27, 2016, 05:26:43 AM by JuneTheSecond »
Best Regards,

Junichi Yoda
http://june.minibird.jp/

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4917
  • Ideas Visio-lized into solutions
Re: Tab-Control like shape
« Reply #2 on: July 27, 2016, 01:07:53 PM »
I took a different approach than JuneTheSecond.

My approach uses shapedata to set tab position, tab text, and tab width.  The tab width drives the overall size of the shape.  Another feature, it's easy to add subtract tabs.  The first tab shape is unique.  It is the master.  All other shapes have their position slaved to this shape, along with their size. 

So, now you have two approaches.  I'm sure there are other techniques as well.

Enjoy.
Wapperdude
Visio 2019 Pro

paullox

  • Jr. Member
  • **
  • Posts: 10
Re: Tab-Control like shape
« Reply #3 on: July 27, 2016, 02:14:22 PM »
Visio People!

Thanks so much for your replies.  I will take a spin with both of the shapes you have provided.

Much appreciated!

Paul

paullox

  • Jr. Member
  • **
  • Posts: 10
Re: Tab-Control like shape
« Reply #4 on: July 27, 2016, 02:48:46 PM »
With regard to the shape provided by JuneTheSecond:

Being rather (extremely) new to Visio I gather that DOCMD(1046) is a 'system' command to bring an object to the front and this has been wired to the doubleclick event.  I suspect you performed this edit by directly editing the ShapeSheet.

I also see the flowing code in the 'general' section and not really sure what this is for or when it is called.

>>>>>>>>>>>>>>>>>>>>>>>>>>>

Sub addtogroup()
    ActiveWindow.Selection.addtogroup
End Sub

>>>>>>>>>>>>>>>>>>>>>>>>>>>

Thanks again for your help and any further comments you care to offer with regard to the SubProcedure above.  I fully expect to utilize your approach and will no doubt find myself wanting to make edits - and generally improve my knowledge of Visio-VBA.

Best wishes,

Paul


wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4917
  • Ideas Visio-lized into solutions
Re: Tab-Control like shape
« Reply #5 on: July 27, 2016, 04:17:11 PM »
One added note, my solution spent  require any macros.  That has security benefit.  Also, since the shape(s) are self-contained, makes distribution easier. 

Wapperdude
Visio 2019 Pro

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: Tab-Control like shape
« Reply #6 on: July 27, 2016, 07:46:25 PM »
Quote
I also see the flowing code in the 'general' section and not really sure what this is for or when it is called.
It should have been deleted before submit.
It is my personal tool to make new shapes sub shapes of existing group shape.
It is much easy than complexed UI operation.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

paullox

  • Jr. Member
  • **
  • Posts: 10
Re: Tab-Control like shape
« Reply #7 on: August 01, 2016, 11:45:54 AM »
in re Wapperdude sol'n:

Thanks for your effort.  I am intrigued by your solution as you are able to get text into the tab itself which is different from the 'body' text.

I have not been able to create more tabs as you describe via 'duplication'.  Not sure what I am doing wrong.  I don't explicitly see a 'duplicate' function and copy-paste does not work.

Finally, some of the tabs will hopefully contain images.  I have been able to get a satisfactory result by grouping images with a shape so that they size together and with the connection point behavior of a shape as opposed to that of an image alone.  However, not sure how I would go about grouping images with the tabs as you have designed.

Thanks for your help and any further comments you might  make.

Sincerely,

Paul

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4917
  • Ideas Visio-lized into solutions
Re: Tab-Control like shape
« Reply #8 on: August 01, 2016, 04:21:24 PM »
First things 1st...

Glad the solution is basically working.  Assuming you've not made any changes, other those provided by the original configuration, then, a single click to select any tab, other than 1st tab, followed by <cntl>+D, will duplicate the shape.  It will be identical to the originating shape in everyway...color, position, text, font, etc.  Merely, right click, and provide new tab position. 

Adding pictures should be ok to main shape.  Click once to select tab, then shift click to select pix, now use shape operations to add to group.

Adding picture to tab was unexpected...small picture.  But, select the main shape again, if it isn't.  Then change grouping behavior so it isn't group only. Now click select the actual tab shape.  Shift click to select tiny pix and group.  That ought to work.  Reset main group shape properties to group only.

HTH, Wapperdude
Visio 2019 Pro

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4917
  • Ideas Visio-lized into solutions
Re: Tab-Control like shape
« Reply #9 on: August 01, 2016, 10:06:27 PM »
Won't quite work.  There's a couple things that need massaging.  Won't take long, should have update tomorrow...I'm  on PDT.

Basically need to lock calculation of group width/height.  Then, set group fill pattern to none.

Wapperdude
Visio 2019 Pro

paullox

  • Jr. Member
  • **
  • Posts: 10
Re: Tab-Control like shape
« Reply #10 on: August 02, 2016, 12:17:03 PM »
Hi,


I am very intrigued by this solution.  It appears to be quite robust.  As mentioned, I am very new to Visio - can you suggest a good tutorial or book on the 'shapedata' approach that you have implemented?

Paul

paullox

  • Jr. Member
  • **
  • Posts: 10
Re: Tab-Control like shape
« Reply #11 on: August 02, 2016, 12:42:49 PM »
Hey Wapperdude,

Playing with the first iteration a bit more this morning.  Figure out how to duplicate it and then using the shapesheet change the tab position and tab text.

I see that the shape may not be dynamically resizable - which is okay - but not sure how to programmatically resize either.  Sorry, really need that primer on custom shapes.

Will keep playing around...

Paul

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4917
  • Ideas Visio-lized into solutions
Re: Tab-Control like shape
« Reply #12 on: August 02, 2016, 05:57:20 PM »
One of my favorite references is https://msdn.microsoft.com/en-us/library/aa200939(v=office.10).aspx

Came out with V2002, but, most info is appropriate for newer versions.  Gives a good understanding of the basics and moving beyond basics.

The overall shape size is slaved to the shape data tab width.
Visio 2019 Pro

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4917
  • Ideas Visio-lized into solutions
Re: Tab-Control like shape
« Reply #13 on: August 02, 2016, 11:34:45 PM »
Here's a cleaned up version.  Hindsight, and not rushing, seem to always improve things!

Added a control point to move the tabs about.  Otherwise, performs as before.

The structure is as follows.  The selection box is set small, and below the tabs.  That way, the tabs are directly selectable and there's nothing overlapping.  Because, double clicking is used to pop desired tab to the front, shapedata is accessed old fashioned way, thru UI menus.  The top shape was converted to a group.  This provides advantage of keeping selection box small, out of the way, and reduces one layer of build up.  This top shape is where the body of the text goes.  Note, it has no fill nor lines.  There is a 2nd shape added to the group.  This provides the background color and the tab textbox.  The 2nd and additional tabs have their size slaved to the 1st tab, as well as their position, via PinX.  This facilitates easy addition of as many tabs as desired. 

The card shape is slaved to the tab size.  This seemed like a reasonable approach.

There's one card that has two pictures.

Wapperdude
Visio 2019 Pro

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4917
  • Ideas Visio-lized into solutions
Re: Tab-Control like shape
« Reply #14 on: August 04, 2016, 08:03:31 PM »
Re-work the card shapes, made them, "smarter".  So, decided to start new topic with the updated design:  http://visguy.com/vgforum/index.php?topic=7389.0

Hopefully, this prevents hi-jacking this topic.

Wapperdude
Visio 2019 Pro