none
this.Refresh() not working

    Question

  • Hello,

    I have a form that pops up as a notification in the bottom right corner of the screen. The form contains 2 labels and 1 button, while the two labels appear correctly the button does not. The button is just a white box, you can use it but it never gets painted.

    The button's paint even is triggered as soon as it is within the screen area.

    this.Refresh() doesn't refresh the form.
    Application.DoEvents() doesn't allow the button to be rendered.

    This code works fine on my PC but not on any other.


    Code Block
    void RaiseNotification()
            {
                bool Finished = false;
                int i = 10;
                do
                {
                    UpdateTop(this.Top - i);
                    if (this.Top <= (Screen.PrimaryScreen.WorkingArea.Bottom - this.Height))
                    {
                        Finished = true;
                    }
                    System.Threading.Thread.Sleep(50);
                } while (!Finished);
                RefreshForm();
            }
            void RefreshForm()
            {
                if (this.InvokeRequired)
                {
                    d_DoSomething d = new d_DoSomething(RefreshForm);
                    this.Invoke(d);
                }
                else
                {
                    Application.DoEvents();
                    this.Refresh();
                    Application.DoEvents();
                }
            }
            void UpdateTop(object NewTop)
            {
                if (this.InvokeRequired)
                {
                    d_UpdateTop d = new d_UpdateTop(UpdateTop);
                    this.Invoke(d, (object)NewTop);
                }
                else
                {
                    this.Top = (int)NewTop;
                }
            }

     

     

    Wednesday, December 19, 2007 3:25 PM

All replies

  • PUt the refreshform call within the do-loop of your first function.

    And make sure it hits that break point...

     

    • Proposed as answer by foxjazz2 Friday, January 16, 2009 3:48 PM
    • Unproposed as answer by Luke_UK Friday, July 23, 2010 3:46 PM
    Wednesday, December 19, 2007 5:04 PM