Skip to content

Commit 560ae7a

Browse files
authored
Create GEN_CreateButtonImage
1 parent 7419164 commit 560ae7a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Snippets/GEN_CreateButtonImage

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#Region "Image Converter"
2+
' Class used to convert bitmaps and icons between their .Net native types
3+
' and an IPictureDisp object which is what the Inventor API requires.
4+
5+
<Global.System.Security.Permissions.PermissionSetAttribute _
6+
(Global.System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")>
7+
Public Class ConvertImage
8+
Inherits System.Windows.Forms.AxHost
9+
Public Sub New()
10+
MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B32")
11+
End Sub
12+
13+
Public Shared Function ConvertImageToIPictureDisp(ByVal Image As System.Drawing.Image) As stdole.IPictureDisp
14+
Try
15+
Return (GetIPictureFromPicture(Image))
16+
Catch ex As Exception
17+
Return Nothing
18+
End Try
19+
End Function
20+
Public Shared Function ConvertIconToIPictureDisp(ByVal Icon As System.Drawing.Icon) As stdole.IPictureDisp
21+
Try
22+
Return (GetIPictureFromPicture(Icon.ToBitmap)) ' Not sure if this will work correctly
23+
Catch ex As Exception
24+
Return Nothing
25+
End Try
26+
End Function
27+
28+
Public Shared Function ConvertIPictureDispToImage(ByVal IPict As stdole.IPictureDisp) As System.Drawing.Image
29+
Try
30+
Return (GetPictureFromIPictureDisp(IPict))
31+
Catch ex As Exception
32+
Return Nothing
33+
End Try
34+
End Function
35+
End Class
36+
#End Region

0 commit comments

Comments
 (0)