Force WaitCursor to parent form of modal form

I have a form that displays a loading animation and the BackgroundWorker does the job and closes when the job is done. I am displaying 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 a background worker in OnShown, and when the background worker ends, it closes.

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

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

Any way to force this Cursor or even set the entire application cursor?

EDIT: I also tried to insert the change into the Cursor before and after the ShowDialog line of code in the parent. It still didn't work. I'd rather have LoadingPopup control the cursor anyway for reuse.

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

+3


source to share


1 answer


You tried:



Mouse.OverrideCursor = Cursors.Wait;

      

0


source







All Articles