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. Ugly dynamic resizing of a control

Ugly dynamic resizing of a control

Scheduled Pinned Locked Moved C#
announcement
4 Posts 2 Posters 1 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.
  • G Offline
    G Offline
    G Ringbom
    wrote on last edited by
    #1

    I have just made a control that is resizable. The resizing is performed with the mouse, in the normal windows way. You put the mouse on the resizer box and drag it to desired shape. I have currently made this work for bottom and the right side of the control. When I resize using those resizers everything works fine. When I drag them with the mouse the control is smoothly updated. Here I update the controls width and height properties. But when I try to do the same thing with the top and left side of the control, things dont work as with the bottom and right side. The control gets strange shapes until I release the mouse button and still it doesnt get the correct shape as I would expect. It kind of works, it resizes in the right directions atleast, but not always in the correct distances, and the resize is definately not smooth, it looks completely screwed up during the resize and flickers and everything. The only difference I can see between these edges of the control and the bottom and right is that the top and left sides need to change the controls Top and Left properties and not just its Width and Height. The code is basically exactly the same for all resizes so it seems really strange to me.

    A 1 Reply Last reply
    0
    • G G Ringbom

      I have just made a control that is resizable. The resizing is performed with the mouse, in the normal windows way. You put the mouse on the resizer box and drag it to desired shape. I have currently made this work for bottom and the right side of the control. When I resize using those resizers everything works fine. When I drag them with the mouse the control is smoothly updated. Here I update the controls width and height properties. But when I try to do the same thing with the top and left side of the control, things dont work as with the bottom and right side. The control gets strange shapes until I release the mouse button and still it doesnt get the correct shape as I would expect. It kind of works, it resizes in the right directions atleast, but not always in the correct distances, and the resize is definately not smooth, it looks completely screwed up during the resize and flickers and everything. The only difference I can see between these edges of the control and the bottom and right is that the top and left sides need to change the controls Top and Left properties and not just its Width and Height. The code is basically exactly the same for all resizes so it seems really strange to me.

      A Offline
      A Offline
      Alexander Kent
      wrote on last edited by
      #2

      Check your OnPaint Event, most likely you have overridden it, maybe excessive use of Invalidate ? ~Alexander Kent

      G 1 Reply Last reply
      0
      • A Alexander Kent

        Check your OnPaint Event, most likely you have overridden it, maybe excessive use of Invalidate ? ~Alexander Kent

        G Offline
        G Offline
        G Ringbom
        wrote on last edited by
        #3

        Yes I have overridden the OnPaint event, and I really dont know whether the use of invalidate is excessive or not, but it works for the bottom and right sides of the control, and I invalidate them just as much as I invalidate the top and left sides. The source code is maybe a little too long to show here but if anyone wants to see it I'll be glad to send it to you.

        A 1 Reply Last reply
        0
        • G G Ringbom

          Yes I have overridden the OnPaint event, and I really dont know whether the use of invalidate is excessive or not, but it works for the bottom and right sides of the control, and I invalidate them just as much as I invalidate the top and left sides. The source code is maybe a little too long to show here but if anyone wants to see it I'll be glad to send it to you.

          A Offline
          A Offline
          Alexander Kent
          wrote on last edited by
          #4

          Keen to take a look at your code ~Alexander Kent

          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