a. Desain Form


        Menyesuaikan ukuran control secara otomatis yang terdapat di dalam sebuah form. Ketika Anda mengubah ukuran form saat run-time dengan cara men-drag pinggir form ke arah luar atau dengan cara me-maximize form, maka semua ukuran control dan atau hurufnya ikut menyesuaikan secara  proporsional. Khusus untuk control yang ukurannya sudah fix seperti checkbox dan optionbutton, maka hanya ukuran huruf  (caption)-nya saja yang berubah.

Persiapan: 1. Buat 1 Project baru dengan 1 Form.
2. Tempatkan beberapa control ke dalam form tersebut,
seperti: frame, textbox, optionbutton, checkbox,
combobox, commandbutton, dsb.
3. Copy-kan coding berikut ke dalam editor Form1

Listing Program :
Private lngFormWidth As Long
Private lngFormHeight As Long

Private Sub Form_Load()
Dim Ctl As Control
'Tempatkan dimensi form dalam variabel
lngFormWidth = ScaleWidth
lngFormHeight = ScaleHeight
'Tempatkan inisialisasi dimensi control
'dalam property Tag - dengan penanganan
'error untuk controls yang tidak memiliki
'properties seperti Top
'(misalnya: control Line)
'coding ini shrsnya jika error lanjut saja, sengaja dihilangkan
spy dapat diupload ke brinkster
For Each Ctl In Me
Ctl.Tag = Ctl.Left & " " & Ctl.Top & " " & _
Ctl.Width & " " & Ctl.Height & " "
Ctl.Tag = Ctl.Tag & Ctl.FontSize & " "
Next Ctl
On Error GoTo 0
End Sub

Private Sub Form_Resize()
Dim D(4) As Double
Dim i As Long
Dim TempPoz As Long
Dim StartPoz As Long
Dim Ctl As Control
Dim TempVisible As Boolean
Dim ScaleX As Double
Dim ScaleY As Double
'Hitung skala-nya
ScaleX = ScaleWidth / lngFormWidth
ScaleY = ScaleHeight / lngFormHeight
'coding ini shrsnya jika error lanjut saja, sengaja dihilangkan
spy dapat diupload ke brinkster
'Untuk setiap control yang terdapat di form
For Each Ctl In Me
TempVisible = Ctl.Visible
Ctl.Visible = False
StartPoz = 1
'Baca data dari property Tag
For i = 0 To 4
TempPoz = InStr(StartPoz, Ctl.Tag, " ", _
vbTextCompare)
If TempPoz > 0 Then
D(i) = Mid(Ctl.Tag, StartPoz, _
TempPoz - StartPoz)
StartPoz = TempPoz + 1
Else
D(i) = 0
End If
'Pindahkan control berdasarkan data
'di property Tag dan di skala form
Ctl.Move D(0) * ScaleX, D(1) * ScaleY, _
D(2) * ScaleX, D(3) * ScaleY
Ctl.Width = D(2) * ScaleX
Ctl.Height = D(3) * ScaleY
'Ganti ukuran huruf
If ScaleX < ScaleY Then
Ctl.FontSize = D(4) * ScaleX
Else
Ctl.FontSize = D(4) * ScaleY
End If
Next i
Ctl.Visible = TempVisible
Next Ctl
On Error GoTo 0
End Sub
 
What is New ?
 
Thank You Myspace Comments
DOWNLOAD :
 
E-LEARNING :
 
HIBURAN :
 
 
Today, there have been 1 visitors (2 hits) on this page!
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free