Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Automatic fluid (in theory) resize of Windows Forms App

Automatic fluid (in theory) resize of Windows Forms App

Scheduled Pinned Locked Moved C#
databasewinformsperformancequestionlounge
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brendanpi
    wrote on last edited by
    #1

    G'day, I am writing something to deal with logged multi-user access to our social media accounts, and what I want to do is add a second textbox when the message goes over the Twitter maximum - 140. What I have at the moment is a form with the controls anchored to their spot on the page. When the second textbox is needed, i call a timer with a 1ms trigger time to expand the size of the form by one 1 px until it's at the "large" size. The idea behind this is to have the second textbox slide down from behind the first one. However it is not fluid. Any ideas how I can speed it up or a better way of doing it? Thanks! Brendan

    OriginalGriffO 1 Reply Last reply
    0
    • B brendanpi

      G'day, I am writing something to deal with logged multi-user access to our social media accounts, and what I want to do is add a second textbox when the message goes over the Twitter maximum - 140. What I have at the moment is a form with the controls anchored to their spot on the page. When the second textbox is needed, i call a timer with a 1ms trigger time to expand the size of the form by one 1 px until it's at the "large" size. The idea behind this is to have the second textbox slide down from behind the first one. However it is not fluid. Any ideas how I can speed it up or a better way of doing it? Thanks! Brendan

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Slow the timer down. At the moment you are asking for 1000 frames per second animation - the drawing can't keep up with that rate so it looks "jerky". Change the interval to say 40 and try again. If may also be worth turning DoubleBuffered to true for the form - experiment. If you don't need it then don't do it as it slows drawing down.

      Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      B 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Slow the timer down. At the moment you are asking for 1000 frames per second animation - the drawing can't keep up with that rate so it looks "jerky". Change the interval to say 40 and try again. If may also be worth turning DoubleBuffered to true for the form - experiment. If you don't need it then don't do it as it slows drawing down.

        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

        B Offline
        B Offline
        brendanpi
        wrote on last edited by
        #3

        Is there a better way of doing it? I would like it to slide out smoothly, but also at a decent speed! Thanks, Brendan

        L 1 Reply Last reply
        0
        • B brendanpi

          Is there a better way of doing it? I would like it to slide out smoothly, but also at a decent speed! Thanks, Brendan

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Movies get played at 24 or 25 frames per second, which is faster than the human eye can discern, resulting in smooth films. So there is no point in having a timer period which is less than say 30 milliseconds. What you should do however, is in each repaint use the actual time, not the predicted or expected one, to calculate how the new frame should look; doing it that way you'd compensate for most of the timing jitter a Windows PC may experience. :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups