Moving form objects around

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chris.dannemiller@gmail.com

    Moving form objects around

    I need to be able to move a few form abouts around after a event occurs
    but when I do this it causes massive flickering is there any way to
    reduce this?

  • Steven Nagy

    #2
    Re: Moving form objects around

    Hi

    Checkout the SuspendLayout and ResumeLayout methods.

    Also, what event are you talking about? It really depends how often you
    want your form to draw. Every pixel of the movement? Only when it gets
    to its destination?

    Cheers,
    Steven Nagy

    Comment

    • chris.dannemiller@gmail.com

      #3
      Re: Moving form objects around

      Thanks for the suggestion but I am still seeing the flickering. Its
      button that the user clicks that causes the form layout to require a
      change.

      Comment

      • Steven Nagy

        #4
        Re: Moving form objects around

        Stick your code on here for the button event (just the important stuff)
        and also try to answer some of my other questions. We'll get you
        sorted!

        Comment

        • chris.dannemiller@gmail.com

          #5
          Re: Moving form objects around

          private void Form_Resize(obj ect sender, System.EventArg s e)
          {
          SuspendLayout() ;
          // Panel1, and Custom1 are aligned top left as well.
          // Panel1 surrounds Custom1 + 1 Pix this is implied below.
          // Custom 1 uses GDI+ and has a Scroll bar that may or may not be
          visible on the
          // right side
          // CustomTo*Edge calculated at load time distance from the * to the
          Edge of the form.
          Custom1.Suspend Layout();
          // Keep this constant.
          Custom1.Width = ClientRectangle .Width - Custom1.Left -
          CustomToRightEd ge;
          Custom1.Height = ClientRectangle .Height - Custom1.Top -
          CustomToBottomE dge;
          // Recalculate and .Value member of the scroll bar so the user does
          not get confused.
          Custom1.RecalcS crollBar ();
          panel1.Width = ClientRectangle .Width - panel1.Left - CustomToRightEd ge
          + 2;
          panel1.Height = ClientRectangle .Height - panel1.Top -
          CustomToBottomE dge + 2;
          leadsControl1.I nvalidate();
          leadsControl1.R esumeLayout(tru e); // If false scroll bar does not
          move
          ResumeLayout(fa lse);
          }

          There is also a Custom control that is docked to the left side but it
          does not flicker. And a label1 that is aligned to Top, Left that
          requires no more complex logic, again it does not flicker. Flickering
          is most apparent when resizing along the left edge of the Form.

          It is possible to collapse panel1 and custom1 into one control, but it
          would require calculating where the scroll bar is. The panel simply
          draws a black box around custom1. I have also tried the WM_SETREDRAW
          workaround however there is bleeding from what is behind the form while
          the user is resizing, but the flicker is gone.

          Comment

          • chris.dannemiller@gmail.com

            #6
            Re: Moving form objects around

            I just figured out that most of the logic above save the recalc scroll
            bar and invalidate can be avoided by simply aligning to all edges
            however this does not solve the problem of flickering. But it helped

            Comment

            • Steven Nagy

              #7
              Re: Moving form objects around

              Whats generally happening in the RecalcScrollBar method? Are you also
              invalidating the control in there?

              Comment

              Working...