+2007-07-31 Rolf Bjarne Kvinge <RKvinge@novell.com>
+
+ * Control.cs: We need to reset the is_created flags when the handle is
+ destroyed. Fixes #82187.
+ * XplatUIWin32.cs: In GetWindowRect don't offset screen coordinates to
+ client coordinates if the window doesn't have a parent.
+ Win32GetParent returns the parent or the owner, and for top-level
+ windows with no parent (but with an owner) we were calculating the
+ location from the location of the owner.
+ * Form.cs: Remove incorrect fix for #82187. Don't raise OnLoad if the
+ form has been disposed.
+ * MdiClient.cs: Add a null-check.
+
2007-07-30 Jonathan Pobst <monkey@jpobst.com>
* TextBoxBase.cs: TextBoxBase reports itself at AutoSize, but doesn't
}
if (IsHandleCreated) {
- // All CommonDialogs assume the form is still alive after a ShowDialog,
- // so don't destroy the handle in this case. Fix for #82187.
- if (!(this is CommonDialog.DialogForm)) {
- DestroyHandle ();
- }
+ DestroyHandle ();
}
if (DialogResult == DialogResult.None) {
AutoScale = false;
}
- OnLoad (e);
-
+ if (!IsDisposed) {
+ OnLoad (e);
+ }
+
if (!IsMdiChild && !IsDisposed) {
switch (StartPosition) {
case FormStartPosition.CenterScreen:
Last = 32651
}
+ private enum AncestorType {
+ GA_PARENT = 1,
+ GA_ROOT = 2,
+ GA_ROOTOWNER = 3
+ }
+
[Flags]
private enum WindowLong {
GWL_WNDPROC = -4,
pt.x=rect.left;
pt.y=rect.top;
- parent = Win32GetParent(handle);
- Win32ScreenToClient(parent, ref pt);
+ parent = Win32GetAncestor (handle, AncestorType.GA_PARENT);
+ if (parent != IntPtr.Zero && parent != Win32GetDesktopWindow ())
+ Win32ScreenToClient(parent, ref pt);
x = pt.x;
y = pt.y;
[DllImport ("user32.dll", EntryPoint="ClientToScreen", CallingConvention=CallingConvention.StdCall)]
private extern static bool Win32ClientToScreen(IntPtr hWnd, ref POINT pt);
+ // This function returns the parent OR THE OWNER!
+ // Use GetAncestor to only get the parent.
[DllImport ("user32.dll", EntryPoint="GetParent", CallingConvention=CallingConvention.StdCall)]
private extern static IntPtr Win32GetParent(IntPtr hWnd);
+ [DllImport ("user32.dll", EntryPoint = "GetAncestor", CallingConvention = CallingConvention.StdCall)]
+ private extern static IntPtr Win32GetAncestor (IntPtr hWnd, AncestorType flags);
+
[DllImport ("user32.dll", EntryPoint="SetActiveWindow", CallingConvention=CallingConvention.StdCall)]
private extern static IntPtr Win32SetActiveWindow(IntPtr hWnd);