Skip to content

Commit

Permalink
Fix IFont and IPicture definitions (#2736)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughbe authored and RussKie committed Jan 19, 2020
1 parent e69016e commit 0daa37a
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static partial class Ole32
[ComImport]
[Guid("BEF6E002-A874-101A-8BBA-00AA00300CAB")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IFont
public unsafe interface IFont
{
string Name { get; set; }
long Size { get; set; }
Expand All @@ -37,13 +37,21 @@ HRESULT SetRatio(
int cyLogical,
int cyHimetric);

[PreserveSig]
HRESULT QueryTextMetrics(
Gdi32.TEXTMETRICW* pTM);

[PreserveSig]
HRESULT AddRefHfont(
IntPtr hFont);

[PreserveSig]
HRESULT ReleaseHfont(
IntPtr hFont);

[PreserveSig]
HRESULT SetHdc(
IntPtr hDC);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ internal static partial class Interop
{
internal static partial class Ole32
{
[ComImport()]
[ComImport]
[Guid("7BF80980-BF32-101A-8BBB-00AA00300CAB")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPicture
{
uint Handle { get; }
/// <remarks>
/// IPicture handles are sign extended on 64 bit devices. To preserve
/// the sign, handles should be represented as ints, not uints.
/// </remarks>
int Handle { get; }

uint hPal { get; }
/// <remarks>
/// HPALETTE handles are sign extended on 64 bit devices. To preserve
/// the sign, handles should be represented as ints, not uints.
/// </remarks>
int hPal { get; }

/// <remarks>
/// This is actually <see cref="PICTYPE"/>, but we can't describe it as such.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ internal static partial class Interop
{
internal static partial class Ole32
{
[ComImport()]
[ComImport]
[Guid("7BF80981-BF32-101A-8BBB-00AA00300CAB")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
internal unsafe interface IPictureDisp
{
uint Handle { get; }
/// <remarks>
/// IPicture handles are sign extended on 64 bit devices. To preserve
/// the sign, handles should be represented as ints, not uints.
/// </remarks>
int Handle { get; }

uint hPal { get; }
/// <remarks>
/// HPALETTE handles are sign extended on 64 bit devices. To preserve
/// the sign, handles should be represented as ints, not uints.
/// </remarks>
int hPal { get; }

/// <remarks>
/// This is actually <see cref="PICTYPE"/>, but we can't describe it as such.
Expand Down
8 changes: 4 additions & 4 deletions src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4027,7 +4027,7 @@ protected static Image GetPictureFromIPicture(object picture)
return null;
}

uint hPal = default;
int hPal = default;
Ole32.IPicture pict = (Ole32.IPicture)picture;
Ole32.PICTYPE type = (Ole32.PICTYPE)pict.Type;
if (type == Ole32.PICTYPE.BITMAP)
Expand Down Expand Up @@ -4055,7 +4055,7 @@ protected unsafe static Image GetPictureFromIPictureDisp(object picture)
return null;
}

uint hPal = default;
int hPal = default;
Ole32.IPictureDisp pict = (Ole32.IPictureDisp)picture;
Ole32.PICTYPE type = (Ole32.PICTYPE)pict.Type;
if (type == Ole32.PICTYPE.BITMAP)
Expand All @@ -4075,9 +4075,9 @@ protected unsafe static Image GetPictureFromIPictureDisp(object picture)
}

private static Image GetPictureFromParams(
uint handle,
int handle,
Ole32.PICTYPE type,
uint paletteHandle,
int paletteHandle,
int width,
int height)
{
Expand Down
Loading

0 comments on commit 0daa37a

Please sign in to comment.