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

[WIP] Remove GetWindowLong and SetWindowLong from UnsafeNativeMethods.cs an… #2447

Open
wants to merge 1 commit into
base: master
from

Conversation

@gpetrou
Copy link
Contributor

gpetrou commented Nov 28, 2019

…d GWL constants from NativeMethods.cs

Proposed changes

  • Remove GetWindowLong and SetWindowLong from UnsafeNativeMethods.cs
  • Remove GWL constants from NativeMethods.cs
Microsoft Reviewers: Open in CodeFlow
@gpetrou gpetrou requested a review from dotnet/dotnet-winforms as a code owner Nov 28, 2019
@gpetrou gpetrou force-pushed the gpetrou:WindowLong branch 2 times, most recently from 0c6abcc to 74ddd43 Nov 28, 2019
…d GWL constants from NativeMethods.cs
@gpetrou gpetrou force-pushed the gpetrou:WindowLong branch from 74ddd43 to 9988077 Nov 28, 2019
@gpetrou gpetrou changed the title Remove GetWindowLong and SetWindowLong from UnsafeNativeMethods.cs an… [WIP] Remove GetWindowLong and SetWindowLong from UnsafeNativeMethods.cs an… Nov 28, 2019
@@ -2449,7 +2449,7 @@ public void ShowDropDown(Control parent)
{
try
{
UnsafeNativeMethods.SetWindowLong(new HandleRef(this, Handle), NativeMethods.GWL_HWNDPARENT, new HandleRef(parent, parent.Handle));
User32.SetWindowLong(new HandleRef(this, Handle), User32.GWL.HWNDPARENT, new HandleRef(parent, parent.Handle));

This comment has been minimized.

Copy link
@hughbe

hughbe Nov 28, 2019

Contributor

nit: use IHandle overloads

@@ -2463,8 +2463,7 @@ public void ShowDropDown(Control parent)
}
finally
{

UnsafeNativeMethods.SetWindowLong(new HandleRef(this, Handle), NativeMethods.GWL_HWNDPARENT, new HandleRef(null, IntPtr.Zero));
User32.SetWindowLong(new HandleRef(this, Handle), User32.GWL.HWNDPARENT, new HandleRef(null, IntPtr.Zero));

This comment has been minimized.

Copy link
@hughbe

hughbe Nov 28, 2019

Contributor
  • get rid of new HandleRef(null, IntPtr.Zero) and turn into IntPtr.Zero
  • use IHandle overload

i.e. -> User32.SetWindowLong(this, User32.GWL.HWNDPARENT, IntPtr.Zero);

@@ -714,7 +714,7 @@ internal void ShowDesignerActionPanel(IComponent relatedComponent, DesignerActio
{
Debug.WriteLineIf(s_designeActionPanelTraceSwitch.TraceVerbose, "Assigning owner to mainParentWindow");
Debug.WriteLineIf(DesignerActionUI.DropDownVisibilityDebug.TraceVerbose, "Assigning owner to mainParentWindow");
UnsafeNativeMethods.SetWindowLong(new HandleRef(designerActionHost, designerActionHost.Handle), NativeMethods.GWL_HWNDPARENT, new HandleRef(_mainParentWindow, _mainParentWindow.Handle));
User32.SetWindowLong(new HandleRef(designerActionHost, designerActionHost.Handle), User32.GWL.HWNDPARENT, new HandleRef(_mainParentWindow, _mainParentWindow.Handle));

This comment has been minimized.

Copy link
@hughbe

hughbe Nov 28, 2019

Contributor

ditto regarding all the overloads where we can use IHandle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.