ole object default action

S

Steve Rindsberg

Ok, if I understand what you are saying, PowerPoint can only send the play
verb from the animation settings. (Or with a WithEvents trap that you build
and handle).

????

Embed an Excel chart or sheet, right click and it gives you Open or Edit as
options (and not a Play in sight).
 
S

Steve Rindsberg

If I were to insert say the Windows Media Player with a link to a wav file,
it would not simply play on its own in PPT.

But look at what happens when you insert a WAV as an object. Action setting's
set to Play automatically, and unless I'm WAY off the mark, that's what Bob's
after. No code other than what's in the inserted object and/or OLE server
that owns it. That about right, Bob?


Raises a question, that does: inserting a file that's "owned" by an OLE server
vs inserting an OLE control seems to have different behaviors.
 
S

Steve Rindsberg

correct, that's the exact problem.


After one of my objects has been inserted, the shape's action settings
are set to "None". If I manually change them to "Object action" I can
then select "Play" from the dropdown list, but that's the manual step
I'm trying to make automatic.

Hmm. Assuming you've got Visual Studio installed, maybe try poking around with the
included Ole/Com viewer; compare what your server looks like to it vs what a server
that automatically creates a Play action looks like. Afraid I've no clue what to
look for exactly, but maybe you'll see something to trigger the Aha! experience.
 
A

Austin Myers

But look at what happens when you insert a WAV as an object. Action
setting's
set to Play automatically, and unless I'm WAY off the mark, that's what
Bob's
after. No code other than what's in the inserted object and/or OLE
server
that owns it. That about right, Bob?

Ok, I think I see what Bob is after. (Yeah I am slow but eventually I catch
on. <g>)

Following up with what you said Steve, it appears the only objects that
behave in this manner are wav and mid files. In fact when I insert a wav as
an object I am given the speaker icon on the slide which leads me to believe
(s.w.a.g.) that PPT recognizes the file type internally and handles it
accordingly. Mid files are automatically given the Sound Recorder icon.

Hmmm, experimenting a little more and it seems this only holds true for wav
files that are PCM (Pulse Code Modulation) based. Other types of wav files
do not generate the speaker icon or the Play action setting. Again its a
s.w.a.g but that leads me to believe PPT is reading the file header and if
it meets the set criteria goes ahead and assigns the play action setting.

I see nothing in the object model that would allow us access to this . :-(



Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia, PFCPro, PFCExpress
http://www.pfcmedia.com
 
B

Bob

But look at what happens when you insert a WAV as an object. Action
setting's set to Play automatically, and unless I'm WAY off the mark, that's
what Bob's after. No code other than what's in the inserted object and/or
OLE server that owns it. That about right, Bob?

Thank you, and Austin too, for all the ideas, and for sticking with me
on this. Steve your assessment (above) of my situation is EXACTLY
right.
Hmm. Assuming you've got Visual Studio installed, maybe try poking around with the
included Ole/Com viewer; compare what your server looks like to it vs what a server
that automatically creates a Play action looks like. Afraid I've no clue what to
look for exactly, but maybe you'll see something to trigger the Aha! experience.

I have studied the OLE viewer, and unfortunately I have been unable to
discern a meaningful difference between my ole server and the windows
sound recorder.

Along the way in this whole investigation I started to wonder if maybe
the windows sound recorder ole server itself, on instantiation,
attempts to figure out whether it's being embedded in PowerPoint, and
if so navigates the PowerPoint object model to find "itself" as a
shape within the presentation, and then sets that shape's
ActionSettings(ppMouseClick).ActionVerb to "play".

I tried this and it works! Here's how I did it (from the point of
view of my ole server code):
- queryinterface myself for IOleObject
- call IOleObject::GetClientSite() to get the IOleClientSite that
holds me
- call IOleClientSite::GetContainer() to get the IOleContainer for
that site.
- queryinterface the IOleContainer for the PowerPoint
"_Presentation"
interface (PowerPoint::_Presentation) to see if it supports it (if so
I think it's safe to I assume I'm embedded in a PowerPoint
presentation)
- Using the PowerPoint object model, I'm then able to sift through
all
the slides of the presentation, and all the shapes on each slide.
For
each shape I
- check its type to see if the shape is an ole embedded object
(Type == msoEmbeddedOLEObject)
- if so I get the Object property of the OLEFormat container of
the shape, and I queryinterface for its IUnknown *. finally I
compare
that pointer to my own IUnknown *. If they match, then I have "found
myself."


