resize objects(controls) in a form resize

skilit
09-22-2003, 05:53 PM
Hello,
I have been searching this website for information about how to resize a form and the objects within that form, and I am getting more and more confused as I read. What I have is a form with some textboxes. I want to be able to drag the corner of the form to resize the form(or hit the maximize button at the top of the form) and have the textboxes resize accordingly(like how IE or Word does the resize). Please tell me that I do not have to find the ratio of each txtbox to the window and some how do a calculation to keep that true for all sizes. From what I was reading a problem with this is that it flickers alot and looks "ugly." It would be nice if it didn't flicker. I was having some problems reading some of the code and explainations that were posted in some of those threads. If anyone can help me out that would great. Thank you.

Nylyst
09-22-2003, 06:08 PM
Actually if you set the ScaleMode of the text boxes and Form to Pixels it's not that hard to do the calculations. I just finished creating my own custtom button that behaves similar to what your looking for.

You can use the ActiveX Control Interface Wizard Add-In (Add-Ins/Add-In Manager to add it) to Extend the standard textbox and use the Ambient.ScaleWidth and .ScaleHeight to get your forms current dimensions when the resize() event is fired and you'll be all set.

If you have some code ready, I could even help out with the OCX creation. It may seem intimidating at first, but believe me it's nearly point and click to get your custom textbox up and running (Unless you're a dolt like me and use InitProperties() instead of resize()!!)

skilit
09-23-2003, 10:44 AM
Actually if you set the ScaleMode of the text boxes and Form to Pixels it's not that hard to do the calculations. I just finished creating my own custtom button that behaves similar to what your looking for.

You can use the ActiveX Control Interface Wizard Add-In (Add-Ins/Add-In Manager to add it) to Extend the standard textbox and use the Ambient.ScaleWidth and .ScaleHeight to get your forms current dimensions when the resize() event is fired and you'll be all set.

If you have some code ready, I could even help out with the OCX creation. It may seem intimidating at first, but believe me it's nearly point and click to get your custom textbox up and running (Unless you're a dolt like me and use InitProperties() instead of resize()!!)

ok so I followed everything you said until the Ambient.ScaleWidth and .ScaleHeight part. I went through and turned the scale on everything in the form to pixels, and I loaded the ActiveX ctrl Interface. When I go to use the wizard it says,"You don't have any User Controls in your project" So I'm not sure what to do next...I created a sub routine with the form_resize event, but I don't know what to do next. Thank you for your help so far, I just need to get over the hump to the next part. Thanks again for all your patience and help.

Nylyst
09-23-2003, 07:54 PM
Ok, sorry about the delay, working on my own custom control to tidy up some things. What you'll need to do to make your control work is start a new activex control project and drop all your textboxes or other controls you want to resize and do the following (this is just an example, change to suit for your specific needs)


Private Sub UserControl_Resize()

'This is for one where IntBorder is a standard Border width you want to maintain in your control
txtbox1.Width = Ambient.ScaleWidth - IntBorder
txtbox1.Top = Ambient.Top - intBorder
txtbox1.Left = Ambient.Left - intBorder

End Sub


This is only a simple example, and obviously if you had more than one control in a row (e.g. left->right) you'd have to adjust the txtbox2.Top and .Left values to work for your control.

Now that I think about it if you only need it to resize gracefully, you wouldn't even need to do an ocx. Sorry if I led you astray, just got hooked on the ocx thing myself. You could just use the form properties (i.e. Form1.ScaleWidth/ScaleHeight/Top/Left) for each individual element. And don't forget to include adjustments for each other element that is resizing or you controls may end up overlapping.

If you're still having troubles, post a .zip of your code and I can help ya out tomorrow afternoon.


Hope this helps!

Le_Roi
09-23-2003, 09:26 PM
You can also try this link here (http://www.visualbasicforum.com/showthread.php?t=101146&highlight=resize+controls)
to another thread that has a pretty easy to use/understand example on this proplem or even here (http://www.visualbasicforum.com/showthread.php?t=100542&highlight=resize+controls) which is one by "passel"!

let me know if you need help understanding it!

-Will,

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum