Resize a control at runtime.

R

Ray Cassick

Does anyone here have any code that shows how to resize a control at runtime
with the mouse like you can do in the designer? The method has to change
depending on what corner of the control you are dragging since of you drag
the upper left corner the location changes but the width and height grow and
shrink as needed to keep the bottom right corner in the same location.

Been beating my head over this for hours and just cant seem to get it.

Uggggggg!
 
R

rowe_newsgroups

So how do you recommend getting the control-boxes (the white square
things you hover over to resize) around the controls?

I never figured out a good/easy way to do that.

Thanks,

Seth Rowe
 
R

Ray Cassick

I know how to move a control. I need to know how to resize one.

....and it is NOT as simple as you think. I could take the simple way out and
just allow resizing by dragging the lower right hand corner. I had that done
already and it is also simple.

I want to be able to resize by dragging from ANY corner, and again it is not
as simple as you think.

Yes, form the lower right had corner you just adjust the height and width of
the control in real time, that's simple. Now try to do it from any of the
other corners. It is a pain because you are not just changing the size but
you are changing a combination of the size AND location, and not both of
either. It would be simple if you could change the origin of the control to
always be the opposite corner from the one you are dragging, but you can't.




Cor Ligthert said:
Ray,

We have a sample, however the principle is very simple.

You set at the mousedown a global boolean to true
As long as that is set you use the mouse hoover to calculate what is
happening.
At the mouse up you set again that boolean to false.

Here the sample.
http://www.vb-tips.com/dbpages.aspx?ID=c1be07ed-e66b-4080-bc11-47ef665ea0c2

It is at the bottom,

I hope this helps,

Cor
 
C

Cor Ligthert [MVP]

Just check everytime where the mouse is and add the width or height
accoording to that.

Cor

Ray Cassick said:
I know how to move a control. I need to know how to resize one.

...and it is NOT as simple as you think. I could take the simple way out
and just allow resizing by dragging the lower right hand corner. I had
that done already and it is also simple.

I want to be able to resize by dragging from ANY corner, and again it is
not as simple as you think.

Yes, form the lower right had corner you just adjust the height and width
of the control in real time, that's simple. Now try to do it from any of
the other corners. It is a pain because you are not just changing the size
but you are changing a combination of the size AND location, and not both
of either. It would be simple if you could change the origin of the
control to always be the opposite corner from the one you are dragging,
but you can't.
 
R

rowe_newsgroups

Ok, I finally got what I wanted and, because it was so difficult, I decided
to write it up and post it publicly on CodeProject.

Good to hear! I'm just finishing the class I wrote in response to your
original question about resizing at runtime. It deals with a few things
you have in your to do list - especially the one about drawing the grab
handles outside the control. I'll try to write a code project page for
it (it will be my first article too) sometime this week and then I'll
post you a link to it.

Thanks,

Seth Rowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top