Dropdown buttons

K

Kim Gräsman

Hi all,

I've built a COM add-in that adds two simple buttons to the Outlook toolbar,
with code similar to this:

<translated from="C++" mode="freely">
Dim objCommandBar
Set objCommandBar =
objApplication.ActiveExplorer.CommandBars.Item("MyCommandBarName")
If objCommandBar Is Nothing Then
Set objCommandBar =
objApplication.ActiveExplorer.CommandBars.Add("MyCommandBarName", msoBarTop,
, False)
End If

Dim objMyFirstButton As _CommandBarButton
Set objMyFirstButton = objCommandBar.Controls.Item(1)
If objMyFirstButton Is Nothing Then
Set objMyFirstButton = objCommandBar.Controls.Add(msoControlButton,
, , , False)

objMyFirstButton.Style = msoButtonCaption
objMyFirstButton.Visible = True
objMyFirstButton.Caption = "My First Button"
objMyFirstButton.Enabled = True
objMyFirstButton.ToolTipText = "The first button I ever added"
End If

Dim objMySecondButton As _CommandBarButton
Set objMySecondButton = objCommandBar.Controls.Item(2)
' Same treatment for this one

' Sink events for the two buttons
</translated>

I'd like to make the two buttons part of the same dropdown button - how
would I go about that? Either I'm looking at the wrong documentation, it's
fairly hard to understand, or I'm just stupid.

I figured it's got something to do with the msoControlButtonDropDown style,
but I can't seem to get the two buttons on the same dropdown.

Many thanks for any leads.
 
E

Eric Lawrence [MSFT]

I was told (when asking this question two years ago) that it's impossible to
create a dropdown button like that from VBA or a COM-plug in. If you find
out otherwise, please let me know.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Kim Gräsman

Hi Eric,

Yeah, after posting (should have been before, sorry about that) I noticed a
good number of posts on the subject [1], and no real solution.

However, I also noticed that I don't really know what a Button Dropdown is,
and that I was actually looking for a Popup control. The open-source project
SpamBayes [2] confirmed this, and provided me with some python code to show
how it's done.

I got it working just fine yesterday with the new control type
(msoControlPopup), to which I can add buttons as sub-controls.

Thanks!

[1] http://groups.google.com/groups?q=msoControlButtonDropDown
[2] http://spambayes.sourceforge.net
 
E

Eric Lawrence [MSFT]

Interesting. Thanks for the tip! (Is there a screenshot of what the
resulting control looks like? Feel free to email if that's easy for you).

Thanks!

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

Kim Gräsman said:
Hi Eric,

Yeah, after posting (should have been before, sorry about that) I noticed a
good number of posts on the subject [1], and no real solution.

However, I also noticed that I don't really know what a Button Dropdown is,
and that I was actually looking for a Popup control. The open-source project
SpamBayes [2] confirmed this, and provided me with some python code to show
how it's done.

I got it working just fine yesterday with the new control type
(msoControlPopup), to which I can add buttons as sub-controls.

Thanks!

[1] http://groups.google.com/groups?q=msoControlButtonDropDown
[2] http://spambayes.sourceforge.net

--
Best regards,
Kim Gräsman


Eric Lawrence said:
I was told (when asking this question two years ago) that it's
impossible
to
create a dropdown button like that from VBA or a COM-plug in. If you find
out otherwise, please let me know.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services
 
K

Kim Gräsman

Eric said:
Interesting. Thanks for the tip! (Is there a screenshot of what the
resulting control looks like? Feel free to email if that's easy for
you).

Sure: http://www.winwonk.com/temp/popupbuttons.png

So the BrowseToSender "container" is of type msoControlPopup, and the items
on the dropdown are ordinary msoControlButtons.
In collapsed state it looks like a button with a little down-arrow to the
right, much like the Send/Receive button.

That's pretty much what I expected the msoControlButtonDropdown type to look
like, so I still have no idea what I've missed :)

Kim
 
E

Eric Lawrence [MSFT]

Ah, but when you click on the thing, does it just dropdown the list?

I believe the msoControlButtonDropDown is like the Outlook "New" button--
you can either click the button to take the default action, or you can pick
from the dropdown by clicking on the arrow.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Kim Gräsman

Hi Eric,
Ah, but when you click on the thing, does it just dropdown the list?

I believe the msoControlButtonDropDown is like the Outlook "New" button--
you can either click the button to take the default action, or you can pick
from the dropdown by clicking on the arrow.

You're right. Again, after posting, I noticed this. Plus the fact that when
the dropdown button is hovered over, the little arrow and the actual button
face seem to be divided graphically.

Anyway, the msoControlPopup style is fine by me, and I still see no way of
creating an msoControlButtonDropDown control.
 

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