I know, it's crazy isn't it!?!? It works, but it's less than ideal
because, while it's reasonably quick for a presentation with only a
few slides, a large presentation hesitates a bit when you add a new
object because it has to search through every slide, which is uncool.
It's not outlandishly slow, but noticeable in some cases and I'm not
happy about that.

So I posted in the microsoft.public.win32.programmer.ole group to see
if anyone knew how I could just step up one level from my ole object
itself to get the shape that contains it instead of the above round-
about search process.

In the mean time I'm going to stick with this approach unless you guys
can conceive of either a better way to do the above, or MUCH more
preferably, a way of registering my "play" verb so that PowerPoint
simply says, "hey this object should 'play' when clicked," whenever a
new object of my type is added.

Again thank you for all your help!
 
S

Steve Rindsberg

What a roundabout way to have to go at it but you gotta admit, it was pretty much
brilliant of you to come up with it. Neat work.

I wonder if you can navigate from the object upward through the chain of .Parent
properties.

For example, if you have a reference to the shape, then it's .Parent is the slide it's
on and so forth.
 
B

Bob

I wonder if you can navigate from the object upward through the chain of .Parent
properties.

For example, if you have a reference to the shape, then it's .Parent is the slide it's
on and so forth.

The trouble I'm having with that is getting "my" Shape to begin with.
My ole server object is all my code, and the powerpoint Shape object
is the thing in the PowerPoint object model that contains me, but it
seems it's entirely up to the container application (PowerPoint) as to
whether (and how) it lets outsiders gain access to its object model.
And even though my object is embedded in PowerPoint, it's still
technically an "outsider" and I have not been able to discover a way
(other than the "round-about way" described in my prior post) to get
from my embedded object to the Shape that contains it.

It's very disappointing, but I guess I should be happy with what I've
got. We'll see if anyone over in the programmer.ole group has any new
ideas. I think there MUST be a way, and I imagine SOMEONE out there
would look at the problem and say, "Duh of course you just have to
<insert answer here>," so it's just a matter of tracking down that
person.

Thanks for your help. If you ever run into someone you think might
fit the above description, send 'em my way!!
 
S

Steve Rindsberg

For example, if you have a reference to the shape, then it's .Parent is the slide it's
The trouble I'm having with that is getting "my" Shape to begin with.
My ole server object is all my code, and the powerpoint Shape object
is the thing in the PowerPoint object model that contains me, but it
seems it's entirely up to the container application (PowerPoint) as to
whether (and how) it lets outsiders gain access to its object model.
And even though my object is embedded in PowerPoint, it's still
technically an "outsider" and I have not been able to discover a way
(other than the "round-about way" described in my prior post) to get
from my embedded object to the Shape that contains it.

I was afraid that might be the case, but it seemed such a nice clean way out, I couldn't
resist suggesting it. said:
It's very disappointing, but I guess I should be happy with what I've
got. We'll see if anyone over in the programmer.ole group has any new
ideas. I think there MUST be a way, and I imagine SOMEONE out there
would look at the problem and say, "Duh of course you just have to
<insert answer here>," so it's just a matter of tracking down that
person.

Thanks for your help. If you ever run into someone you think might
fit the above description, send 'em my way!!

Of course ... and if you find that person, squirt the answer back this way.
 

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