Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to tell when a control is done resizing?

Status
Not open for further replies.

SavantMan

Programmer
Apr 17, 2002
165
US
I have a control that the user is able to manually resize --- and it works great. The problem is I need to handle something when the control is done being resized, but not during the resize, so just putting what I need in the resize event won't work. Any suggestions?
 
2005 edition or rather the Express products (free!) have:

- resize
- resizeBegin
- ResizeEnd

events! That is great, but you do not use that version..

What i can think of and suggest is that you could combine the mouseDown, the mouseUp and the resize events of the form-control.
 
Actually I'm using the VS2005 professional edition --- the resizebegin and resizeend events are available for forms, but not controls. I'm sure it's because I'm giving the user limited "design time" access to the control, which is not common, but a user being able to resize a form is.
 
Still need help.

I looked at doing something along the lines of storing the control size to a local variable on mousedown, comparing on mouseup and handling that way, but because the control is in design mode, it's not actually recognizing the mousedown and mouseup events.
 
***Thinking Out Loud...Not sure if this will work or not*****

If I understand this, you have a control that needs to do something "after" it has been resized. There's 2 events that I can think of that might work here.

First, the Redraw event. If your user changes the size of a control, the form will automatically redraw the form. So, if you have an array with the dimensions of the control, then you can set up an event that will fire when the redraw does. This event will get the dimensions of your control through it's properties and compare them to what's in the array. If they're different then fire the method that does what you need done.

Second, which is kinda similar to the first, is to use the mouse drag event. This would require you to again keep up with dimension and location of your control, and if the mouse drag event starts on one of the corners of your control then fire the event when it's done.

Another event to look into is the mouse down event. If the coordinates of the mouse down event are within the area of your control, then check if they drag...if so, fire the event when the user let's go of the control.

Oh yeah...something else you could do is to create a custom control by inheriting the current control and adding the "resize" event to your control. If that's something you want to look into, Google "Visual Inheritance Visual Basic". That should give you quite a bit of information to go over.
 
Thanks for everyones help so far... Still not working.

The controls I'm using are all customcontrols already, and it's trapping the resize event that I was trying.

Essentially what I'm trying to do in the resize event is check to see if the new size/position meet certain criteria, and if not, move them in code.

I looked for the "redraw" event and it doesn't seem to exist. The ResizeEnd event exists for the parent, but not for the control. Since the control is actually in designmode there are certain events that simply don't fire, such as the click event.

Things that make you go hmmm...
 
Just one thought:

Get the cursor X and Y values at the mousedown event of the control. Class only scope variables: Private _x, _y as long. Check what is closer to its edge like:

if _r = True Then
If control_width - _x < control_height - _y Then
'closer to right
'code setting the height depending on control's current width
Else
'closer to down
'code setting the widht depending on control's current height
End If
End If

Variable _r is also class level var (private _r as boolean =false) and should be set in the mousedown event too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top