473,587 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resize a control at runtime.

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!

--
Ray
Jan 15 '07 #1
7 5099
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?...1-47ef665ea0c2

It is at the bottom,

I hope this helps,

Cor

"Ray Cassick" <rc************ *@enterprocity. comschreef in bericht
news:u8******** ******@TK2MSFTN GP03.phx.gbl...
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!

--
Ray

Jan 16 '07 #2
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
Cor Ligthert [MVP] wrote:
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?...1-47ef665ea0c2

It is at the bottom,

I hope this helps,

Cor

"Ray Cassick" <rc************ *@enterprocity. comschreef in bericht
news:u8******** ******@TK2MSFTN GP03.phx.gbl...
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!

--
Ray
Jan 16 '07 #3
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 [MVP]" <no************ @planet.nlwrote in message
news:Ol******** *****@TK2MSFTNG P06.phx.gbl...
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?...1-47ef665ea0c2

It is at the bottom,

I hope this helps,

Cor

"Ray Cassick" <rc************ *@enterprocity. comschreef in bericht
news:u8******** ******@TK2MSFTN GP03.phx.gbl...
>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!

--
Ray


Jan 17 '07 #4
Just check everytime where the mouse is and add the width or height
accoording to that.

Cor

"Ray Cassick" <rc************ *@enterprocity. comschreef in bericht
news:OP******** ******@TK2MSFTN GP03.phx.gbl...
>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 [MVP]" <no************ @planet.nlwrote in message
news:Ol******** *****@TK2MSFTNG P06.phx.gbl...
>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?...1-47ef665ea0c2

It is at the bottom,

I hope this helps,

Cor

"Ray Cassick" <rc************ *@enterprocity. comschreef in bericht
news:u8******* *******@TK2MSFT NGP03.phx.gbl.. .
>>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!

--
Ray



Jan 17 '07 #5
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.

http://www.codeproject.com/useritems/controlresize.asp

Raymond R Cassick
CEO / CSA
Enterprocity Inc.
www.enterprocity.com
3380 Sheridan Drive, #143
Amherst, NY 14227
V: 716-316-5973
Blog: http://spaces.msn.com/members/rcassick/

"Ray Cassick" <rc************ *@enterprocity. comwrote in message
news:u8******** ******@TK2MSFTN GP03.phx.gbl...
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!

--
Ray

Jan 18 '07 #6
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
Ray Cassick wrote:
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.

http://www.codeproject.com/useritems/controlresize.asp

Raymond R Cassick
CEO / CSA
Enterprocity Inc.
www.enterprocity.com
3380 Sheridan Drive, #143
Amherst, NY 14227
V: 716-316-5973
Blog: http://spaces.msn.com/members/rcassick/

"Ray Cassick" <rc************ *@enterprocity. comwrote in message
news:u8******** ******@TK2MSFTN GP03.phx.gbl...
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!

--
Ray
Jan 19 '07 #7
Here's the link to my article:

http://www.codeproject.com/useritems...rolresizer.asp

Sorry it's in C# though, when I started programming I forgot what
newsgroup I had seen the question in.

Thanks,

Seth Rowe
rowe_newsgroups wrote:
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
Ray Cassick wrote:
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.

http://www.codeproject.com/useritems/controlresize.asp

Raymond R Cassick
CEO / CSA
Enterprocity Inc.
www.enterprocity.com
3380 Sheridan Drive, #143
Amherst, NY 14227
V: 716-316-5973
Blog: http://spaces.msn.com/members/rcassick/

"Ray Cassick" <rc************ *@enterprocity. comwrote in message
news:u8******** ******@TK2MSFTN GP03.phx.gbl...
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!
>
--
Ray
>
Jan 20 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3250
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the parent that holds my user control is resized, I resize my image so that it uses the maximum available space. Note: It takes about 2 seconds to...
1
1312
by: Mamatha | last post by:
Hi I have an application in VB.NET,in that application one form contains listbox(on the leftside of the form)and datagrid control(on the rightside of the form).Both controls displays data at runtime,i want to see the data of both controls by resizing according to my convinence.How can i resize those controls at runtime.If any one help me...
1
3179
by: Rohan | last post by:
Hi There, Is it possible to rotate or resize pictureboxes, labels, textboxes at runtime? And I even wanted to make textbox and label controls Transperent ?
2
1833
by: james | last post by:
As part of my app I am programatically adding some Label controls to a form at runtime. The code for these is part of a function that is overrriding the Paint event of the form. The other stuff that is drawn in the same function works fine when I resize the screen (some lines and so on) but the labels remain. I tried deleting them by...
11
8176
by: Newbie Coder | last post by:
Hi All VB.NET 2003 Can anyone tell me how to stop a user control being able to be resized during both design time & run time, please? I am looking for something like the LOCKED property, but being able to move the control to wherever on the form it's needed.
4
3193
by: Russ Green | last post by:
I have a VB.NET app that uses lots of forms which I am loading into a panel cotrol using..... Me.pnlMain.Controls.Clear() frm.TopLevel = False frm.WindowState = FormWindowState.Maximized frm.Dock = DockStyle.Fill frm.Anchor = AnchorStyles.Left + AnchorStyles.Right + AnchorStyles.Top + AnchorStyles.Bottom
2
6102
by: Diogene Laerzio | last post by:
I'd like to allow user to resize a treeview control in a form at runtime. What properties should I set to allow this? Thank you.
0
1332
by: ashinamdev | last post by:
Hi I have a probelm I am using the datagrid control in my asp.net web page. I want to resize the datagrid column at runtime. User can be able to resize the column width according to his requirment at run time. Pls solve this problem. Ashish
10
44070
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their screen. I used to write code in Java a few years ago (2005), and you could stretch a form with the mouse and all the controls and fonts would...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.