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

ShowWindow has wrong P/Invoke signature #68

Closed
Ron2 opened this issue Oct 2, 2012 · 1 comment
Closed

ShowWindow has wrong P/Invoke signature #68

Ron2 opened this issue Oct 2, 2012 · 1 comment

Comments

@Ron2
Copy link

Ron2 commented Oct 2, 2012

In WeifenLuo.WinFormsUI.Docking.NativeMethods, there's this DllImport:

    [DllImport("User32.dll", CharSet=CharSet.Auto)]
    public static extern int ShowWindow(IntPtr hWnd, short cmdShow);

It should use an 'int' instead of a 'short':

    [DllImport("User32.dll", CharSet=CharSet.Auto)]
    public static extern int ShowWindow(IntPtr hWnd, int cmdShow);

Here are some references of the signature of this Win32 function:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx
http://www.pinvoke.net/default.aspx/user32.showwindow

We discovered that in Visual Studio 2010, with .Net Framework 4 and AnyCPU platform (on a 64-bit computer) that the Visible property on DragForm was not getting set to 'true', which would prevent those docking indicators from showing and the dragged window from showing. The reason this was happening is that the Win32.ShowWindowStyles.SW_SHOWNOACTIVATE constant of 4 is being put in just the low 16-bits of a register, but there's potentially garbage in the upper 16 bits. We think that on the native side, the full 32 bits is read from the register which causes the flags value to be mangled.

This sounds like the cause of these bugs, too:
#46
#48

@lextm
Copy link
Member

lextm commented Oct 2, 2012

Thanks for sharing the details. Your investigation is very helpful and the root cause has been found.

DPS no longer uses ShowWindow call, so we won't need to fix the PInvoke signature now.

@lextm lextm closed this as completed Oct 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants