Toolbar Icon problem

G

gurry

Hi,

I'm trying to add an icon to a commandbar that I'm creating within
Visio 2007. Although my icon does appear, it does not have a
transparent background, which is what I would like. The background
shows up as blue instead and the icon therefore is hardly discernible
as the whole thing looks like a blue square.

Based on what I've read somewhere, to add the icon to toolbar I'm
using the following code.

First I've created an ActiveXControlWrapper class derived from
ActiveXHost:

Public Class ActiveXCtrlWrapper
Inherits System.Windows.Forms.AxHost

Public Sub New()
MyBase.New("{DC61E11F-C8DD-4e35-91B3-1BEEC0D6E308}")
End Sub

Public Function GetIPictureDisp(ByVal image As
System.Drawing.Image) As stdole.IPictureDisp
Dim picture As stdole.IPictureDisp
picture = CType(GetIPictureDispFromPicture(image),
stdole.IPictureDisp)
Return picture
End Function

Public Function GetIPictureDisp(ByVal icon As System.Drawing.Icon)
As stdole.IPictureDisp
Dim image As New System.IO.MemoryStream()
icon.Save(image)
Return GetIPictureDisp(System.Drawing.Image.FromStream(image))
End Function
End Class


Then to add the icon I've written the following code, where
"StartIcon.ico" is the name of the icon file and "startButton" is the
name of the button to which the icon is to be added:


Dim activeXWrapper As New ActiveXCtrlWrapper()
Dim icon As System.Drawing.Icon
Dim picture As stdole.IPictureDisp

icon = My.Resources.Icons.StartIcon
picture = activeXWrapper.GetIPictureDisp(icon)
startButton.Picture = picture
startButton.Mask = picture

I'm using VB.Net on Visual Studio 2005 to write this code.

Kindly help me resolve this transparency problem.

Thanks.
Gurinder
 
J

jeeban

hi gury . same problem i have faced also. i didnt get the proper
result but it will apper a little bit clear...
i paint the icon and the masking image properly pixel wise . and both
image should be same. the icon display also depends on the masking
image also.
so you will get a little bit clear . if u got the perfect solution plz
let me know.
 

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