Ugly dynamic resizing of a control
-
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.
-
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.
Check your OnPaint Event, most likely you have overridden it, maybe excessive use of Invalidate ? ~Alexander Kent
-
Check your OnPaint Event, most likely you have overridden it, maybe excessive use of Invalidate ? ~Alexander Kent
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.
-
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.
Keen to take a look at your code ~Alexander Kent