Forzar WaitCursor al formulario principal de un formulario modal

I have a Form which displays a Loading animation while a BackgroundWorker is doing work, and closes when the work is complete. I show it with the following code:

using (BackgroundWorker bw = new BackgroundWorker())
using (LoadingPopup loadingPopup = new LoadingPopup(bw))
{
    bw.DoWork += delegate
    {
        DoMyWork();
    };

    loadingPopup.ShowDialog(this);
}

My LoadingPopup form starts the background worker in OnShown, and when the background worker finishes it closes itself.

I want to have a WaitCursor displayed if the user hovers over any part of the parent form or the child form.

I've tried adding code to the LoadingPopup OnShown event to set the Parent.Cursor, Owner.Cursor, this.Cursor, and Cursor.Current to WaitCursor, then setting them back to Cursor.Default in the OnClosed event. But when I hover over the parent form I always get a Default cursor.

Any way to force this Cursor or even set an application-wide cursor?

EDIT: I have also tried inserting the change to the Cursor before and after the ShowDialog line of code in the parent. It still did not work. I would prefer that the LoadingPopup manage the cursor anyway for reusability.

I also tried setting the UseWaitCursor property to true on both the child form and the parent form and it had the same result.

preguntado el 09 de marzo de 12 a las 16:03

1 Respuestas

Has probado:

Mouse.OverrideCursor = Cursors.Wait;

respondido 09 mar '12, 17:03

This is using Windows Forms, not WPF. - Trevor Elliott

Yep, sorry. I forgot that was WPF Only. - matt burland

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.