Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IFont and IPicture definitions #2736

Merged
merged 1 commit into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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