Valhalla Legends Archive

Programming => General Programming => Topic started by: Fr0z3N on March 15, 2003, 07:16 PM

Title: Resizing...
Post by: Fr0z3N on March 15, 2003, 07:16 PM
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
Title: Re: Resizing...
Post by: warz on March 15, 2003, 07:42 PM
well youd put the .heigh .top and .width to use,,,
exampel:

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

i uplaoded the form to lakctech at htto?://tks.slacktech.com under visubal basic source code
Title: Re: Resizing...
Post by: Fr0z3N on March 15, 2003, 08:51 PM
Yes but I dont know what to do with the numbers to make them the size of my shit or w/e
Title: Re: Resizing...
Post by: warz on March 15, 2003, 09:02 PM
Mess around with them, it's not that hard.
Title: Re: Resizing...
Post by: Noodlez on March 15, 2003, 09:29 PM
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)
Title: Re: Resizing...
Post by: Grok on March 15, 2003, 09:33 PM
Quotewow... 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)

Should also use Obj.Move instead of setting the properties directly.
Title: Re: Resizing...
Post by: Fr0z3N on March 16, 2003, 06:11 AM
huh?
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 16, 2003, 06:34 AM
You have to think to do this you know.

Type it into fucking google for christs sake.

*takes over warz's job*
Title: Re: Resizing...
Post by: Grok on March 16, 2003, 07:00 AM
Here is an example from an MDI child form I use:

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

(http://www.valhallalegends.com/images/Resize1.jpg)
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.
Title: Re: Resizing...
Post by: warz on March 16, 2003, 09:04 AM
yeah frozen is pretty stupid, eh?
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 16, 2003, 10:15 AM
Fake warz eh?
Title: Re: Resizing...
Post by: Fr0z3N on March 16, 2003, 11:16 AM
i dunno if its stupid or it works all i know is its confusing and complicated
Title: Re: Resizing...
Post by: warz on March 16, 2003, 12:53 PM
Fake warz? What the shit. Who would want to be me?
I pitty the wanksta who attempts to take over my
name.
Title: Re: Resizing...
Post by: Fr0z3N on March 16, 2003, 05:47 PM
lol warz
Title: Re: Resizing...
Post by: haZe on March 17, 2003, 01:17 AM
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.
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 17, 2003, 01:48 AM
yeah ok
Title: Re: Resizing...
Post by: MrRaza on March 17, 2003, 02:48 AM
I wish his avatar was in color too  ::) ;D
Title: Re: Resizing...
Post by: Fr0z3N on March 17, 2003, 11:15 AM
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.
Title: Re: Resizing...
Post by: Grok on March 17, 2003, 12:48 PM
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.
Title: Re: Resizing...
Post by: Fr0z3N on March 17, 2003, 01:11 PM
Sorry Grok, I haven't tryed your way yet I was refering to warz way. I'll go try your way.
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 17, 2003, 01:16 PM
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
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


then in your form_resize event

ResizeAll me
Title: Re: Resizing...
Post by: Fr0z3N on March 17, 2003, 03:03 PM
I didn't mean to sound so ungrateful, I'm sorry and that code works, thanks.
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 17, 2003, 05:18 PM
har don't worry about it
i was kidding
Title: Re: Resizing...
Post by: Fr0z3N on March 17, 2003, 05:22 PM
you always sound so serious,  :P
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 17, 2003, 05:24 PM
I don't mean half the stuff I post anyway.
Title: Re: Resizing...
Post by: Fr0z3N on March 17, 2003, 05:42 PM
lol, so you really have 100 meaning full posts?  ;D
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 18, 2003, 01:59 AM
Approximately.
Title: Re: Resizing...
Post by: MailMan on March 19, 2003, 11:10 AM
Thank you for that, storm.id, that was a very neat and helpful function.
Title: Re: Resizing...
Post by: Fr0z3N on March 19, 2003, 01:04 PM
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

(http://www.frozcreations.com/Fr0zChat.JPG)


Edit; got ss working
Title: Re: Resizing...
Post by: haZe on March 19, 2003, 04:01 PM
Yeah, When you minimize it, for me, it makes my RTB and everything else on my form invisible...
Title: Re: Resizing...
Post by: Fr0z3N on March 19, 2003, 04:22 PM
Same!
Title: Re: Resizing...
Post by: Banana fanna fo fanna on March 20, 2003, 10:41 AM
if windowstate = vbminimized then exit sub
Title: Re: Resizing...
Post by: Fr0z3N on March 20, 2003, 04:23 PM
where would that go  :o
Title: Re: Resizing...
Post by: haZe on March 21, 2003, 01:38 AM
Underneath Public Sub Resizeall blah blah

[edit] spelling