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", CharSet:=CharSet.Ansi, ExactSpelling:=True, PreserveSig:=True)>
Private Function OleCreatePictureIndirect(ByRef pictdesc As PICTDESC, ByRef riid As Guid, fOwn As Boolean, <MarshalAs(UnmanagedType.IDispatch)> ByRef lplpvObj As Object) As Integer
End Function
User-Defined Types:
<StructLayout(LayoutKind.Sequential)>
Friend Structure PICTDESC
Public SizeOfStruct As Integer
Public PicType As Integer
Public Hbitmap As IntPtr
Public Hpal As IntPtr
Public Padding As Integer
Public Sub New(hBmp As IntPtr)
SizeOfStruct = Marshal.SizeOf(GetType(PICTDESC))
PicType = 1
Hbitmap = hBmp
Hpal = IntPtr.Zero
Padding = 0
End Sub
End Structure
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:
<DllImport("OleAut32.dll", EntryPoint:="OleCreatePictureIndirect", CharSet:=CharSet.Ansi, ExactSpelling:=True, PreserveSig:=True)>
Private Function OleCreatePictureIndirect(ByRef pictdesc As PICTDESC, ByRef riid As Guid, fOwn As Boolean, <MarshalAs(UnmanagedType.IDispatch)> ByRef lplpvObj As Object) As Integer
End Function
<StructLayout(LayoutKind.Sequential)>
Friend Structure PICTDESC
Public SizeOfStruct As Integer
Public PicType As Integer
Public Hbitmap As IntPtr
Public Hpal As IntPtr
Public Padding As Integer
Public Sub New(hBmp As IntPtr)
SizeOfStruct = Marshal.SizeOf(GetType(PICTDESC))
PicType = 1
Hbitmap = hBmp
Hpal = IntPtr.Zero
Padding = 0
End Sub
End Structure
Public Function ImageToPictureDisp(Input As Bitmap) As stdole.IPictureDisp
Dim PictDesc As PICTDESC = New PICTDESC(Input.GetHbitmap())
Dim Pic As Object = Nothing
OleCreatePictureIndirect(PictDesc, GetType(stdole.IPictureDisp).GUID, True, Pic)
Return CType(Pic, stdole.IPictureDisp)
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).