[Mono-winforms-list] Handle being created when I don't expect

Rolf Bjarne Kvinge rolflists at ya.com
Fri Aug 10 12:23:12 EDT 2007



> -----Original Message-----
> From: Maser, Dan [mailto:Dan.Maser at inin.com]
> Sent: viernes, 10 de agosto de 2007 14:34
> To: Rolf Bjarne Kvinge; mono-winforms-list at lists.ximian.com
> Subject: RE: [Mono-winforms-list] Handle being created when I don't
> expect
> 
> 
>    That's the first time the HandleCreated event is fired, I have a
> MessageBox.Show in the first line of the HandleCreated handler and this
> is the first time I see it.  As such, how can I show you a call stack
> for the first time the handle is created if this is the first time the
> HandleCreated event is fired?
> 

I never rely on events for debugging :)
Try overriding CreateHandle and print a stack trace from there (remember to
call the base class as well).
You can also override WndProc and watch out for WM_CREATE (0x1) and
WM_DESTROY (0x2).

And just before doing:
form.MdiParent = theParent;

Do this:
Console.WriteLine (form.IsHandleCreated)
Which will tell you if the handle has already been created or not.

Rolf

>    I wonder if I should hack in some Console.WriteLine statements into
> the mono source and recompile to see?
> 
>    Dan
> 
> -----Original Message-----
> From: Rolf Bjarne Kvinge [mailto:rolflists at ya.com]
> Sent: Friday, August 10, 2007 6:23 AM
> To: Maser, Dan; mono-winforms-list at lists.ximian.com
> Subject: RE: [Mono-winforms-list] Handle being created when I don't
> expect
> 
> 
> 
> > -----Original Message-----
> > From: Maser, Dan [mailto:Dan.Maser at inin.com]
> > Sent: jueves, 09 de agosto de 2007 15:15
> > To: Rolf Bjarne Kvinge; mono-winforms-list at lists.ximian.com
> > Subject: RE: [Mono-winforms-list] Handle being created when I don't
> > expect
> >
> >
> >   Sure. I'm using the latest mono I built from the SVN source on
> > 08/07/2007.  The call stack with file/line info is really wide, so
> > I've attached it as a text file to this message.
> >
> 
> When setting MdiParent the handle is being *re*created, not created,
> and this is matching MS' behavior.
> 
> To know when the handle was created in the first place I'd need another
> stack trace :)
> 
> Rolf
> 
> >   Thanks!
> >
> > -----Original Message-----
> > From: Rolf Bjarne Kvinge [mailto:rolflists at ya.com]
> > Sent: Thursday, August 09, 2007 2:15 AM
> > To: Maser, Dan; mono-winforms-list at lists.ximian.com
> > Subject: RE: [Mono-winforms-list] Handle being created when I don't
> > expect
> >
> >
> >
> > >From: mono-winforms-list-bounces at lists.ximian.com
> > [mailto:mono-winforms-list-bounces at lists.ximian.com] On Behalf Of
> > Maser, Dan
> > >Sent: miércoles, 08 de agosto de 2007 23:49
> > >To: Maser, Dan; mono-winforms-list at lists.ximian.com
> > >Subject: Re: [Mono-winforms-list] Handle being created when I don't
> > >expect
> > >
> > >  Sorry, that got sent too early.  Here's more of the call stack
> this
> > time.
> >
> >
> > Could you execute with "mono --debug app.exe" so that you get line
> > numbers as well? And knowing which version of Winforms you're using
> > would also help
> > :)
> >
> > Rolf
> >
> > >_____________________________________________
> > >From:   Maser, Dan
> > >Sent:   Wednesday, August 08, 2007 4:39 PM
> > >To:     'mono-winforms-list at lists.ximian.com'
> > >Subject:        Handle being created when I don't expect
> >
> > >  I've got a situation with MDI forms where the behavior is
> different
> > >on MS
> > vs mono, but it's proving difficult to get a simple test project that
> > >reproduces it.  The problem is that in my app setting the
> > >Form.MdiParent is
> > causing that Form's handle to be created in mono when it doesn't on
> > >MS.NET.   And it doesn't happen for simple test programs on mono
> > >either;
> > with simple test programs setting the MdiParent property doesn't
> cause
> > the
> > >handle to be created.  I think it must be something about my real
> > >project
> > that causes this, but the program is so large it's difficult to tell
> > what that >might be.  Here's a partial call stack from the
> > Form.HandleCreated event.  Does this info give enough info to someone
> > to make some guesses about what >could cause the MdiParent property
> to
> > trigger the HandleCreated in some projects but not in others?
> > >  Thanks in advance for any ideas!
> > > Partial call stack:
> > >at MyChildForm.on_HandleCreated(System.Object sender,
> > >System.EventArgs
> > >e) at System.Windows.Forms.Control.OnHandleCreated(System.EventArgs
> > >e) at System.Windows.Forms.Form.OnHandleCreated(System.EventArgs e)
> > >at System.Windows.Forms.Control.WmCreate(Message ByRef m) at
> > >System.Windows.Forms.Control.WndProc(Message ByRef m) at
> > >System.Windows.Forms.ScrollableControl.WndProc(Message ByRef m) at
> > >System.Windows.Forms.ContainerControl.WndProc(Message ByRef m) at
> > >System.Windows.Forms.Form.WndProc(Message ByRef m) at
> > >System.Windows.Forms.Control+ControlWindowTarget.OnMessage(Message
> > >ByRef
> > m)
> > >at System.Windows.Forms.Control+ControlNativeWindow.WndProc(Message
> > >ByRef
> > m)
> > >at System.Windows.Forms.NativeWindow.WndProc(IntPtr hWnd, Msg msg,
> > >IntPtr
> > wParam, IntPtr lParam)
> > >at System.Windows.Forms.XplatUIX11.SendMessage(IntPtr hWnd, Msg msg,
> > >IntPtr
> > wParam, IntPtr lParam)
> > >at
> >
> System.Windows.Forms.XplatUIX11.CreateWindow(System.Windows.Forms.Crea
> > t
> > ePara
> > ms cp)
> > >at
> >
> System.Windows.Forms.XplatUI.CreateWindow(System.Windows.Forms.CreateP
> > a
> > rams
> > cp)
> > >at
> >
> System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.Cr
> > e
> > atePa
> > rams create_params)
> > >at System.Windows.Forms.Control.CreateHandle()
> > >at System.Windows.Forms.Form.CreateHandle()
> > >at System.Windows.Forms.Control.WmDestroy(Message ByRef m) at
> > >System.Windows.Forms.Control.WndProc(Message ByRef m) at
> > >System.Windows.Forms.ScrollableControl.WndProc(Message ByRef m) at
> > >System.Windows.Forms.ContainerControl.WndProc(Message ByRef m) at
> > >System.Windows.Forms.Form.WmDestroy(Message ByRef m) at
> > >System.Windows.Forms.Form.WndProc(Message ByRef m) at
> > >System.Windows.Forms.Control+ControlWindowTarget.OnMessage(Message
> > >ByRef
> > m)
> > >at System.Windows.Forms.Control+ControlNativeWindow.WndProc(Message
> > >ByRef
> > m)
> > >at System.Windows.Forms.NativeWindow.WndProc(IntPtr hWnd, Msg msg,
> > >IntPtr
> > wParam, IntPtr lParam)
> > >at System.Windows.Forms.XplatUIX11.SendMessage(IntPtr hWnd, Msg msg,
> > >IntPtr
> > wParam, IntPtr lParam)
> > >at System.Windows.Forms.XplatUIX11.DestroyWindow(IntPtr handle) at
> > >System.Windows.Forms.XplatUI.DestroyWindow(IntPtr handle) at
> > >System.Windows.Forms.NativeWindow.DestroyWindow()
> > >at System.Windows.Forms.Control.DestroyHandle()
> > >at System.Windows.Forms.Control.RecreateHandle()
> > >at System.Windows.Forms.Form.set_MdiParent(System.Windows.Forms.Form
> > >value)
> >
> > >....
> > >There's more, but this seems like the relevant part.
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.11/944 - Release Date:
> 09/08/2007 14:44




More information about the Mono-winforms-list mailing list