Customizing Chart Elements > Form Resizing |
Some applications permit the resizing of a Form object at runtime. This resizing is enabled at design time by setting the form's BorderStyle property to either 2 (Sizable) or 5 (Sizable ToolWindow).
To adjust the size of a Chart3D object when the Form object is resized, define a Resize procedure for the form, and adjust the chart's height and width to correspond to the form's height and width. Here is a sample Resize procedure:
Private Sub Form_Resize()
' Match the graph to the size of the form.
If Width > 700 Then ' Check the width of the window
' This keeps a consistent border around the
' sides of the chart
Chart3D1.Width = Width - 700
Else
' Sets the width to 0 because the window
' is smaller than the size of the chart
Chart3D1.Width = 0
End If
If Height > 1360 Then ' Check the height of the window
' This keeps a consistent border around the
' top and bottom of the chart
Chart3D1.Height = Height - 1360
Else
' Sets the height to 0 because the window is
' smaller than the size of the chart
Chart3D1.Height = 0
End If
End Sub
The height and width of both the form and the chart are measured in twips (1,440 twips equals one inch). To convert twips to pixels, use the following code:
pixwidth = Chart3D1.Width / Screen.TwipsPerPixelX
pixheight = Chart3D1.Height / Screen.TwipsPerPixelY