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
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