ShowDialog() freezes

  • Thread starter Thread starter Max Christian
  • Start date Start date
M

Max Christian

If I show a dialog box using ShowDialog(), it appears but none of the
controls are functional -- can't even enter text into textboxes. If I
just change the ShowDialog() to a Show(), everything works fine
(except it isn't modal).

Any ideas out there? Both the parent and child forms are full-screen
windows with no title bar. The parent form was instantiated with a
call to Application.Run(New theParentForm).

Any suggestions greatly appreciated. I'm amazed how much trouble I've
had trying to display a modal dialog in compact .NET.

Thank you,

Max Christian
 
Hi Max,

Are you possibly invoking ShowDialog in a different thread from the GUI
(e.g., as a result of a low-level event)? This will often cause the sort
of behavior you're seeing. If this is the case, try using the
Control.Invoke method.

Ryan Chapman
Software Development Engineer
NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Are you possibly invoking ShowDialog in a different thread from the GUI
(e.g., as a result of a low-level event)? This will often cause the sort
of behavior you're seeing. If this is the case, try using the
Control.Invoke method.

I've found that the problem goes away if I call ShowDialog() from the
Click event rather than the MouseDown event. I do need to use the
MouseDown event though so I'm off to find out about Control.Invoke.

Many thanks

Max Christian
 
Hi Max,

I've managed to reproduce the problem and I'm looking for a work-around.
It might help if I knew why you needed to do this in MouseDown rather than
Click?

Thanks,

Ryan

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Max,

We've put together a workaround for now. In the form on which you are
invoking ShowDialog(), add this override:

protected override void OnLoad(EventArgs e)
{
this.Capture = true;
base.OnLoad( e );
}

Let me know if this helps.

Ryan

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Max,

We've put together a workaround for now. In the form on which you are
invoking ShowDialog(), add this override:

Let me know if this helps.

Ryan

I (think I) need to invoke ShowDialog from MouseDown rather than Click
because I need to know where the user clicked on the control and
respond appropriately, sometimes with a dialog, other times not.

My own workaround was to set global variables X,Y in the MouseDown
event and then show the dialog from the Click event (not pretty).
I've tried your more elegant approach and it Works For Me. Do I need
to worry about this breaking in a future .NET release?

Many thanks,

Max Christian
 
Hi Max,

I know of no reason why this should cause problems in the future. The bug
we have is that the Capture property isn't getting set properly, so any
future fix shouldn't collide with what you've done.

Thanks,

Ryan

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Max,

I know of no reason why this should cause problems in the future. The bug
we have is that the Capture property isn't getting set properly, so any
future fix shouldn't collide with what you've done.

Oh dear -- I've found the fix only seems to work for the first dialog
box shown each time the program runs. After that it freezes again,
although text boxes work, buttons and combo boxes don't.

Can you help? I'm really stuck now.

Max Christian
 
Hi Max,

New work-around--add this to your main form:

Private Sub frmPlanMakerPocket_LostFocus(ByVal sender As Object, ByVal
e As System.EventArgs) Handles MyBase.LostFocus
If ((Not Me.Focused) And Me.Capture) Then
Me.Capture = False
End If
End Sub

The problem is that the compact framework is not disabling the Capture
property for the underlying form when a new form is shown in MouseDown.
We're working on a fix, but there's no saying when it might be available.
I tested this work-around with your code and it worked...

Good luck!

Ryan

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top