.NET winforms redraw problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SEngel
    New Member
    • Mar 2008
    • 13

    .NET winforms redraw problem

    I am using .net 2.0 and working in VS2005.
    I've noticed following unpleasant effect in the standard Form class
    behaviour: when the Form is hovered by some other window, it is being redrawn very slowly.

    Here is the example. I have taken empty form, put there some standard controls:
    http://www.ljplus.ru/img4/b/o/boshetunmaj/Redraw2.jpg

    My hardware conf is: p4 3200, 2 Gb ram, GeForce 5200.
  • SEngel
    New Member
    • Mar 2008
    • 13

    #2
    I have found that controls redraw at this moment takes up to 80% of CPU time...

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      I have never had that occurance unless my computer is super bogged down with a lot of applications.
      Might I suggest checking your windows theme/style settings? The P4 might not be able to hand it if you have a LOT of controls on your windows.

      Comment

      • SEngel
        New Member
        • Mar 2008
        • 13

        #4
        Originally posted by Plater
        I have never had that occurance unless my computer is super bogged down with a lot of applications.
        Might I suggest checking your windows theme/style settings? The P4 might not be able to hand it if you have a LOT of controls on your windows.
        It's strange, but there are only few controls. The most noticable effect is for TextBoxes, ComboBoxes and GroupBoxes.
        Which one setting do you mean?

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Hmm, I turn off most of the themeing on my computer so I'm not sure it even has any bearing on it.

          Are you doing anything else with the form? Doing anything durring paint/redraw events? Or populating data from a database or anything?

          Comment

          • SEngel
            New Member
            • Mar 2008
            • 13

            #6
            Originally posted by Plater
            Hmm, I turn off most of the themeing on my computer so I'm not sure it even has any bearing on it.

            Are you doing anything else with the form? Doing anything durring paint/redraw events? Or populating data from a database or anything?
            The form is free from any code.

            I have set DoubleBuffered property of groupboxes to true and this helped a little, but the problem still stays.

            Comment

            • SEngel
              New Member
              • Mar 2008
              • 13

              #7
              I have found the following effect:
              I create multi window app (I run another window in another thread) and catch
              events concerning moving and resizing of that other window. On each such event I run DoEvents() in a main thread. This leads to perferct window redraw.

              But I can't understand, how to do the same with windows of 3rd side applications.
              Can anybode help?

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Ah!
                So this window was not running in the GUI thread but in a different thread?

                Comment

                • SEngel
                  New Member
                  • Mar 2008
                  • 13

                  #9
                  Originally posted by Plater
                  Ah!
                  So this window was not running in the GUI thread but in a different thread?

                  Yes, I've created BackgroundWorke r in the main GUI thread and asked it to do
                  Run.Application (AnotherWindow) ;

                  In this case I've no such awful effect as it was described in the 1st post.
                  That's because I can catch events from this window.

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    I thought you were having trouble with the "main" window. Makes sense that the window in the other thread had trouble with redraws.

                    Comment

                    • SEngel
                      New Member
                      • Mar 2008
                      • 13

                      #11
                      Originally posted by Plater
                      I thought you were having trouble with the "main" window. Makes sense that the window in the other thread had trouble with redraws.
                      No, you were right!
                      again, the situaton is following:

                      1). I have main window with simple controls. When any window from other app hovers over it, the problem with redraw occurs.
                      2). I have another window in another thread. There is no problem described in point 1), if I catch it's Move and Resize events in the main window and refresh main window manually by means of DoEvents()
                      -----------

                      So, how can I get rid of the problem in point 1) ???

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        Did you use Application.Run () to run the main form?

                        Comment

                        • SEngel
                          New Member
                          • Mar 2008
                          • 13

                          #13
                          Originally posted by Plater
                          Did you use Application.Run () to run the main form?
                          Yes,

                          Application.Ena bleVisualStyles ();
                          Application.Set CompatibleTextR enderingDefault (false);
                          Application.Run (new PhotoEngineForm ());

                          Comment

                          • Plater
                            Recognized Expert Expert
                            • Apr 2007
                            • 7872

                            #14
                            And PhotoEngineForm is the one that has troubles with the screen not getting refreshed?
                            And this only occurs when that otherr form in that other thread is open correct?

                            Comment

                            • SEngel
                              New Member
                              • Mar 2008
                              • 13

                              #15
                              Originally posted by Plater
                              And PhotoEngineForm is the one that has troubles with the screen not getting refreshed?
                              And this only occurs when that otherr form in that other thread is open correct?
                              PhotoEngineForm is the main form with refresh problems, that is correct.
                              But troubles occur, when the other application window is moved over PhotoEngineForm .

                              I have written about other form, let's call it OtherForm, ONLY in order to show, that the problem is theoretically solvable be means of catching onMove and onResize events. (this also means, that my hardware conf can handle it). But I don't know how to catch these events from OTHER applications.

                              Comment

                              Working...