Skip to content

Commit

Permalink
Convert DOCHOSTUIINFO to CsWin32 (#9915)
Browse files Browse the repository at this point in the history
* Convert DOCHOSTUIINFO to CsWin32

* make static to fix build error
  • Loading branch information
elachlan authored Sep 15, 2023
1 parent 549eb61 commit 16ca3e1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

internal partial class Interop
{
internal partial class Mshtml
internal static partial class Mshtml
{
[ComImport]
[Guid("3050f610-98b5-11cf-bb82-00aa00bdce0b")]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Windows.Win32.System.Ole;
using MsHtml = Windows.Win32.Web.MsHtml;

internal partial class Interop
{
Expand All @@ -24,7 +25,7 @@ HRESULT ShowContextMenu(

[PreserveSig]
HRESULT GetHostInfo(
DOCHOSTUIINFO* pInfo);
MsHtml.DOCHOSTUIINFO* pInfo);

[PreserveSig]
HRESULT ShowUI(
Expand Down
1 change: 1 addition & 0 deletions src/System.Windows.Forms.Primitives/src/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ DispatchMessage
DISPID_*
DISPPARAMS
DLGC_*
DOCHOSTUIINFO
DoDragDrop
DPI_AWARENESS_CONTEXT_*
DPI_HOSTING_BEHAVIOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Drawing;
using Windows.Win32.System.Ole;
using MsHtml = Windows.Win32.Web.MsHtml;
using static Interop.Mshtml;
using Ole = Windows.Win32.System.Ole;
using ComTypes = System.Runtime.InteropServices.ComTypes;
Expand Down Expand Up @@ -55,7 +56,7 @@ unsafe HRESULT IDocHostUIHandler.ShowContextMenu(uint dwID, Point* pt, object pc
return HRESULT.S_OK;
}

unsafe HRESULT IDocHostUIHandler.GetHostInfo(DOCHOSTUIINFO* pInfo)
unsafe HRESULT IDocHostUIHandler.GetHostInfo(MsHtml.DOCHOSTUIINFO* pInfo)
{
if (pInfo is null)
{
Expand All @@ -64,26 +65,26 @@ unsafe HRESULT IDocHostUIHandler.GetHostInfo(DOCHOSTUIINFO* pInfo)

WebBrowser wb = (WebBrowser)Host;

pInfo->dwDoubleClick = DOCHOSTUIDBLCLK.DEFAULT;
pInfo->dwFlags = DOCHOSTUIFLAG.NO3DOUTERBORDER |
DOCHOSTUIFLAG.DISABLE_SCRIPT_INACTIVE;
pInfo->dwDoubleClick = MsHtml.DOCHOSTUIDBLCLK.DOCHOSTUIDBLCLK_DEFAULT;
pInfo->dwFlags = MsHtml.DOCHOSTUIFLAG.DOCHOSTUIFLAG_NO3DOUTERBORDER |
MsHtml.DOCHOSTUIFLAG.DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE;

if (wb.ScrollBarsEnabled)
{
pInfo->dwFlags |= DOCHOSTUIFLAG.FLAT_SCROLLBAR;
pInfo->dwFlags |= MsHtml.DOCHOSTUIFLAG.DOCHOSTUIFLAG_FLAT_SCROLLBAR;
}
else
{
pInfo->dwFlags |= DOCHOSTUIFLAG.SCROLL_NO;
pInfo->dwFlags |= MsHtml.DOCHOSTUIFLAG.DOCHOSTUIFLAG_SCROLL_NO;
}

if (Application.RenderWithVisualStyles)
{
pInfo->dwFlags |= DOCHOSTUIFLAG.THEME;
pInfo->dwFlags |= MsHtml.DOCHOSTUIFLAG.DOCHOSTUIFLAG_THEME;
}
else
{
pInfo->dwFlags |= DOCHOSTUIFLAG.NOTHEME;
pInfo->dwFlags |= MsHtml.DOCHOSTUIFLAG.DOCHOSTUIFLAG_NOTHEME;
}

return HRESULT.S_OK;
Expand Down

0 comments on commit 16ca3e1

Please sign in to comment.