Office加载项自定义位图按钮 [英] Office Add-In custom bitmap button

查看:69
本文介绍了Office加载项自定义位图按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我们正在创建一个Office加载项。我们能够成功地显示加载项。
但是,我们按照

一个示例程序,它显示一个FaceID = 1044(

不是我们想要显示的按钮的位图)。我们

想要显示我们自己的自定义位图。


我们如何显示我们自己的自定义位图

相关的位图FaceID = 1044?


TIA,

BC

解决方案

关于Excel的许多愚蠢的事情之一是您必须创建

自己的位图按钮的方式:


1.加载您的位图。

2.用

标准Windows控件背景颜色替换所有想要透明的像素(在当前

主题中配置) )。

3.备份剪贴板(只要它不是太大)。

4.将位图复制到剪贴板。

5.将位图粘贴到按钮上。

6.恢复剪贴板。


备份和恢复剪贴板是可选的,但它'当用户复制一些文本,启动Excel并粘贴以查找

>
一些愚蠢的插件已经破坏了剪贴板。


如果您使用的是Excel XP,那么您可以设置属性
图像和图像蒙版的按钮。


问候,

Aaron Queenan。


BC <一个******* @ discussions.microsoft.com>在消息中写道

news:04 **************************** @ phx.gbl ... < blockquote class =post_quotes>你好,

我们正在创建一个Office加载项。我们能够成功地显示加载项。但是,我们关注了一个示例程序,它显示了一个FaceID = 1044(它不是我们想要显示的按钮的位图)。我们想要显示我们自己的自定义位图。

我们如何显示自己的自定义位图而不是与FaceID = 1044相关的位图?
TIA,
BC



Hello Aaron,


感谢您回复我的帖子。


您是否有任何示例C#代码实现

您描述创建自定义

按钮的过程?


再次感谢,

BC


你好BC,

这里是我的代码(没有备份剪贴板,我没有想过

关于那:))。现在我必须做到这一点:)


oButton =(Office.CommandBarButton)oBar.Controls.Add

(MsoControlType.msoControlButton,

Missing.Value,Missing.Value,1,false);


Clipboard.SetDataObject(oButtonIcon);

// oButtonIcon是Drawing.Icon


mButton.PasteFace();

mButton.Style = MsoButtonStyle.msoButtonIconAndCaption;


嗯,是的Aaron是的,我必须实现剪贴板备份。


希望有所帮助

Sunny


文章< 08****************************@phx.gbl>,
一个******* @ discuss.microsoft.com 说...

你好亚伦,
<感谢您回复我的帖子。

您是否有任何示例C#代码实现了您为创建自定义
按钮所描述的过程?

再次感谢,
BC



Hello,

We are creating an Office add-in. We are able to
display the add-in successfully. However, we followed
a sample program, and it displays a FaceID = 1044 (which
is not the bitmap of the button we want to display). We
want to display our own custom bitmap.

How do we display our own custom bitmap instead
of the bitmap associated with FaceID = 1044?

TIA,
BC

解决方案

One of the many stupid things about Excel is the way you have to create your
own bitmap buttons:

1. Load your bitmap.
2. Replace all of the pixels that you want to be transparent with the
standard Windows control background colour (as configured in the current
theme).
3. Backup the clipboard (as long as it isn''t too big).
4. Copy the bitmap to the clipboard.
5. Paste the bitmap to the button.
6. Restore the clipboard.

Backing up and restoring the clipboard is optional, but it''s really annoying
to users when they copy some text, start Excel, and paste only to find that
some dumb plug-in has trashed the clipboard.

If you''re using Excel XP it''s slightly easier in that you can set properties
of the button to the image and image mask.

Regards,
Aaron Queenan.

"BC" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...

Hello,

We are creating an Office add-in. We are able to
display the add-in successfully. However, we followed
a sample program, and it displays a FaceID = 1044 (which
is not the bitmap of the button we want to display). We
want to display our own custom bitmap.

How do we display our own custom bitmap instead
of the bitmap associated with FaceID = 1044?

TIA,
BC



Hello Aaron,

Thank you for responding to my posting.

Do you have any sample C# code that implements
the process you described for creating a custom
button?

Thanks again,
BC


Hi BC,
here is my code (without backing up the clipboard, I haven''t tought
about that :) ). Now I have to make it :)

oButton = (Office.CommandBarButton)oBar.Controls.Add
(MsoControlType.msoControlButton,
Missing.Value, Missing.Value, 1, false);

Clipboard.SetDataObject(oButtonIcon);
// oButtonIcon is Drawing.Icon

mButton.PasteFace();
mButton.Style = MsoButtonStyle.msoButtonIconAndCaption;

Hmmm, yes Aaron is right, I have to implement Clipboard backup.

Hope that helps
Sunny

In article <08****************************@phx.gbl>,
an*******@discussions.microsoft.com says...

Hello Aaron,

Thank you for responding to my posting.

Do you have any sample C# code that implements
the process you described for creating a custom
button?

Thanks again,
BC



这篇关于Office加载项自定义位图按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