W
Wayne Bradney
Simple, really. I have C# code in a Windows Form, thus:
int rc;
rc = Win32API.SetParent(ctrl.Handle, new
IntPtr(Win32API.GetDesktopWindow()));
rc = Win32API.GetWindowLong(ctrl.Handle, Win32API.GWL_EXSTYLE);
if (rc == 0) {
System.Console.WriteLine(Marshal.GetLastWin32Error());
}
where ctrl is a control on the form (it doesn't seem to matter what
type of control), and Win32API has all the relevant imports:
[DllImport("user32.dll")]
public static extern int SetParent(IntPtr childHwnd, IntPtr
parentHwnd);
[DllImport("user32.dll")]
public static extern int GetDesktopWindow();
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
I'm doing this as a precursor to making the control a custom drop-down
of sorts (subsequent lines will set WS_EX_TOOLWINDOW, HWND_TOPMOST,
etc. and subclass the GWL_WNDPROC for mouse handling etc.), but I
don't even get that far. In all cases GetWindowLong returns 0, and the
Win32Error is 127 (which decodes as 'The specified procedure could not
be found.')
Anyone successfully done this from .NET?
int rc;
rc = Win32API.SetParent(ctrl.Handle, new
IntPtr(Win32API.GetDesktopWindow()));
rc = Win32API.GetWindowLong(ctrl.Handle, Win32API.GWL_EXSTYLE);
if (rc == 0) {
System.Console.WriteLine(Marshal.GetLastWin32Error());
}
where ctrl is a control on the form (it doesn't seem to matter what
type of control), and Win32API has all the relevant imports:
[DllImport("user32.dll")]
public static extern int SetParent(IntPtr childHwnd, IntPtr
parentHwnd);
[DllImport("user32.dll")]
public static extern int GetDesktopWindow();
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
I'm doing this as a precursor to making the control a custom drop-down
of sorts (subsequent lines will set WS_EX_TOOLWINDOW, HWND_TOPMOST,
etc. and subclass the GWL_WNDPROC for mouse handling etc.), but I
don't even get that far. In all cases GetWindowLong returns 0, and the
Win32Error is 127 (which decodes as 'The specified procedure could not
be found.')
Anyone successfully done this from .NET?