Extending objects with custom properties

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

First up, thanks to everyone who has responded to my various odball
questions :-D

Anyway, is it possible to add your own properties to displayed objects and
therefore extend them? Even better are the objects (like a text box)
essentially OOP classes that can be sub-classed? If so, how do I do this and
how do I extend the properties editor to allow me to enter the extra stuff?

Background:
I'm a teacher and I'm trying to create an easy to use timer (count down/up)
to use on slides to time exercises, breaks, wasted time etc etc.

TIA

Paul
 
First up, thanks to everyone who has responded to my various odball
questions :-D

Fun stuff. Keep it coming.
Anyway, is it possible to add your own properties to displayed objects and
therefore extend them? Even better are the objects (like a text box)
essentially OOP classes that can be sub-classed? If so, how do I do this and
how do I extend the properties editor to allow me to enter the extra stuff?

Not that I'm aware of, but you can add tags to any shape, slide or
presentation, then your own code can do whatever it needs to with that
information.
 
Steve Rindsberg said:
Fun stuff. Keep it coming.
Ok, you asked for it! ;-)
Not that I'm aware of, but you can add tags to any shape, slide or
presentation, then your own code can do whatever it needs to with that
information.

Sounds promising. How do I do that?
TIA
 
Thanks for that :-)

These may well be useful as a stop-gap, but infortunately I need something a
little more customizable (not least in that I'm not timing breaks, but
exercises and so on!)

Thanks again for taking the time to respond.
 
Sounds promising. How do I do that?

Tags? Easy:

Assuming you've got a reference to the shape, slide or presentation in oSomeVar, to
set a tag:

oSomeVar.Tags.Add Name:="MyTagName", Value:="MyTagValue"

For example:

oSomeVar.Tags.Add Name:="LifeTheUniverseEverything", Value:="42"


or

If oSomeVar.Tags("LifeTheUniverseEverything") = "42" Then
MsgBox("I'm SO tired. And there's this pain in all the diodes...")
End If

You can have as many tags per item as you like, for all practical purposes, and
each can contain a LOT of text.
 
Steve Rindsberg said:
Tags? Easy:

Assuming you've got a reference to the shape, slide or presentation in oSomeVar, to
set a tag:

oSomeVar.Tags.Add Name:="MyTagName", Value:="MyTagValue"

For example:

oSomeVar.Tags.Add Name:="LifeTheUniverseEverything", Value:="42"


or

If oSomeVar.Tags("LifeTheUniverseEverything") = "42" Then
MsgBox("I'm SO tired. And there's this pain in all the diodes...")
End If

You can have as many tags per item as you like, for all practical purposes, and
each can contain a LOT of text.
Uhhh ok - that looks like we're getting somewhere :-)

I'll have a play and then, no doubt (in the words of Arnie) I'll Be Back ;-)

Thanks again!
 
Ok, I've seen various add-ins that suggest a custom object (or at least a
standard object with additional tags) is being created. This usually involves
something added to the "insert" menu, although I'll bet you can add it to the
toolbox as well.

What I want to do is the following:-

Allow the user to create an object called a timer. This object will
basically be a text box, but with two differences..

1) When it is created it will auomatically have a couple of additional
properties (held in tags) so a dialog will need to come up to allow the user
to enter these (these will be the time for the timer, whether it should start
automatically or wait to be clicked and whether to advance to the next slide
once the timer runs out).

2) It needs to have an "on click" action already defined which I will then
trap when the show is running in order to start (and / or pause) the timer. I
would also like to trap either a double-click or a right-click or a
shoft-click in order to allow the user to alter the time during the
presentation. I might do this, however, by adding something to the context
enu whenever a slide shows with a timer on ot.

Now I have managed to trap the right-mouse click in the editing window, and
then checked to see if I'm on a text box or not. This might work since my
user could then crate a normal text box and then right click on it and select
an option to convert the box to a timer (or edit it if it already is one!).
This kind of works, but I can't figure out how to add the action to the box
from the event handler.

