Cara mengontrol componen menggunakan combobok
delphi 2010
Oleh:
JOKO TURWANTO
NIM : 2011.15.458.0016
JURUSAN
TEKNIK INFORMATIKA
FAKULTAS
TEKNIK
UNIVERSITAS WAHIDIYAH
Untuk langkah awal kali ini kita akan membuat
bagai mana cara mengontrol komponen 2 yang kita buat pada delphi 2010 seperti mengubah by ground membikin warna
tilisan mengubah ukuran tulisan mengganti2 gambar dll untuk lebih lengkapnya
langsung saja kita praktekkan biar ga bosen materi terus dalam pmbuatan kali
ini kita bisa membuat form terlebih dahulu komponennya antara lain : di bawah ini dan untuk panel di letakan di paling
bawah.
Nama komponen
|
Caption
|
Name
|
TComboBox
|
Merubah ukuran size DesainProgramer
|
JokoSizeDesainProgramer
|
TComboBox
|
Merubah warna size DesainProgramer
|
JokoColorSize
|
TComboBox
|
Meruah warna byground
|
JokoWarnaByground
|
TComboBox
|
miring tebal garis bawah
|
JokoMiringTebalGbawah
|
TComboBox
|
Mengganti-ganti gambar
|
JokoImage
|
Timage
|
-
|
Ab
|
Timage
|
-
|
Ac
|
Timage
|
-
|
Ad
|
Timage
|
-
|
Image3
|
Ttimer
|
-
|
Timer1
|
Ttimer
|
-
|
Timer2
|
Ttimer
|
-
|
Timer3
|
Ttimer
|
Timer4
|
|
Tlabil
|
N ri
|
Nri
|
Tlabil
|
Uniwa
|
Uniwa
|
Tlabil
|
C
|
|
Tlabil
|
Designprogram717
|
Jalan
|
Tpanel
|
-
|
Waktu
|
Oy untuk t image kita bisa pilih sendiri sesuai
dengan keinginan kita untuk mempercantik tampilan caranya pilih properti kemu dian
pictur cari dech gambarnya sesuai kesukaan kita
Untuk form utamama masukan kode seperti di bawah ini pilih kode yang terletak
di bawah form kan ada tiga pilihan yaitu
kode,
design dan histori klik satu kali di kode pastikan kode sama persis di bawah ini Kalaw sekiranya caption terlalu panjang udah
sesuaikan saja dengan keinginan kita
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, ExtCtrls, StdCtrls, jpeg;
type
TForm2
= class(TForm)
JokoSizeDesainProgramer: TComboBox;
JokoColorSize: TComboBox;
JokoWarnaByground: TComboBox;
JokoMiringTebalGbawah: TComboBox;
JokoImage: TComboBox;
ab:
TImage;
ac:
TImage;
Image3: TImage;
jalan: TLabel;
waktu2: TPanel;
Timer1: TTimer;
Timer2: TTimer;
Timer3: TTimer;
ad:
TImage;
UNIWA: TLabel;
NRI:
TLabel;
Timer4: TTimer;
c:
TLabel;
procedure JokoSizeDesainProgramerChange(Sender: TObject);
procedure JokoColorSizeChange(Sender: TObject);
procedure JokoWarnaBygroundChange(Sender: TObject);
procedure JokoMiringTebalGbawahChange(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure JokoImageChange(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure Timer4Timer(Sender: TObject);
private
{
Private declarations }
public
{
Public declarations }
end;
var
Form2:
TForm2;
implementation
{$R *.dfm}
Klik combobox Merubah ukuran size DesainProgramer
pilih even onchange lalu masukan kode seperti di bawah ini
procedure
TForm2.JokoSizeDesainProgramerChange(Sender: TObject);
begin
if JokoSizeDesainProgramer.Text='5' then
jalan.font.Size:=5;
if JokoSizeDesainProgramer.Text='8' then
jalan.font.Size:=8;
if JokoSizeDesainProgramer.Text='10' then
jalan.font.Size:=10;
if JokoSizeDesainProgramer.Text='11' then
jalan.font.Size:=11;
if JokoSizeDesainProgramer.Text='12' then
jalan.font.Size:=12;
if JokoSizeDesainProgramer.Text='14' then
jalan.font.Size:=14;
if JokoSizeDesainProgramer.Text='16' then
jalan.font.Size:=16;
if JokoSizeDesainProgramer.Text='18' then
jalan.font.Size:=18;
if JokoSizeDesainProgramer.Text='20' then
jalan.font.Size:=20;
if JokoSizeDesainProgramer.Text='21' then
jalan.font.Size:=21;
if JokoSizeDesainProgramer.Text='22' then
jalan.font.Size:=22;
if JokoSizeDesainProgramer.Text='24' then
jalan.font.Size:=24;
end;
di dalam combobox ini kita bisa pilih/masukan didalam
properti lalu pilih item tulis 5 enter
8enter 10 begitu seterusnya sampai 24
dan evennya adalh on change
Klik combobox Mengganti-ganti
gambar pilih even onchange lalu masukan kode seperti di bawah ini
procedure TForm2.JokoImageChange(Sender:
TObject);
begin
if JokoImage.Text='AQ DAN MYFRIEND' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto edit/FOTO
EDIT/AQ.BMP');
if JokoImage.Text='UNIWA' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/UNIWA.BMP');
if JokoImage.Text='TASBIH' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/TASBIH.BMP');
if JokoImage.Text='ALLAH' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/ALLAH.BMP');
if JokoImage.Text='BAGUS' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/PROFIL.BMP');
if JokoImage.Text='GURUN' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/editor.BMP');
if JokoImage.Text='TENGKORAK' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/kkhg.BMP');
if JokoImage.Text='KOMPUTER' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/jdv.BMP');
if JokoImage.Text='LOGO UNIWA' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/uniwa.BMP');
if JokoImage.Text='KENANGAN' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/kenangan.BMP');
if JokoImage.Text='B.POWEL' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/z.BMP');
if JokoImage.Text='PANCASILA' then
IMAGE3.PICTURE.LOADFROMFILE('E:/foto foto/foto edit/OK.BMP');
if JokoImage.Text='NONE' then
IMAGE3.Picture.Icon;
end;
di dalam combo box ini kita bisa pilih/masukan didalam
properti lalu pilih item tulis KOMPUTER enter logo LOGO UNIWA enter KENANGAN
begitu seterusnya sampai SEBANYAK GAMBAR YANG KITA PANGGIL CONTOH KITA NYIMPAN
GAMBARNYA ('E:/foto foto/foto edit/jdv.BMP'); DIUSAHAKAN FORMAT GAMBARNYA BMP
dan evennya adalh on change
Klik combobox Merubah warna size DesainProgramer
pilih even onchange lalu masukan kode seperti di bawah ini
procedure TForm2.JokoColorSizeChange(Sender:
TObject);
begin
if JokoColorSize.Text='MERAH' then
jalan.Font.Color:=(clred);
if JokoColorSize.Text='HIJAU' then
jalan.Font.Color:=(CLTEAL);
if JokoColorSize.Text='KUNING' then
jalan.Font.Color:=(clYELLOW);
if JokoColorSize.Text='BIRU' then
jalan.Font.Color:=(clBLUE);
if JokoColorSize.Text='HIJAU DAUN' then
jalan.Font.Color:=(clLIME);
if JokoColorSize.Text='PUTIH' then
jalan.Font.Color:=(clCREAM);
if JokoColorSize.Text='HITAM' then
jalan.Font.Color:=(clBLACK);
if JokoColorSize.Text='UNGU' then
jalan.Font.Color:=(CLPURPLE);
if JokoColorSize.Text='PINK' then
jalan.Font.Color:=(CLFUCHSIA);
if JokoColorSize.Text='COKLAT' then
jalan.Font.Color:=(CLMAROON);
end;
di dalam combobox ini kita bisa pilih/masukan didalam
properti lalu pilih item tulis HIJAU
enter KUNINGenter BIRU begitu seterusnya sampai COKLAT
dan evennya adalh on change
Klik combobox Merubah warna by bround DesainProgramer
pilih even onchange lalu masukan kode seperti di bawah ini
procedure
TForm2.JokoWarnaBygroundChange(Sender: TObject);
begin
if JokoWarnaByground.Text='MERAH' then
form2.Color:=(clred);
if JokoWarnaByground.Text='TEAL' then
form2.Color:=(CLTEAL);
if JokoWarnaByground.Text='KUNING' then
form2.Color:=(clYELLOW);
if JokoWarnaByground.Text='BIRU' then
form2.Color:=(clBLUE);
if JokoWarnaByground.Text='HIJAU DAUN' then
form2.Color:=(clLIME);
if JokoWarnaByground.Text='PUTIH' then
form2.Color:=(clCREAM);
if JokoWarnaByground.Text='HITAM' then
form2.Color:=(clBLACK);
if JokoWarnaByground.Text='UNGU' then
form2.Color:=(CLPURPLE);
if JokoWarnaByground.Text='PINK' then
form2.Color:=(CLFUCHSIA);
if JokoWarnaByground.Text='COKLAT' then
form2.Color:=(CLMAROON);
end;
di dalam combobox ini kita bisa pilih/masukan didalam
properti lalu pilih item tulis MERAH
enter TEALenter KUNING begitu seterusnya sampai COKLAT
lalu klik 2kali pad TIMER1dan masukan kode
seperti di bawah ini untuk menampilkaan waktu
procedure TForm2.Timer1Timer(Sender: TObject);
begin
waktu2.Caption:=FormatDateTime('dddd, dd mmmm
yyyy (hh:mm:ss)',Now);
end;
klik 2 kali padatimer dua
procedure TForm2.Timer2Timer(Sender: TObject);
begin
if jalan.Left<-jalan.Width then
jalan.Left:=Width
else
jalan.Left:=jalan.Left-1;
end;
klik 2 kali pada timer3
procedure TForm2.Timer3Timer(Sender: TObject);
begin
ab.PICTURE.LOADFROMFILE('E:/foto
foto/image/uniwa wahidiyah.BMP');
ad.PICTURE.LOADFROMFILE('E:/foto
foto/image/v.BMP');
ac.PICTURE.LOADFROMFILE('E:/foto foto/foto
edit/ok.BMP');
if ab.Visible=true then ab.Visible:=false
else
ab.Visible:=true;
if ad.Visible=true then ad.Visible:=false
else
if ac.Visible=true then ac.Visible:=false
else
ac.Visible:=true;
end;
klik 2 kali pada timer4
procedure TForm2.Timer4Timer(Sender: TObject);
begin
UNIWA.Font.color:=rgb(random(255),random(255),random(255));
NRI.Font.color:=rgb(random(255),random(255),random(255));
C.caption:=('');
if UNIWA.Visible=true then UNIWA.Visible:=false
else
UNIWA.Visible:=true;
if C.Visible=true then C.Visible:=false
else
if NRI.Visible=true then NRI.Visible:=false
else
NRI.Visible:=true;
end;
pada combobok miring tebal garis bawah pilih
even on change dan masukan kode seperti di bawah ini
procedure
TForm2.JokoMiringTebalGbawahChange(Sender: TObject);
begin
if
JokoMiringTebalGbawah.Text='Gbawah,Tebal,Miring
' then jalan.Font.Style:=[fsunderline,fsbold,fsitalic];
if JokoMiringTebalGbawah.Text='garis
Bawah,Miring' then jalan.Font.Style:=[fsunderline,fsitalic];
if JokoMiringTebalGbawah.Text='Garis
Bawah,Tebal' then jalan.Font.Style:=[fsunderline,fsbold];
if JokoMiringTebalGbawah.Text='Miring,Tebal'
then jalan.Font.Style:=[fsbold,fsitalic];
if JokoMiringTebalGbawah.Text='Garis
Bawah,Tebal' then jalan.Font.Style:=[fsunderline,fsbold];
if JokoMiringTebalGbawah.Text='Garis Bawah'
then jalan.Font.Style:=[fsunderline];
if JokoMiringTebalGbawah.Text='Miring' then
jalan.Font.Style:=[fsitalic];
if JokoMiringTebalGbawah.Text='Tebal' then
jalan.Font.Style:=[fsbold];
end;
end.
POKOKNYA SETIAP COMBOBOX ITEMNYA HARUS DI
SESUAIKAN DENGAN NAMA YANG AKAN KITA PANGGIL dan untuk timer kita bisa mengatur kecepatanya di properti interval atau yang kita bikin
g_mail :dprwscout717@gmail.com
blok :designprogram717.blokspot.com
no hp : 082302577717


Tidak ada komentar:
Posting Komentar