Valhalla Legends Forums Archive | General Programming | Resizing...

AuthorMessageTime
Fr0z3N
how do you make everything on your form resize when you resize your form?

like txt's rtb's cmd's lv's
i have no clue so explain slowly please
March 16, 2003, 1:16 AM
warz
well youd put the .heigh .top and .width to use,,,
exampel:

[code]
Private Sub Form_Resize()
On Error Resume Next
   Text3.Left = Me.Width - 1000
   Text3.Height = Me.Height - 750
   Text3.Width = 735
   
   Text1.Height = Text3.Height
   Text1.Width = (Me.Width - Text3.Width) - 600
   
   Text2.Width = Text1.Width
   Text2.Top = Me.ScaleHeight - 400
End Sub
[/code]

i uplaoded the form to lakctech at htto?://tks.slacktech.com under visubal basic source code
March 16, 2003, 1:42 AM
Fr0z3N
Yes but I dont know what to do with the numbers to make them the size of my shit or w/e
March 16, 2003, 2:51 AM
warz
Mess around with them, it's not that hard.
March 16, 2003, 3:02 AM
Noodlez
wow... thats some amazing self restraint

should always use Me.ScaleX instead of Me.X (Me.ScaleHeight as opposed to Me.Height for those of you that were born disadvantaged)
March 16, 2003, 3:29 AM
Grok
[quote]wow... thats some amazing self restraint

should always use Me.ScaleX instead of Me.X (Me.ScaleHeight as opposed to Me.Height for those of you that were born disadvantaged)[/quote]

Should also use Obj.Move instead of setting the properties directly.
March 16, 2003, 3:33 AM
Fr0z3N
huh?
March 16, 2003, 12:11 PM
St0rm.iD
You have to think to do this you know.

Type it into fucking google for christs sake.

*takes over warz's job*
March 16, 2003, 12:34 PM
Grok
Here is an example from an MDI child form I use:

[code]
Private Sub Form_Resize()
   txtTalk.Move 0, Me.ScaleHeight - CoolBar1.Height - txtTalk.Height, Me.ScaleWidth
   picRoom.Move 0, 0, Me.ScaleWidth - picUsers.Width
   picUsers.Move picRoom.Width, 0, lvUsers.Width
   rtb.Move 0, picRoom.Height, Me.ScaleWidth - lvUsers.Width, Me.ScaleHeight - CoolBar1.Height - txtTalk.Height - picRoom.Height
   lvUsers.Move rtb.Width, rtb.Top, lvUsers.Width, rtb.Height
End Sub
[/code]

[img width=440 height=323]http://www.valhallalegends.com/images/Resize1.jpg[/img]
To see it work, put these objects on a form:

TextBox txtTalk
PictureBox picRoom
PictureBox picUsers
RichTextBox rtb
ListView lvUsers
CoolBar CoolBar1 (align to bottom of form)

Run it and watch how the code resizes each control during the form_resize event.  That should get you started.
March 16, 2003, 1:00 PM
warz
yeah frozen is pretty stupid, eh?
March 16, 2003, 3:04 PM
St0rm.iD
Fake warz eh?
March 16, 2003, 4:15 PM
Fr0z3N
i dunno if its stupid or it works all i know is its confusing and complicated
March 16, 2003, 5:16 PM
warz
Fake warz? What the shit. Who would want to be me?
I pitty the wanksta who attempts to take over my
name.
March 16, 2003, 6:53 PM
Fr0z3N
lol warz
March 16, 2003, 11:47 PM
haZe
Fr0z3n If you can't make something out of what Grok said, which is a perfect example, then I don't mean to flame or anything but take some time to learn VB. No, that wasn't a flame, it was a suggestion.
March 17, 2003, 7:17 AM
St0rm.iD
yeah ok
March 17, 2003, 7:48 AM
MrRaza
I wish his avatar was in color too  ::) ;D
March 17, 2003, 8:48 AM
Fr0z3N
Haze, I know NOTHING about resizing and It's hard to learn when ppl throw there code at you and not explain what each function does.
March 17, 2003, 5:15 PM
Grok
Frozen,

I spent a good 15-20 minutes preparing a clear answer for you, including a screenshot.  That's 20 minutes out of my day that I will spend elsewhere in the future, if you are so ungrateful.

My code only had ONE method in it, ".move" which only takes four arguments.  Left, Top, Width, Height.  You can easily read out .move in MSDN online or in VB Help.  It is not my responsibility to help you at all, much less teach you the syntax of the only command you needed.

