Valhalla Legends Archive

Programming => General Programming => Topic started by: WiLD on October 15, 2003, 05:23 AM

Title: Resizing Form
Post by: WiLD on October 15, 2003, 05:23 AM
Ok i didnt know where to post this but im posting it here!
Im having a little trouble with a form. i want it so when you resize it everything else adjusts to the new size so you can see all the extra black stuff.
Thank you in advance.
Title: Re:Resizing Form
Post by: Grok on October 15, 2003, 06:56 AM
I've posted resize code for a form.  Search the forum and search bnetdocs.
Title: Re:Resizing Form
Post by: WiLD on October 16, 2003, 06:37 PM
ok, iv tried searching but it only comes up with this topic, if you could provide a link and copy and paste the code it would be greatly appreciated.
Title: Re:Resizing Form
Post by: Banana fanna fo fanna on October 16, 2003, 07:23 PM
Basically, you want to pull out your algebra hat.

Make a ratio of the old size to the new size and adjust your coords/sizes accordingly.
Title: Re:Resizing Form
Post by: Grok on October 16, 2003, 07:57 PM
Quote from: WiLD on October 16, 2003, 06:37 PM
ok, iv tried searching but it only comes up with this topic, if you could provide a link and copy and paste the code it would be greatly appreciated.

Click Advanced Search, put "Form_Resize" as the phrase to search for, and change the number of days to 800.  You'll find enough useful code to ignore for a month.  Especially the resize stuff from st0rm.
Title: Re:Resizing Form
Post by: Seven on October 18, 2003, 05:43 AM
Quote from: St0rm.iD on October 16, 2003, 07:23 PM
Basically, you want to pull out your algebra hat.

Make a ratio of the old size to the new size and adjust your coords/sizes accordingly.

As he said, just calculate the subtraction (in my case) to however many objects you have.  Yes, Form_Resize can be a bitch, but once you get a few objects down to resizing, the rest is a peice of cake
Title: Re:Resizing Form
Post by: iago on October 18, 2003, 07:38 AM
If you make everything a control array it's easy!
Title: Re:Resizing Form
Post by: UserLoser on October 18, 2003, 08:44 AM
Quote from: Grok on October 15, 2003, 06:56 AM
I've posted resize code for a form.  Search the forum and search bnetdocs.

AFAIK BnetDocs doesnt have anything on resizing
Title: Re:Resizing Form
Post by: Banana fanna fo fanna on October 19, 2003, 07:53 PM
Quote from: iago on October 18, 2003, 07:38 AM
If you make everything a control array it's easy!

Form.controls iirc
Title: Re:Resizing Form
Post by: Adron on October 20, 2003, 05:49 AM
Was the language specified yet?
Title: Re:Resizing Form
Post by: iago on October 20, 2003, 08:07 AM
Quote from: Adron on October 20, 2003, 05:49 AM
Was the language specified yet?

Nope!
Title: Re:Resizing Form
Post by: hismajesty on October 20, 2003, 02:29 PM
Quote from: Adron on October 20, 2003, 05:49 AM
Was the language specified yet?

No, but it is VB.
Title: Re:Resizing Form
Post by: Adron on October 20, 2003, 02:34 PM
Quote from: hismajesty on October 20, 2003, 02:29 PM

No, but it is VB.

Why do you say that?
Title: Re:Resizing Form
Post by: Banana fanna fo fanna on October 20, 2003, 06:43 PM
omfg omfg wrong forum flame flame flame
Title: Re:Resizing Form
Post by: hismajesty on October 20, 2003, 07:27 PM
Quote from: Adron on October 20, 2003, 02:34 PM
Quote from: hismajesty on October 20, 2003, 02:29 PM

No, but it is VB.

Why do you say that?

Well, I assumed it is VB because every other post he has posted here has been about VB.  ;)
Title: Re:Resizing Form
Post by: Adron on October 21, 2003, 03:34 AM
Ah, OK. Well, forms exist in many languages, and it seems for example VB.NET has much better features for looping through all controls on a form to resize them.
Title: Re:Resizing Form
Post by: Fr0z3N on October 21, 2003, 06:51 AM

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



Private Sub Form_Resize()
If WindowState = vbMinimized Then Exit Sub
ResizeAll Me
End Sub

Title: Re:Resizing Form
Post by: Archonist on November 05, 2003, 07:00 PM
Private Sub Form_Resize()
Chat.Width = Me.ScaleWidth - lvUsers.Width
Chat.Height = Me.ScaleHeight - txtSend.Height
lvUsers.Height = Me.ScaleHeight - lChan.Height - txtSend.Height
lChan.Left = Chat.Width
lvUsers.Left = Chat.Width
txtSend.Top = Chat.Height
txtSend.Width = Me.ScaleWidth
End Sub


It works perfectly for my needs.
Title: Re:Resizing Form
Post by: dxoigmn on November 06, 2003, 12:02 PM
Quote from: Archonist on November 05, 2003, 07:00 PM
Private Sub Form_Resize()
Chat.Width = Me.ScaleWidth - lvUsers.Width
Chat.Height = Me.ScaleHeight - txtSend.Height
lvUsers.Height = Me.ScaleHeight - lChan.Height - txtSend.Height
lChan.Left = Chat.Width
lvUsers.Left = Chat.Width
txtSend.Top = Chat.Height
txtSend.Width = Me.ScaleWidth
End Sub


It works perfectly for my needs.


What about when you resize the form really small?  Negative values?  Also, it's better to use the Move() property of controls.
Title: Re:Resizing Form
Post by: Fr0z3N on November 06, 2003, 02:18 PM
Therefor

Mine > Archon's
Title: Re:Resizing Form
Post by: dxoigmn on November 06, 2003, 03:20 PM
Quote from: Fr0z3N on November 06, 2003, 02:18 PM
Therefor

Mine > Archon's

Except that you don't use the Move() property.
Title: Re:Resizing Form
Post by: Banana fanna fo fanna on November 06, 2003, 05:29 PM
Except that Move() isn't a VB property.
Title: Re:Resizing Form
Post by: dxoigmn on November 06, 2003, 07:29 PM
Quote from: St0rm.iD on November 06, 2003, 05:29 PM
Except that Move() isn't a VB property.

Huh?
Title: Re:Resizing Form
Post by: Adron on November 07, 2003, 07:56 PM
Quote from: kamakazie on November 06, 2003, 07:29 PM
Quote from: St0rm.iD on November 06, 2003, 05:29 PM
Except that Move() isn't a VB property.

Huh?

It's a method?
Title: Re:Resizing Form
Post by: Fr0z3N on November 07, 2003, 10:33 PM
....meh
Title: Re:Resizing Form
Post by: dxoigmn on November 08, 2003, 12:22 PM
Quote from: Adron on November 07, 2003, 07:56 PM
Quote from: kamakazie on November 06, 2003, 07:29 PM
Quote from: St0rm.iD on November 06, 2003, 05:29 PM
Except that Move() isn't a VB property.

Huh?

It's a method?

The line between method and property in VB is thin.  I think of the Move() property/method as something that assigns values, not something that does work on those values.