autoscrollposition and invalidate()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon

    autoscrollposition and invalidate()

    I am writing a graphics application that
    supports "zooming". I have implemented some code that
    forces the zoom to occur around the center of the client
    window. So, the code recalculates the PageScale, which
    will be changed when the Paint event is called, then
    calculates the offset required to return the original
    center coordinate to the center of the client window after
    the zooming has occurred.

    However, when I use the AutoScrollPosit ion to set the
    offset distance, the program is repainting only part of
    the client window. The last command of the method calls
    the Invalidate() method, which corrects the screenshot.
    However, the brief incorrect repainting is causing
    a "flicker".

    Any suggestions?



  • Greg Ewing [MVP]

    #2
    Re: autoscrollposit ion and invalidate()

    Jon, how are you displaying the image? One way to eliminate flicker is to
    follow these steps:

    1. Draw your image using the image class in memory.
    2. Display that image using an image control or other means
    3. make any changes to your image in memory, zooming etc...
    4. Change the visible image to the new image.

    By not displaying the image which you are working on you can eliminate most
    flicker. Hope that helps.

    --
    Greg Ewing [MVP]
    Accomplish Your Mission with Better IT | IT support for nonprofits. You deserve peace of mind. National and remote outsourced nonprofit IT.


    "Jon" <jhirsch3@netze ro.com> wrote in message
    news:026101c384 b0$83e613b0$a00 1280a@phx.gbl.. .[color=blue]
    > I am writing a graphics application that
    > supports "zooming". I have implemented some code that
    > forces the zoom to occur around the center of the client
    > window. So, the code recalculates the PageScale, which
    > will be changed when the Paint event is called, then
    > calculates the offset required to return the original
    > center coordinate to the center of the client window after
    > the zooming has occurred.
    >
    > However, when I use the AutoScrollPosit ion to set the
    > offset distance, the program is repainting only part of
    > the client window. The last command of the method calls
    > the Invalidate() method, which corrects the screenshot.
    > However, the brief incorrect repainting is causing
    > a "flicker".
    >
    > Any suggestions?
    >
    >
    >[/color]


    Comment

    • Jon

      #3
      Re: autoscrollposit ion and invalidate()

      Greg,

      The application is drawing the image directly to the
      graphics object provided by the paint method. I figured
      the answer was going to revolve around manual "buffering" ,
      but it is a little complicated since I have several
      routines that handle different aspects of drawing.

      I will give it a shot with a manual buffering technique
      such as the one you suggested. Theoretically, I should be
      able to turn off the automatic double buffering I had
      previously enabled, since I am now going to handle this
      manually, correct?

      Thanks for your help.

      Jon
      [color=blue]
      >-----Original Message-----
      >Jon, how are you displaying the image? One way to[/color]
      eliminate flicker is to[color=blue]
      >follow these steps:
      >
      >1. Draw your image using the image class in memory.
      >2. Display that image using an image control or other[/color]
      means[color=blue]
      >3. make any changes to your image in memory, zooming[/color]
      etc...[color=blue]
      >4. Change the visible image to the new image.
      >
      >By not displaying the image which you are working on you[/color]
      can eliminate most[color=blue]
      >flicker. Hope that helps.
      >
      >--
      >Greg Ewing [MVP]
      >http://www.citidc.com
      >
      >"Jon" <jhirsch3@netze ro.com> wrote in message
      >news:026101c38 4b0$83e613b0$a0 01280a@phx.gbl. ..[color=green]
      >> I am writing a graphics application that
      >> supports "zooming". I have implemented some code that
      >> forces the zoom to occur around the center of the client
      >> window. So, the code recalculates the PageScale, which
      >> will be changed when the Paint event is called, then
      >> calculates the offset required to return the original
      >> center coordinate to the center of the client window[/color][/color]
      after[color=blue][color=green]
      >> the zooming has occurred.
      >>
      >> However, when I use the AutoScrollPosit ion to set the
      >> offset distance, the program is repainting only part of
      >> the client window. The last command of the method calls
      >> the Invalidate() method, which corrects the screenshot.
      >> However, the brief incorrect repainting is causing
      >> a "flicker".
      >>
      >> Any suggestions?
      >>
      >>
      >>[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Greg Ewing [MVP]

        #4
        Re: autoscrollposit ion and invalidate()

        Jon, yes, in theory you should be able to turn that off. You might find
        though that it makes the graphics changes just a little neater and cleaner.

        --
        Greg Ewing [MVP]
        Accomplish Your Mission with Better IT | IT support for nonprofits. You deserve peace of mind. National and remote outsourced nonprofit IT.


        "Jon" <jhirsch3@netze ro.com> wrote in message
        news:0a0001c385 56$867f7ed0$a10 1280a@phx.gbl.. .[color=blue]
        > Greg,
        >
        > The application is drawing the image directly to the
        > graphics object provided by the paint method. I figured
        > the answer was going to revolve around manual "buffering" ,
        > but it is a little complicated since I have several
        > routines that handle different aspects of drawing.
        >
        > I will give it a shot with a manual buffering technique
        > such as the one you suggested. Theoretically, I should be
        > able to turn off the automatic double buffering I had
        > previously enabled, since I am now going to handle this
        > manually, correct?
        >
        > Thanks for your help.
        >
        > Jon
        >[color=green]
        > >-----Original Message-----
        > >Jon, how are you displaying the image? One way to[/color]
        > eliminate flicker is to[color=green]
        > >follow these steps:
        > >
        > >1. Draw your image using the image class in memory.
        > >2. Display that image using an image control or other[/color]
        > means[color=green]
        > >3. make any changes to your image in memory, zooming[/color]
        > etc...[color=green]
        > >4. Change the visible image to the new image.
        > >
        > >By not displaying the image which you are working on you[/color]
        > can eliminate most[color=green]
        > >flicker. Hope that helps.
        > >
        > >--
        > >Greg Ewing [MVP]
        > >http://www.citidc.com
        > >
        > >"Jon" <jhirsch3@netze ro.com> wrote in message
        > >news:026101c38 4b0$83e613b0$a0 01280a@phx.gbl. ..[color=darkred]
        > >> I am writing a graphics application that
        > >> supports "zooming". I have implemented some code that
        > >> forces the zoom to occur around the center of the client
        > >> window. So, the code recalculates the PageScale, which
        > >> will be changed when the Paint event is called, then
        > >> calculates the offset required to return the original
        > >> center coordinate to the center of the client window[/color][/color]
        > after[color=green][color=darkred]
        > >> the zooming has occurred.
        > >>
        > >> However, when I use the AutoScrollPosit ion to set the
        > >> offset distance, the program is repainting only part of
        > >> the client window. The last command of the method calls
        > >> the Invalidate() method, which corrects the screenshot.
        > >> However, the brief incorrect repainting is causing
        > >> a "flicker".
        > >>
        > >> Any suggestions?
        > >>
        > >>
        > >>[/color]
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        • Jon H.

          #5
          Re: autoscrollposit ion and invalidate()

          Greg,

          The basis of the problem seems to be that because I am
          adjusting the autoscrollposit ion, buffering will not be
          able to control the graphic. The code is automatically
          invalidating only the part of the screen that was not
          displayed before the scroll adjustment was performed.
          This is what is causing the "flicker".

          What I need is a more detailed control of the scrollbar
          behavior. Specifically, I need the Invalidated rectangle
          upon scrolling to be the entire clientrectangle and I need
          to suspend any redrawing of the scrollbars themselves
          until my code has programmaticall y made the necessary
          adjustments to the scrollbar positions. Any suggestions?

          Thanks in advance.

          [color=blue]
          >-----Original Message-----
          >Jon, how are you displaying the image? One way to[/color]
          eliminate flicker is to[color=blue]
          >follow these steps:
          >
          >1. Draw your image using the image class in memory.
          >2. Display that image using an image control or other[/color]
          means[color=blue]
          >3. make any changes to your image in memory, zooming[/color]
          etc...[color=blue]
          >4. Change the visible image to the new image.
          >
          >By not displaying the image which you are working on you[/color]
          can eliminate most[color=blue]
          >flicker. Hope that helps.
          >
          >--
          >Greg Ewing [MVP]
          >http://www.citidc.com
          >
          >"Jon" <jhirsch3@netze ro.com> wrote in message
          >news:026101c38 4b0$83e613b0$a0 01280a@phx.gbl. ..[color=green]
          >> I am writing a graphics application that
          >> supports "zooming". I have implemented some code that
          >> forces the zoom to occur around the center of the client
          >> window. So, the code recalculates the PageScale, which
          >> will be changed when the Paint event is called, then
          >> calculates the offset required to return the original
          >> center coordinate to the center of the client window[/color][/color]
          after[color=blue][color=green]
          >> the zooming has occurred.
          >>
          >> However, when I use the AutoScrollPosit ion to set the
          >> offset distance, the program is repainting only part of
          >> the client window. The last command of the method calls
          >> the Invalidate() method, which corrects the screenshot.
          >> However, the brief incorrect repainting is causing
          >> a "flicker".
          >>
          >> Any suggestions?
          >>
          >>
          >>[/color]
          >
          >
          >.
          >[/color]

          Comment

          • Greg Ewing [MVP]

            #6
            Re: autoscrollposit ion and invalidate()

            Jon, any chance you could post some code which demonstrates the problem you
            are running in to? A complete, runnable, program would be great.

            --
            Greg Ewing [MVP]
            Accomplish Your Mission with Better IT | IT support for nonprofits. You deserve peace of mind. National and remote outsourced nonprofit IT.


            "Jon H." <jhirsch3@netze ro.net> wrote in message
            news:0a9d01c385 6c$d4410920$a30 1280a@phx.gbl.. .[color=blue]
            > Greg,
            >
            > The basis of the problem seems to be that because I am
            > adjusting the autoscrollposit ion, buffering will not be
            > able to control the graphic. The code is automatically
            > invalidating only the part of the screen that was not
            > displayed before the scroll adjustment was performed.
            > This is what is causing the "flicker".
            >
            > What I need is a more detailed control of the scrollbar
            > behavior. Specifically, I need the Invalidated rectangle
            > upon scrolling to be the entire clientrectangle and I need
            > to suspend any redrawing of the scrollbars themselves
            > until my code has programmaticall y made the necessary
            > adjustments to the scrollbar positions. Any suggestions?
            >
            > Thanks in advance.
            >
            >[color=green]
            > >-----Original Message-----
            > >Jon, how are you displaying the image? One way to[/color]
            > eliminate flicker is to[color=green]
            > >follow these steps:
            > >
            > >1. Draw your image using the image class in memory.
            > >2. Display that image using an image control or other[/color]
            > means[color=green]
            > >3. make any changes to your image in memory, zooming[/color]
            > etc...[color=green]
            > >4. Change the visible image to the new image.
            > >
            > >By not displaying the image which you are working on you[/color]
            > can eliminate most[color=green]
            > >flicker. Hope that helps.
            > >
            > >--
            > >Greg Ewing [MVP]
            > >http://www.citidc.com
            > >
            > >"Jon" <jhirsch3@netze ro.com> wrote in message
            > >news:026101c38 4b0$83e613b0$a0 01280a@phx.gbl. ..[color=darkred]
            > >> I am writing a graphics application that
            > >> supports "zooming". I have implemented some code that
            > >> forces the zoom to occur around the center of the client
            > >> window. So, the code recalculates the PageScale, which
            > >> will be changed when the Paint event is called, then
            > >> calculates the offset required to return the original
            > >> center coordinate to the center of the client window[/color][/color]
            > after[color=green][color=darkred]
            > >> the zooming has occurred.
            > >>
            > >> However, when I use the AutoScrollPosit ion to set the
            > >> offset distance, the program is repainting only part of
            > >> the client window. The last command of the method calls
            > >> the Invalidate() method, which corrects the screenshot.
            > >> However, the brief incorrect repainting is causing
            > >> a "flicker".
            > >>
            > >> Any suggestions?
            > >>
            > >>
            > >>[/color]
            > >
            > >
            > >.
            > >[/color][/color]


            Comment

            Working...