Finally, it was all written in good will as a response to a question that YOU ASKED.  Surely you can take the time to study the code in the best of all replies given to you.  I even told you how to build the form and which controls to put on it so that the code sample would work.

Don't bite the hand that feeds you.
March 17, 2003, 6:48 PM
Fr0z3N
Sorry Grok, I haven't tryed your way yet I was refering to warz way. I'll go try your way.
March 17, 2003, 7:11 PM
St0rm.iD
Fucking shit, here's your goddamn answer you ungrateful son of a bitch.

put:
Dim PrevResizeX
Dim PrevResizeY

at the top of your form

then do this
[code]
Public Function ResizeAll(FormName As Form)
   Dim tmpControl As Control
   On Error Resume Next
   'Ignores errors in case the control does
   '     n't
   'have a width, height, etc.


   If PrevResizeX = 0 Then
       'If the previous form width was 0
       'Which means that this function wasn't r
       '     un before
       'then change prevresizex and y and exit


'     function
   PrevResizeX = FormName.ScaleWidth
   PrevResizeY = FormName.ScaleHeight
   Exit Function
End If


For Each tmpControl In FormName
   'A loop to make tmpControl equal to ever
   '     y
   'control on the form


   If TypeOf tmpControl Is Line Then
       'Checks the type of control, if its a
       'Line, change its X1, X2, Y1, Y2 values
       tmpControl.x1 = tmpControl.x1 / PrevResizeX * FormName.ScaleWidth
       tmpControl.x2 = tmpControl.x2 / PrevResizeX * FormName.ScaleWidth
       tmpControl.Y1 = tmpControl.Y1 / PrevResizeY * FormName.ScaleHeight
       tmpControl.Y2 = tmpControl.Y2 / PrevResizeY * FormName.ScaleHeight
       'These four lines see the previous ratio
       '
       'Of the control to the form, and change
       '     they're
       'current ratios to the same thing
   Else
       'Changes everything elses left, top
       'Width, and height
       tmpControl.Left = tmpControl.Left / PrevResizeX * FormName.ScaleWidth
       tmpControl.Top = tmpControl.Top / PrevResizeY * FormName.ScaleHeight
       tmpControl.Width = tmpControl.Width / PrevResizeX * FormName.ScaleWidth
       tmpControl.Height = tmpControl.Height / PrevResizeY * FormName.ScaleHeight
       'These four lines see the previous ratio
       '
       'Of the control to the form, and change
       '     they're
       'current ratios to the same thing
   End If
Next tmpControl
PrevResizeX = FormName.ScaleWidth
PrevResizeY = FormName.ScaleHeight
'Changes prevresize x and y to current w
'     idth
'and height
End Function

[/code]

then in your form_resize event

[code]
ResizeAll me
[/code]
March 17, 2003, 7:16 PM
Fr0z3N
I didn't mean to sound so ungrateful, I'm sorry and that code works, thanks.
March 17, 2003, 9:03 PM
St0rm.iD
har don't worry about it
i was kidding
March 17, 2003, 11:18 PM
Fr0z3N
you always sound so serious,  :P
March 17, 2003, 11:22 PM
St0rm.iD
I don't mean half the stuff I post anyway.
March 17, 2003, 11:24 PM
Fr0z3N
lol, so you really have 100 meaning full posts?  ;D
March 17, 2003, 11:42 PM
St0rm.iD
Approximately.
March 18, 2003, 7:59 AM
MailMan
Thank you for that, storm.id, that was a very neat and helpful function.
March 19, 2003, 5:10 PM
Fr0z3N
STORM! that function fucks up when you minamize bot http://www.blizzside.com/madz/download.php?op=getit&lid=74
theres link to my bot if you wanna see

[img]http://www.frozcreations.com/Fr0zChat.JPG[/img]


Edit; got ss working
March 19, 2003, 7:04 PM
haZe
Yeah, When you minimize it, for me, it makes my RTB and everything else on my form invisible...
March 19, 2003, 10:01 PM
Fr0z3N
Same!
March 19, 2003, 10:22 PM
St0rm.iD
if windowstate = vbminimized then exit sub
March 20, 2003, 4:41 PM
Fr0z3N
where would that go  :o
March 20, 2003, 10:23 PM
haZe
Underneath Public Sub Resizeall blah blah

[edit] spelling
March 21, 2003, 7:38 AM

Search