在 Access 2007 中使用 .png 作为自定义功能区图标
我想在 Access 2007 功能区中使用 .png 作为自定义图标。
以下是我到目前为止所做的尝试:
我能够将 .bmp 和 .jpg 作为自定义图像加载,而无需任何其他操作问题。我可以加载 .gif,但它似乎没有保留透明度。我根本无法加载 .png。我真的很想使用 .png 来利用其他格式所不具备的 alpha 混合功能。
我发现了一个类似的问题,但这只是处理加载任何类型的自定义图标。我对 .png 特别感兴趣。 Albert Kallal 对这个问题有一个答案,链接到他编写的一个类模块,该模块似乎完全符合我的要求:
meRib("Button1").Picture = "HappyFace.png"
不幸的是,该答案中的链接已失效。
我还发现了这个网站,它提供了完整的460行模块的下载数十个 API 调用以获得对透明图标的支持。在走这条路之前,我想问问这里的专家是否知道更好的方法。
我知道 .png 是相当新颖的,但我希望 Office 开发人员能够对该格式提供一些本机支持。
I'd like to use a .png as a custom icon in the Access 2007 ribbon.
Here's what I've tried so far:
I am able to load .bmp's and .jpg's as custom images without any problem. I can load .gif's, but it doesn't seem to preserve the transparency. I can't load .png's at all. I'd really like to use .png's to take advantage of the alpha-blending that is not available in the other formats.
I found a similar question on SO, but that just deals with loading custom icons of any kind. I am specifically interested in .png's. There is an answer from Albert Kallal to that question that links to a class module he had written that appears to do exactly what I want:
meRib("Button1").Picture = "HappyFace.png"
Unfortunately, the link in that answer is dead.
I also found this site which offers a download of a 460 line module full of dozens of API calls to get support for transparent icons. Before I go that route I wanted to ask the experts here if they know of a better way.
I know .png is pretty new-fangled and all, but I'm hoping the Office development folks slipped in some native support for the format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我目前正在使用的。 Albert Kallal 为 Access 2007 功能区编程提供了更全面的解决方案,它可以做更多的事情不仅仅是加载 .png 的。我还没有使用它,但值得一试。
对于那些感兴趣的人,这是我正在使用的代码。我相信这非常接近 .png 支持所需的最低要求。如果这里有任何无关的内容,请告诉我,我会更新我的答案。
将以下内容添加到标准代码模块:
然后,如果您还没有标准代码模块,请添加一个名为
USysRibbons
的表。 (注意:Access 将此表视为系统表,因此您必须通过转至 Access 选项 --> 当前数据库 --> 导航选项来在导航窗格中显示这些表,并确保“显示系统对象”为选中。)然后将这些属性添加到您的控件标记中:getImage="GetRibbonImage" tag="Acq.png"
例如:
Here is what I am currently using. Albert Kallal has a more full-fledged solution for Access 2007 ribbon programming that does a lot more than just load .png's. I am not using it yet, but it's worth checking out.
For those who are interested, here is the code that I am using. I believe this is pretty close to the minimum required for .png support. If there's anything extraneous here, let me know and I'll update my answer.
Add the following to a standard code module:
Then, if you don't already have one, add a table named
USysRibbons
. (NOTE: Access treats this table as a system table, so you'll have to show those in your nav pane by going to Access Options --> Current Database --> Navigation Options and make sure 'Show System Objects' is checked.) Then add these attributes to your control tag:getImage="GetRibbonImage" tag="Acq.png"
For example: