Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than oleaut32, prefix the name with the module name and a period.
OleCreatePictureIndirect (oleaut32)
.
Summary:
VB Signature:
<DllImport("OleAut32.dll", EntryPoint:="OleCreatePictureIndirect", ExactSpelling:=True, PreserveSig:=False)>
Private Shared Function OleCreatePictureIndirect(<MarshalAs(UnmanagedType.AsAny)>picdesc As Object, ByRef iid As Guid, <MarshalAs(UnmanagedType.Bool)>fOwn As Boolean) As stdole.IPictureDisp
End Function
User-Defined Types:
Private NotInheritable Class PICTDESC
Private Sub New()
End Sub
Private Enum PicType As Short
Uninitialized = -1
None = 0
Bitmap = 1
MetaFile = 2
Icon = 3
EnhMetaFile = 4
End Enum
<StructLayout(LayoutKind.Sequential)>
Public Structure Bitmap
Private ReadOnly SizeOfStruct As Integer
Private ReadOnly PicType As Integer
Private ReadOnly BitmapHandle As IntPtr
Private ReadOnly PaletteHandle As IntPtr
Private ReadOnly Padding As Integer
Public Sub New(input As Drawing.Bitmap)
SizeOfStruct = Marshal.SizeOf(GetType(PICTDESC.Bitmap))
PicType = PICTDESC.PicType.Bitmap
BitmapHandle = input.GetHbitmap()
PaletteHandle = IntPtr.Zero
Padding = 0
End Sub
End Structure
<StructLayout(LayoutKind.Sequential)>
Public Structure Icon
Private ReadOnly SizeOfStruct As Integer
Private ReadOnly PicType As Integer
Private ReadOnly IconHandle As IntPtr
Private ReadOnly Padding As Integer
Private ReadOnly MorePadding As Integer
Public Sub New(input As Drawing.Icon)
SizeOfStruct = Marshal.SizeOf(GetType(PICTDESC.Icon))
picType = PICTDESC.PicType.Icon
IconHandle = input.Handle
Padding = 0
MorePadding = 0
End Sub
End Structure
End Class
None.
Alternative Managed API:
Do you know one? Please contribute it!
Notes:
Though this function is undoubtedly useful for other purposes, I have only seen it used to convert managed image types to the type required for use in custom Office ribbons.
Tips & Tricks:
Please add some!
Sample Code:
Public Function ConvertToIPictureDisplay(input As Bitmap) As stdole.IPictureDisp
Dim bitmap As PICTDESC.Bitmap = New PICTDESC.Bitmap(input)
Return OleCreatePictureIndirect(bitmap, GetType(stdole.IPictureDisp).GUID, True)
End Function
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).