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!