Can anyone offer any advice on this?

BTW, once I get this working, I intend to make it available to others - a
flexible timer would be invaluable to a lot of people.

Many thanks (again!),

Paul
 
Ok, I've seen various add-ins that suggest a custom object (or at least a
standard object with additional tags) is being created. This usually involves
something added to the "insert" menu, although I'll bet you can add it to the
toolbox as well.

What I want to do is the following:-

Allow the user to create an object called a timer. This object will
basically be a text box, but with two differences..

1) When it is created it will auomatically have a couple of additional
properties (held in tags) so a dialog will need to come up to allow the user
to enter these (these will be the time for the timer, whether it should start
automatically or wait to be clicked and whether to advance to the next slide
once the timer runs out).

Starting thought: create an add-in with event handler and a menu. Click "Add timer" on
the menu and it creates a shape of the type and size you want and pops a dialog so the
user can fill in the needed info.

Then instead of getting too fancy with the editing, maybe just another item on the menu
... Edit Timer. If the user selects one of your objects, clicking this brings up the
edit dialog. Otherwise it tells the user to select a timer object first. You could get
fancier and check each shape on the slide to see if it's one of yours and if there's
only one, pull that up automatically when the user hasn't selected it.
2) It needs to have an "on click" action already defined which I will then
trap when the show is running in order to start (and / or pause) the timer. I
would also like to trap either a double-click or a right-click or a
shoft-click in order to allow the user to alter the time during the
presentation.

OnClick shouldn't be hard (assign it a Run Macro action setting and have the macro run
whatever code you need it to (out of your add-in). The macro could detect whether or
not a shift/alt/ctrl key is depressed and give you add'l options that way.

Or trapping the rightclick as you describe ...
 
1) When it is created it will auomatically have a couple of additional
Starting thought: create an add-in with event handler and a menu. Click "Add timer" on
the menu and it creates a shape of the type and size you want and pops a dialog so the
user can fill in the needed info.

Then instead of getting too fancy with the editing, maybe just another item on the menu
... Edit Timer. If the user selects one of your objects, clicking this brings up the
edit dialog. Otherwise it tells the user to select a timer object first. You could get
fancier and check each shape on the slide to see if it's one of yours and if there's
only one, pull that up automatically when the user hasn't selected it.

Ok, that seems reasonable, I guess I was thinking I needed the user to
"draw" on the page (like when you create a text box) but there isn't any
reason why they can't re-size and move it afterwards (and reformat it).
Thanks for the inspiration!

OnClick shouldn't be hard (assign it a Run Macro action setting and have the macro run
whatever code you need it to (out of your add-in). The macro could detect whether or
not a shift/alt/ctrl key is depressed and give you add'l options that way.

Sorry to be a pain, but I haven't been able to find how to programmatically
set this - can you point me in the right direction? What is the object
property actually called (as I obviously don't want the user to have to set
this up themselves ;-)

Thanks again for all your input on this (and my other threads!!!!)

Paul
 
Ok, that seems reasonable, I guess I was thinking I needed the user to
"draw" on the page (like when you create a text box) but there isn't any
reason why they can't re-size and move it afterwards (and reformat it).
Thanks for the inspiration!



Sorry to be a pain, but I haven't been able to find how to programmatically
set this - can you point me in the right direction? What is the object
property actually called (as I obviously don't want the user to have to set
this up themselves ;-)

You won't do yourself damage if I tell you that you can use the Macro Recorder to grab the
code for this? <g>

Sub SetAction(oSh As Shape)
With oSh.ActionSettings(ppMouseClick)
.Run = "MacroName"
.Action = ppActionRunMacro
.SoundEffect.Type = ppSoundNone
.AnimateAction = msoFalse
End With
End Sub

Google around GetAsyncKeyState to find a way to detect ctrl/alt/other keys.

I don't have any examples I'm free to publish, I'm afraid.
 
Back
Top