0% found this document useful (0 votes)
48 views3 pages

OOP 1 (Object Oriented Programming) Rahmadi, SE

This document discusses animating forms and modifying a string grid with a combo box in Delphi. It provides code to: 1. Animate the opening of a menu form. 2. Create an elliptical shaped form and populate a combo box with options. 3. Sync the combo box to the focused cell of the string grid and update the cell with the selected combo box text.

Uploaded by

Haris Wahyu
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
48 views3 pages

OOP 1 (Object Oriented Programming) Rahmadi, SE

This document discusses animating forms and modifying a string grid with a combo box in Delphi. It provides code to: 1. Animate the opening of a menu form. 2. Create an elliptical shaped form and populate a combo box with options. 3. Sync the combo box to the focused cell of the string grid and update the cell with the selected combo box text.

Uploaded by

Haris Wahyu
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 3

1

OOP (Object Oriented Programming) dengan Delphi


MODUL8:
Tujuan : 1. Membuat Form Animasi
2. Modifikasi StringGrid dengan ComboBox

Aplikasi dalam Delphi


1. Buat Form Menu Seperti di bawah ini !!!

2. Buat Form Elips

3.Coding Program:
3.1.Form Menu
procedure Tform_menu.FormCreate(Sender: TObject);
begin
AnimateWindow(Self.Handle,999,AW_HOR_POSITIVE or AW_ACTIVATE);
end;

procedure Tform_menu.FormElips1Click(Sender: TObject);


begin
Form_Elips.Show;
end;

procedure Tform_menu.BackGroud1Click(Sender: TObject);


begin
if openpicturedialog1.Execute then
begin
image1.Picture.LoadFromFile(openpicturedialog1.FileName);
image1.Stretch:=true;
end;

OOP 1 (Object Oriented Programming)


Rahmadi, SE
2
end;
procedure Tform_menu.Exit1Click(Sender: TObject);
begin
If MessageDlg('Anda Yakin mau Menutup Aplikasi?',mtConfirmation, [mbYes, mbNo], 0)
= mrYes then
application.Terminate;
end;

3.2.Form Elips
procedure TForm_Elips.FormCreate(Sender: TObject);
begin
//code untuk animasi form
Setwindowrgn(form_elips.handle, CreateEllipticrgn(0,0, width, height), true);
horzscrollbar.Visible:=false;
vertscrollbar.Visible:=false;
//code untuk stringgrid
StringGrid1.DefaultRowHeight:=ComboBox1.Height;
//isi combobox
combobox1.Items.Clear;
combobox1.Items.Add('01');
combobox1.Items.Add('02');
combobox1.Items.Add('03');
combobox1.Items.Add('04');
combobox1.Items.Add('05');
combobox1.Items.Add('06');
combobox1.Items.Add('07');
combobox1.Items.Add('08');
combobox1.Items.Add('09');
combobox1.Items.Add('10');
end;

procedure TForm_Elips.Btn_BackGroundClick(Sender: TObject);


begin
if openpicturedialog1.Execute then
begin
image1.Picture.LoadFromFile(openpicturedialog1.FileName);
image1.Stretch:=true;
end;
end;

procedure TForm_Elips.StringGrid1DrawCell (sender:TObject;ACol, ARow:Integer;


Rect:Trect; State:TGridDrawState);
Var R:TRect;
Begin
If (ACol>=StringGrid1.FixedCols) and (ARow>=StringGrid1.FixedRows)
And (gdFocused in State) then
With ComboBox1 do
Begin
BringToFront;
CopyRect(R, Rect);
R.TopLeft:=Form_Elips.ScreenToClient(StringGrid1.ClientToScreen(R.TopLeft));

OOP 1 (Object Oriented Programming)


Rahmadi, SE
3
R.BottomRight:=Form_Elips.ScreenToClient
(StringGrid1.ClientToScreen(R.BottomRight));
SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.top);
End;
End;

procedure TForm_Elips.StringGrid1TopLeftChanged (sender:TObject);


Var R:TRect;
Begin
With StringGrid1 do
CopyRect(R, CellRect(Col, Row));

With ComboBox1 do
Begin
Visible:=False;
R.TopLeft:=Form_Elips.ScreenToClient(StringGrid1.ClientToScreen(R.TopLeft));
R.BottomRight:=Form_Elips.ScreenToClient
(StringGrid1.ClientToScreen(R.BottomRight));
SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.top);
End;

With StringGrid1 do
If (TopRow<=Row) and (TopRow+VisibleRowCount>Row) then Combobox1.Show;
End;

procedure TForm_Elips.ComboBox1Change(Sender: TObject);


begin
With StringGrid1 do
Cells[Col,Row]:=ComboBox1.Text;
end;

4. Project Manager

OOP 1 (Object Oriented Programming)


Rahmadi, SE

You might also like