Tham khảo Giáo trình lý thuyết và bài tập Borland Delphi NXB Lao Động-Xã Hội trang 207.

Một phần của tài liệu CHƯƠNG TRÌNH VẬT LÝ LỚP 12 NÂNG CAO NGÔN NGỮ LẬP TRÌNH DELPHI (Trang 32 - 62)

Sau khi đã Highlight nếu người dùng cĩ nhu cầu lưu trang sau khi Highlight thì người dùng Click vào biểu tượng và làm theo các chỉ dẫn của chương trình như hình sau:

Click vào đây, sẽ xuất hiện hộp thọai như hình bên dưới

GVHD: VƯƠNG TẤN SĨ Trang 33 SVTH: NGƠ MINH HẢI

Thốt khỏi chế độ Highlight: Khi cịn trong chế độ Hightlight, khi rê con trỏ vào vùng Highlight thì con trỏ cĩ hình dấu cộng “+” báo hiệu đang ở chế độ Highlight, để thốt khỏi chế độ Highlight người dùng Click vào biểu tượng

một lần nửa.

Trong quá trình nghiên cứu lý thuyết nếu muốn ghi lại những ghi chú cần thiết người dùng cĩ thể gọi Form ghi chú bằng cách Click vào biểu tượng

sẽ được Form ghi chú như hình sau:

Đoạn Code xử lý tình huống trên là:

{Xử lý tình huống khi người dùng kích chuột vào nút Ghi chú

procedure TFormbai1.SpeedButtonNoteClick(Sender: TObject); begin

FormNote.Show; //Hiển thị FormNote

Sau khi nghiên cứu tài liệu, người dùng cĩ thể vận dụng để làm các câu trắc nghiệm lựa chọn, để gọi Form trắc nghiệm người dùng Click vào biểu tượng

sẽ được Form như hình:

Đoạn Code xử lý tình huống trên là:

{Xử lý tình huống khi người dùng kích chuột vào nút trắc nghiệm}

procedure TFormbai1.SpeedButtontracnghiemClick(Sender: TObject); begin

Form1.Hide;//Ẩn Form chính

Formbai1.Hide; //Ẩn Form bài

Formtnbai1.show;//Hiện Form trắc nghiệm

end;

GVHD: VƯƠNG TẤN SĨ Trang 35 SVTH: NGƠ MINH HẢI

Trên đây là một đơn cử về việc thiết kế biểu mẫu và soạn thảo mã lệnh (viết Code) cho Form bài học, các bài cịn lại chúng ta cĩ thể thực hiện theo cách vào menu File| New| Other…

Chọn thẻ chứa tên dự án (Project) để tạo các Form cho các bài cịn lại.

Đối với các Form khác thì việc thiết kế biểu mẫu và soạn thảo mã lệnh cũng tương tự như phần đã trình bày ở trên. Sau khi thực hiện, chúng ta sẽ cĩ dược các Form tương ứng với các mục đích sử dụng khác nhau là:

Form chính: Dùng để giới thiệu chương trình Vật lý lớp 12 một cách xúc tích thơng qua các đoạn Clip giới thiệu cho từng chương, các Clip này được tác giả thiết kế rất cơng phu, từ đĩ giúp cho người dùng cĩ hứng thú muốn đi tiếp vào các phần trong của chương trình. Từ Form chính này người dùng cĩ thể theo các đường dẫn để đi đến tất cả nội dung của chương trình. Form cĩ giao diện như hình sau:

GVHD: VƯƠNG TẤN SĨ Trang 37 SVTH: NGƠ MINH HẢI

Form chương: Làm cầu nối cho phép người dùng truy xuất đến các Form bài học. Ví dụ Form chương 1 cĩ giao diện như hình sau:

Form trắc nghiệm: Là nơi chứa các câu hỏi dạng trắc nghiệm lựa chọn, giúp cho người dùng củng cố kiến thức trên cơ sở sau khi đã đọc tài liệu. Form được xây dựng khá bắt mắt, tạo cảm giác thoải mái và phấn khởi ngay từ cái nhìn đầu tiên. Bên cạnh việc làm trắc nghiệm, người dùng cịn cĩ thể bổ sung thêm kiến thức bằng cách vào xem tiểu sử của một vài nhà khoa học lỗi lạc trên thế giới. Form cĩ giao diện như hình sau:

GVHD: VƯƠNG TẤN SĨ Trang 39 SVTH: NGƠ MINH HẢI

Form ghi chú: Giúp cho người dùng trong quá trình nghiên cứu tài liệu cĩ được cơng cụ đơn giản, hữu dụng ghi lại những vất đề phát sinh. Form được thiết kế rất đơn giản và thật sự đĩng vai trị khơng thể thiếu khi đọc tài liệu. Form cĩ giao diện như hình sau: (adsbygoogle = window.adsbygoogle || []).push({});

Form đồng hồ: Trong trường hợp người dùng muốn định thời gian trong lúc làm trắc nghiệm thì cĩ thể sử dụng Form đồng hồ. Form được thiết kế nhỏ gọn, đơn giản và đầy đủ chức năng giúp cho việc ấn định thời gian làm bài một cách chính xác. Form cĩ giao diện như hình sau:

Form tiểu sử: Giới thiệu các nhà khoa học lỗi lạc trên thế giới, gĩp phần mở rộng hiểu biết của người dùng. Form cĩ giao diện như hình sau:

GVHD: VƯƠNG TẤN SĨ Trang 41 SVTH: NGƠ MINH HẢI

KẾT LUẬN

Những điều đạt được

Luận văn thể hiện được các yêu cầu của giả thiết đã đề ra trong đề tài: + Giới thiệu một cách cơ bản về ngơn ngữ lập trình Delphi 7.

+ Đưa ra được một dự án cụ thể để xây dựng Chương trình vật lý lớp 12 nâng cao, với đầy đủ các bước thựchiện từ đơn giản cho đến phức tạp. + Thu thập nguồn thơng tin, dữ liệu đưa vào chương trình khá đầy đủ. + Lập trình thiết kế bài trắc nghiệm tự động kiểm tra kết quả và tính điểm chính xác.

+ Làm phong phú thêm nội dung chương trình bằng tiểu sử tĩm tắt của các nhà khoa học.

Luận văn đã thể hiện được vai trị của tin học trong thời đại cơng nghệ mới, đặc biệt là sự ứng dụng tin học vào việc giải quyết những khĩ khăn trong giảng dạy và học vật lý nhằm đưa nền giáo dục của ta bắt kịp nhịp độ phát triển của xã hội.

Hướng phát triển của đề tài

Đề tài cĩ tính khả thi cao, ngoài chức năng làm nguồn tài liệu cho học sinh tự học và nghiên cứu, thì giáo viên cĩ thể sử dụng để hỗ trợ cho giảng dạy trong giảng dạy. Bên cạnh đĩ cũng được nhiều bạn sinh viên tìm hiểu, học tập và nghiên cứu.

Hạn chế của đề tài

Về cơ bản luận văn đã hồn thành tốt mục đích và nhiệm vụ mà đề tài đã đề ra. Bên cạnh đĩ mặc dù đã cố gắng rất nhiều nhưng do thời gian thực hiện đề tài cĩ hạn nên khơng khỏi những hạn chế và thiết sĩt, tơi rất mong được những gĩp ý tận tình, gĩp phần cho luận văn hoàn thiện hơn.

PHỤ LỤC

Mã lệnh cài đặt cho các phương thức xử lý của các đối tượng trong Form chính:

Tình huống Form khởi tạo:

procedure TForm1.FormCreate(Sender: TObject); var hSysMenu: HMenu;

begin hSysMenu:=GetSystemMenu(Handle,False); if hSysMenu >0 then EnableMenuItem(hSysMenu,SC_CLOSE,MF_BYCOMMAND or MF_DISABLED or MF_GRAYED); Imagethoat2.Visible:=False; Mediaplayerchinh.Display:=Paneldisplay; Mediaplayerchinh.DisplayRect:=Rect(0,0,Paneldisplay.Width,paneldisplay.Height ); Mediaplayerchinh.Notify:=True; Mediaplayerchinh.Visible:=true; Mediaplayerchinh.Play; end;

Tình huống Click vào “Chương 1” lần thứ nhất:

procedure TForm1.Labelchuong1Click(Sender: TObject); begin Formchuong1.Show; Labelchuong1.Left:=16; Labelchuong1.Top:=8; Labelchuong1.Font.Size:=18; Labelchuong1.Font.Color:=clwhite; end;

Tình huống Click vào “Chương 1” lần thứ hai:

procedure TForm1.Labelc1Click(Sender: TObject); begin

If (Mediaplayerchinh.Notify = True) then begin Paneldisplay.Visible:=False; Mediaplayerchinh.Visible:=False; speedbuttonfullscreen.Visible:=false; Mediaplayerchinh.Stop; end;

If (Mediaplayerc1.Notify = True) then begin

GVHD: VƯƠNG TẤN SĨ Trang 43 SVTH: NGƠ MINH HẢI

Mediaplayerc1.Visible:=False; Speedbuttonc1.Visible:=False; Mediaplayerc1.Stop;

end;

If (Mediaplayerc2.Notify = True) then begin Panelc2.Visible:=False; Mediaplayerc2.Visible:=False; Speedbuttonc2.Visible:=False; Mediaplayerc2.Stop; end;

If (Mediaplayerc3.Notify = True) then begin Panelc3.Visible:=False; Mediaplayerc3.Visible:=False; Speedbuttonc3.Visible:=False; Mediaplayerc3.Stop; end;

If (Mediaplayerc4.Notify = True) then begin Panelc4.Visible:=False; Mediaplayerc4.Visible:=False; Speedbuttonc4.Visible:=False; Mediaplayerc4.Stop; end; (adsbygoogle = window.adsbygoogle || []).push({});

If (Mediaplayerc5.Notify = True) then begin Panelc5.Visible:=False; Mediaplayerc5.Visible:=False; Speedbuttonc5.Visible:=False; Mediaplayerc5.Stop; end;

If (Mediaplayerc6.Notify = True) then begin Panelc6.Visible:=False; Mediaplayerc6.Visible:=False; Speedbuttonc6.Visible:=False; Mediaplayerc6.Stop; end;

If (Mediaplayerc7.Notify = True) then begin Panelc7.Visible:=False; Mediaplayerc7.Visible:=False; Speedbuttonc7.Visible:=False; Mediaplayerc7.Stop; end;

If (Mediaplayerc8.Notify = True) then begin

Panelc8.Visible:=False;

Speedbuttonc8.Visible:=False; Mediaplayerc8.Stop;

end;

If (Mediaplayerc9.Notify = True) then begin Panelc9.Visible:=False; Mediaplayerc9.Visible:=False; Speedbuttonc9.Visible:=False; Mediaplayerc9.Stop; end;

If (Mediaplayerc10.Notify = True) then begin Panelc10.Visible:=False; Mediaplayerc10.Visible:=False; Speedbuttonc10.Visible:=False; Mediaplayerc10.Stop; end;

If (Mediaplayer10c.Notify = True) then begin Panel10c.Visible:=False; Mediaplayer10c.Visible:=False; Speedbutton10c.Visible:=False; Mediaplayer10c.Stop; end; Mediaplayerc1.DisplayRect:=Rect(0,0,Panelc1.Width,panelc1.Height); Mediaplayerc1.Notify:=True; Mediaplayerc1.Visible:=True; Speedbuttonc1.Visible:=True; Panelc1.Visible:=True; Labeltenclip.Caption:='ĐỘNG LỰC HỌC VẬT RẮN'; If Labelchuong1.Left=312 then begin Labelchuong1.Left:=16; Labelchuong1.Top:=8; Labelchuong1.Font.Size:=18; Labelchuong1.Font.Color:=clwhite; end; If Labelchuong2.Left=312 then begin Labelchuong2.Left:=16; Labelchuong2.Top:=52; Labelchuong2.Font.Size:=18; Labelchuong2.Font.Color:=clwhite; end; If Labelchuong3.Left=312 then begin Labelchuong3.Left:=16; Labelchuong3.Top:=96;

GVHD: VƯƠNG TẤN SĨ Trang 45 SVTH: NGƠ MINH HẢI Labelchuong3.Font.Size:=18; Labelchuong3.Font.Color:=clwhite; end; If Labelchuong4.Left=312 then begin Labelchuong4.Left:=16; Labelchuong4.Top:=142; Labelchuong4.Font.Size:=18; Labelchuong4.Font.Color:=clwhite; end; If Labelchuong5.Left=312 then begin Labelchuong5.Left:=16; Labelchuong5.Top:=188; Labelchuong5.Font.Size:=18; Labelchuong5.Font.Color:=clwhite; end; If Labelchuong6.Left=312 then begin Labelchuong6.Left:=16; Labelchuong6.Top:=233; Labelchuong6.Font.Size:=18; Labelchuong6.Font.Color:=clwhite; end; If Labelchuong7.Left=312 then begin Labelchuong7.Left:=16; Labelchuong7.Top:=278; Labelchuong7.Font.Size:=18; Labelchuong7.Font.Color:=clwhite; end; If Labelchuong8.Left=312 then begin Labelchuong8.Left:=16; Labelchuong8.Top:=322; Labelchuong8.Font.Size:=18; Labelchuong8.Font.Color:=clwhite; end; If Labelchuong9.Left=312 then begin Labelchuong9.Left:=16; Labelchuong9.Top:=366; Labelchuong9.Font.Size:=18; Labelchuong9.Font.Color:=clwhite; end; If Labelchuong10.Left=312 then begin Labelchuong10.Left:=16; Labelchuong10.Top:=410; Labelchuong10.Font.Size:=18;

Labelchuong10.Font.Color:=clwhite; end; If Label10chuong.Left=190 then begin Label10chuong.Left:=16; Label10chuong.Top:=451; Label10chuong.Font.Size:=18; Label10chuong.Font.Color:=clwhite; end; Labelchuong1.Left:=312; Labelchuong1.Top:=0; Labelchuong1.Font.Size:=22; Labelchuong1.Font.Color:=clYellow; Labelc1.Visible:=False; end;

(Các “Chương” cịn lại làm tương tự)

Tình huống di chuyển chuột trên Form:

procedure TForm1.ImagenenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Labelc1.Visible:=False; Labelc2.Visible:=False; Labelc3.Visible:=False; Labelc4.Visible:=False; Labelc5.Visible:=False; Labelc6.Visible:=False; Labelc7.Visible:=False; Labelc8.Visible:=False; Labelc9.Visible:=False; Labelc10.Visible:=False; Label10c.Visible:=False; end;

Tình huống Click vào nút Full Screen:

procedure TForm1.SpeedButtonfullscreenClick(Sender: TObject); var R:TRect; begin Form1.WindowState:=wsMaximized; Paneldisplay.Top:=0; Paneldisplay.Left:=0; Paneldisplay.Height:=Form1.Height; Paneldisplay.Width:=Form1.Width; R.Left:=0; R.Top:=0; R.Bottom:=Paneldisplay.Height; R.Right:=Paneldisplay.Width; Mediaplayerchinh.DisplayRect:=R; Mediaplayerchinh.Play; end;

GVHD: VƯƠNG TẤN SĨ Trang 47 SVTH: NGƠ MINH HẢI

Tình huống Click trên Panelc1:

procedure TForm1.Panelc1Click(Sender: TObject); var R:TRect; begin Form1.WindowState:=wsNormal; Panelc1.Top:=166; Panelc1.Left:=178; Panelc1.Height:=346; Panelc1.Width:=476; R.Left:=0; R.Top:=0; R.Bottom:=Panelc1.Height; R.Right:=Panelc1.Width; Mediaplayerc1.DisplayRect:=R; end;

Tình huống di chuyển chuột trên nút thốt:

procedure TForm1.Imagethoat1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin

Imagethoat2.Visible:=True; end;

Tình huống Click vào nút thốt:

procedure TForm1.Imagethoat2Click(Sender: TObject); begin

close; end;

Mã lệnh cài đặt cho các phương thức xử lý của các đối tượng trong Form chương:

Tình huống di chuyển chuột đến nút “Bài 1”:

procedure TFormchuong1.SpeedButtonbai1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); (adsbygoogle = window.adsbygoogle || []).push({});

begin Labelbai1.Visible:=True; Imagebai1s.Picture:=Imagebai1.Picture; Imagebai1s.Height:=121; Imagebai1s.Width:=161; end;

Tình huống Click nút “Bài 1”:

procedure TFormchuong1.SpeedButtonbai1Click(Sender: TObject); begin

Formchuong1.Hide; Formbai1.Show; end;

(Các nút “Bài” cịn lại làm tương tự)

Tình huống di chuyển chuột trên Form:

procedure TFormchuong1.ImagenenMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin Labelbai1.Visible:=False; Labelbai2.Visible:=False; Labelbai3.Visible:=False; Labelbai4.Visible:=False; Labelbai5.Visible:=False; Labelbai6.Visible:=False; Labelbai7.Visible:=False; Labelbai8.Visible:=False; Labelbai9.Visible:=False; Imagebai1s.Height:=0; Imagebai1s.Width:=0; Imagebai2s.Height:=0; Imagebai2s.Width:=0; Imagebai3s.Height:=0; Imagebai3s.Width:=0; Imagebai4s.Height:=0; Imagebai4s.Width:=0; Imagebai5s.Height:=0; Imagebai5s.Width:=0; Imagebai6s.Height:=0; Imagebai6s.Width:=0; Imagebai7s.Height:=0; Imagebai7s.Width:=0; Imagebai8s.Height:=0; Imagebai8s.Width:=0; Imagebai9s.Height:=0; Imagebai9s.Width:=0; end;

Tình huống Click vào biểu tượng “Ngơi nhà”:

procedure TFormchuong1.SpeedButtonformchinhClick(Sender: TObject); begin

Form1.show; end;

GVHD: VƯƠNG TẤN SĨ Trang 49 SVTH: NGƠ MINH HẢI

Mã lệnh cài đặt cho các phương thức xử lý của các đối tượng trong Form bài học:

Tình huống Click vào nút “Mở”:

procedure TFormbai1.SpeedButtonmoClick(Sender: TObject); begin If speedbuttonmo.Down then begin Speedbuttonmo.Caption:='Đóng'; Imagesachmo.Visible:=True; Paneltrangsach.Visible:=True; end else begin Speedbuttonmo.Caption:='Mở'; Imagesachmo.Visible:=False; Paneltrangsach.Visible:=False; Panelshow.Visible:=False; end; end;

Tình huống di chuyển chuột trên trang sách:

procedure TFormbai1.trang1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Imagehienthi.Visible:=False; Imageshow.Picture:=trang1.Picture; Panelshow.Height:=Imageshow.Height+18; Panelshow.Width:=Imageshow.Width+18; Panelshow.Visible:=True; end;

Tình huống Click vào trang sách:

procedure TFormbai1.trang1Click(Sender: TObject); begin

Imagehienthi.Picture:=trang1.Picture; trang:=1;

Trang1.Visible:=False;

Labeltrang1.Font.Color:=clMaroon; If trang2.Visible = false then begin

Trang2.Visible:=True; end;

If trang3.Visible = false then begin

Trang3.Visible:=True; end;

If trang4.Visible = false then begin

Trang4.Visible:=True; end;

If trang5.Visible = false then begin

Trang5.Visible:=True; end;

If trang6.Visible = false then begin (adsbygoogle = window.adsbygoogle || []).push({});

Trang6.Visible:=True; end;

If trang7.Visible = false then begin

Trang7.Visible:=True; end;

If trang8.Visible = false then begin

Trang1.Visible:=True; end;

If trang9.Visible = false then begin

Trang9.Visible:=True; end;

end;

(Các trang cịn lại làm tương tự)

Tình huống Click vào biểu tượng “Cây viết”:

procedure TFormbai1.SpeedButtonPenClick(Sender: TObject); begin If SpeedButtonPen.Down then begin Panelmangche.Hide; Imagehienthi.Cursor:=crCross; Imagehienthi.Enabled:=True; Imagehienthi.AutoSize:=True; Speedbuttonzoomout.Enabled:=False; Speedbuttonzoomin.Enabled:=False;

ShowMessage('Hay chon mau can Highlight.'); end; If SpeedbuttonPen.Down=False then begin Panelmangche.Show; Imagehienthi.Enabled:=False; Imagehienthi.AutoSize:=False; Imagehienthi.Cursor:=crDefault; Speedbuttonzoomout.Enabled:=True; Speedbuttonzoomin.Enabled:=True; end; end;

GVHD: VƯƠNG TẤN SĨ Trang 51 SVTH: NGƠ MINH HẢI

Tình huống Click vào nút phĩng to:

procedure TFormbai1.SpeedButtonZoomOutClick(Sender: TObject); begin

Imagehienthi.ClientHeight:=Imagehienthi.Height+20; Imagehienthi.ClientWidth:=Imagehienthi.Width+20; end;

(Nút thu nhỏ tương tự)

Tình huống Click vào nút “Save”:

procedure TFormbai1.SpeedButtonSaveClick(Sender: TObject); begin

if SaveDialog.Execute then

Imagehienthi.Picture.SaveToFile(SaveDialog.FileName); end;

Tình huống di chuyển chuột đến dịng chữ “Xem hìnhđúng cỡ”:

procedure TFormbai1.Labelphongto1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin Imagehienthi.Visible:=False; Labelphongto2.Visible:=True; Imagephongto.Picture:=Imageslideshow.Picture; Imagephongto.Visible:=True; end;

Mã lệnh cài đặt cho các phương thức xử lý của các đối tượng trong Form trắc nghiệm:

Tình huống rê chuột lên vùng chứa câu hỏi:

procedure TFormtnbai1.ImagemangMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin

Panelmang.Visible:=False; end;

Tình huống rê chuột lên câu hỏi: (adsbygoogle = window.adsbygoogle || []).push({});

procedure TFormtnbai1.Imagecau9MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin

Panelhienthi.Visible:=False;

Imageshow.Picture:=Imagecau9.Picture; Panelshow.Height:=Imageshow.Height+18; Panelshow.Width:=Imageshow.Width+18;

Panelshow.Visible:=True; end;

Tình huống Click chọn câu hỏi:

procedure TFormtnbai1.Imagecau9Click(Sender: TObject); begin

if (cau = 1)and (chon = 'A') then i1:=1;

if (cau = 2)and (chon = 'B') then i2:=1;

if (cau = 3)and (chon = 'C') then i3:=1;

if (cau = 4)and (chon = 'D') then i4:=1;

if (cau = 5)and (chon = 'A') then i5:=1;

if (cau = 6)and (chon = 'A') then i6:=1;

if (cau = 7)and (chon = 'B') then i7:=1;

if (cau = 8)and (chon = 'C') then i8:=1;

if (cau = 9)and (chon = 'D') then i9:=1;

if (cau = 10)and (chon = 'A') then i10:=1; Panelhienthi.Visible:=True; Imagehienthi.Picture:=Imagecau9.Picture; cau:=9; radiogroupabcd.ItemIndex:=-1; Imagecau9.Visible:=False; Labelcau9.Font.Color:=clMaroon; Imagecopycau9.Picture:=Imagecau9.Picture; if Imagecau1.Visible = false then

begin

Imagecau1.Picture:= Imagecopycau1.Picture; Imagecau1.Visible:=true;

end;

if Imagecau2.Visible = false then begin

Imagecau2.Picture:= Imagecopycau2.Picture; Imagecau2.Visible:=true;

end;

if Imagecau3.Visible = false then begin

Imagecau3.Picture:= Imagecopycau3.Picture; Imagecau3.Visible:=true;

end;

GVHD: VƯƠNG TẤN SĨ Trang 53 SVTH: NGƠ MINH HẢI

begin

Imagecau4.Picture:= Imagecopycau4.Picture; Imagecau4.Visible:=true;

end; (adsbygoogle = window.adsbygoogle || []).push({});

if Imagecau5.Visible = false then begin

Imagecau5.Picture:= Imagecopycau5.Picture; Imagecau5.Visible:=true;

end;

if Imagecau7.Visible = false then begin

Imagecau7.Picture:= Imagecopycau7.Picture; Imagecau7.Visible:=true;

end;

if Imagecau8.Visible = false then begin

Imagecau8.Picture:= Imagecopycau8.Picture; Imagecau8.Visible:=true;

end;

if Imagecau6.Visible = false then begin

Imagecau6.Picture:= Imagecopycau6.Picture; Imagecau6.Visible:=true;

end;

if Imagecau10.Visible = false then begin

Imagecau10.Picture:= Imagecopycau10.Picture; Imagecau10.Visible:=true;

end; end;

(Các câu cịn lại làm tương tự)

Tình huống Click chọn đáp án:

procedure TFormtnbai1.RadioGroupabcdClick(Sender: TObject); begin chon:=''; if radiogroupabcd.ItemIndex = 0 then chon:='A'; if radiogroupabcd.ItemIndex = 1 then chon:='B'; if radiogroupabcd.ItemIndex = 2 then chon:='C'; if radiogroupabcd.ItemIndex = 3 then chon:='D'; end;

Tình huống Click nút “Xong”:

procedure TFormtnbai1.SpeedButtonxongClick(Sender: TObject); begin

Panelhienthi.Visible:=True; radiogroupabcd.ItemIndex:=-1;

Imagehienthi.Picture:=Imagecopyhienthi.Picture; if (cau = 1)and (chon = 'A') then

i1:=1;

if (cau = 2)and (chon = 'B') then i2:=1;

if (cau = 3)and (chon = 'C') then i3:=1;

if (cau = 4)and (chon = 'D') then i4:=1;

if (cau = 5)and (chon = 'A') then i5:=1;

if (cau = 6)and (chon = 'A') then i6:=1;

if (cau = 7)and (chon = 'B') then i7:=1;

if (cau = 8)and (chon = 'C') then i8:=1; (adsbygoogle = window.adsbygoogle || []).push({});

if (cau = 9)and (chon = 'D') then i9:=1;

if (cau = 10)and (chon = 'A') then i10:=1;

if Imagecau1.Visible = false then begin

Imagecau1.Picture:= Imagecopycau1.Picture; Imagecau1.Visible:=true;

end;

if Imagecau2.Visible = false then begin

Imagecau2.Picture:= Imagecopycau2.Picture; Imagecau2.Visible:=true;

end;

if Imagecau3.Visible = false then begin

Imagecau3.Picture:= Imagecopycau3.Picture; Imagecau3.Visible:=true;

end;

if Imagecau4.Visible = false then begin

Imagecau4.Picture:= Imagecopycau4.Picture; Imagecau4.Visible:=true;

end;

if Imagecau5.Visible = false then begin

GVHD: VƯƠNG TẤN SĨ Trang 55 SVTH: NGƠ MINH HẢI

Imagecau5.Visible:=true; end;

if Imagecau6.Visible = false then begin

Imagecau6.Picture:= Imagecopycau6.Picture; Imagecau6.Visible:=true;

end;

if Imagecau7.Visible = false then begin

Imagecau7.Picture:= Imagecopycau7.Picture; Imagecau7.Visible:=true;

end;

if Imagecau8.Visible = false then begin

Imagecau8.Picture:= Imagecopycau8.Picture; Imagecau8.Visible:=true;

end;

if Imagecau9.Visible = false then begin

Imagecau9.Picture:= Imagecopycau9.Picture; Imagecau9.Visible:=true;

end;

if Imagecau10.Visible = false then begin (adsbygoogle = window.adsbygoogle || []).push({});

Imagecau10.Picture:= Imagecopycau10.Picture; Imagecau10.Visible:=true;

end;

i:=i1+i2+i3+i4+i5+i6+i7+i8+i9+i10;

ShowMessage('Ban lam dung ' + IntToStr(i) + '/10 cau.'); cau:=0;

chon:='';

speedbuttonll.Enabled:=true; end;

Tình huống Click nút “Làm lại”:

procedure TFormtnbai1.SpeedButtonllClick(Sender: TObject); begin cau:=0; i1:=0; i2:=0; i3:=0; i4:=0; i5:=0; i6:=0; i7:=0; i8:=0; i9:=0; i10:=0; Panelhienthi.Visible:=True;

radiogroupabcd.ItemIndex:=-1;

Imagehienthi.Picture:=Imagecopyhienthi.Picture; if Imagecau1.Visible = false then

begin

Imagecau1.Picture:= Imagecopycau1.Picture; Imagecau1.Visible:=true;

end;

if Imagecau2.Visible = false then begin

Imagecau2.Picture:= Imagecopycau2.Picture; Imagecau2.Visible:=true;

end;

if Imagecau3.Visible = false then begin

Imagecau3.Picture:= Imagecopycau3.Picture; Imagecau3.Visible:=true;

end;

if Imagecau4.Visible = false then begin

Imagecau4.Picture:= Imagecopycau4.Picture; Imagecau4.Visible:=true;

end;

if Imagecau5.Visible = false then begin

Imagecau5.Picture:= Imagecopycau5.Picture; Imagecau5.Visible:=true;

end;

if Imagecau6.Visible = false then begin

Imagecau6.Picture:= Imagecopycau6.Picture; Imagecau6.Visible:=true;

end;

if Imagecau7.Visible = false then begin

Imagecau7.Picture:= Imagecopycau7.Picture; Imagecau7.Visible:=true; (adsbygoogle = window.adsbygoogle || []).push({});

end;

if Imagecau8.Visible = false then begin

Imagecau8.Picture:= Imagecopycau8.Picture; Imagecau8.Visible:=true;

end;

if Imagecau9.Visible = false then begin

Imagecau9.Picture:= Imagecopycau9.Picture; Imagecau9.Visible:=true;

end;

if Imagecau10.Visible = false then begin

GVHD: VƯƠNG TẤN SĨ Trang 57 SVTH: NGƠ MINH HẢI Imagecau10.Visible:=true; end; labelcau1.Font.Color:=clWhite; labelcau2.Font.Color:=clWhite; labelcau3.Font.Color:=clWhite; labelcau4.Font.Color:=clWhite; labelcau5.Font.Color:=clWhite; labelcau6.Font.Color:=clWhite; labelcau7.Font.Color:=clWhite; labelcau8.Font.Color:=clWhite; labelcau9.Font.Color:=clWhite; labelcau10.Font.Color:=clWhite; end;

Mã lệnh cài đặt cho các phương thức xử lý của các đối tượng trong Form ghi chú:

Tình huống Click nút “Clear”:

procedure TFormNote.ClearClick(Sender: TObject); begin

memonote.Clear; end;

Tình huống Click nút “Cut”:

procedure TFormNote.CutClick(Sender: TObject); begin

memonote.CutToClipboard; paste.Enabled:=true;

end;

Tình huống Click nút “Copy”:

procedure TFormNote.CopyClick(Sender: TObject); begin

memonote.CopyToClipboard; paste.Enabled:=true;

end;

Tình huống Click nút “Paste”:

procedure TFormNote.PasteClick(Sender: TObject); begin

memonote.PasteFromClipboard; end;

Mã lệnh cài đặt cho các phương thức xử lý của các đối tượng trong Form đồng hồ:

Tình huống Click nút “Set Time”:

procedure TFormdongho.SpeedButtondinhphutClick(Sender: TObject); var phut:String; begin labelp.Caption:='00'; labelg.Caption:='00'; i:=0; p:=0; g:=0;

phut:=InPutbox('Dinh thoi gian lam bai','So phut lam bai:','15'); If TryStrToInt(phut,p) then

If p=0 then ShowMessage('Ban khong the lam bai trong "0" phut!') else

begin t:=60; (adsbygoogle = window.adsbygoogle || []).push({});

speedbuttonbatdau.Enabled:=true;

labelthoigian.Caption:='Bạn sẽ làm bài trong '+IntToStr(p)+' phút.'; g:=p*60;

for i:=1 to p do a[i]:=i;

end

else ShowMessage('Ban chon thoi gian chua dung !'); end;

Tình huống Click nút “Start”:

procedure TFormdongho.SpeedButtonbatdauClick(Sender: TObject); begin timerdongho.Enabled:=True; Speedbuttonngung.Enabled:=true; speedbuttonnghi.Enabled:=true; end; Tình huống Click nút “Pause”:

procedure TFormdongho.SpeedButtonngungClick(Sender: TObject); begin If speedbuttonngung.Down then timerdongho.Enabled:=False else timerdongho.Enabled:=true; end; Tình huống Click nút “Stop”:

GVHD: VƯƠNG TẤN SĨ Trang 59 SVTH: NGƠ MINH HẢI

begin

timerdongho.Enabled:=false;

speedbuttonbatdau.Enabled:=False; speedbuttonngung.Enabled:=False;

ShowMessage('Ban da su dung het '+IntToStr(p-1-StrToInt(labelp.Caption))+' phut'+' '+IntToStr(60-StrToInt(labelg.Caption))+' giay.');

end;

Tình huống Click nút “Hide”:

procedure TFormdongho.SpeedButton1Click(Sender: TObject); begin

Formdongho.Hide; end;

Mã lệnh cài đặt cho các phương thức xử lý của các đối tượng trong Form tiểu sử:

Tình huống khởi tạo Form:

procedure TFormtrongsuot.FormCreate(Sender: TObject); var frmRegion, tempRegion:HRGN;

i:Integer; Arect:TRect; begin

frmRegion:=0;

For i:=0 to ControlCount -1 do begin aRect:=Controls[i].BoundsRect; OffsetRect(aRect,clientorigin.X-left,clientorigin.Y-top); tempRegion:=CreateRectRgnIndirect(aRect); If frmRegion=0 then frmRegion:=tempRegion Else begin CombineRgn(frmRegion,frmRegion,tempRegion,RGN_OR); DeleteObject(tempRegion); end; end; tempRegion:=CreateRectRgn(0,0,0,0);

CombineRgn(frmRegion, frmRegion, tempRegion, RGN_OR); DeleteObject(tempRegion);

SetWindowRgn(handle,frmRegion,true); end;

Tình huống rê chuột trên hình:

procedure TFormtrongsuot.ImageanhnhoMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin

Panelto.Visible:=True; Timer5giay.Enabled:=True; end;

Tình huống Click nút “Next”: (adsbygoogle = window.adsbygoogle || []).push({});

procedure TFormAccimet.SpeedButtontoiClick(Sender: TObject); begin

inherited;

Formaccimet.Hide; FormAmbe.show; end;

GVHD: VƯƠNG TẤN SĨ Trang 61 SVTH: NGƠ MINH HẢI

TÀI LIỆU THAM KHẢO

1- Phĩ Đức Hịa – Ngơ Quang Sơn: Ứng dụng cơng nghệ thơng tin trong dạy học tích cực, NXB Giáo Dục tháng 04 năm 2008.

2-Đào Văn Phúc – Thế Trường – Vũ Thanh Khiết: Truyện kể về các

nhà bác học vật lý, NXB Giáo Dục tháng 08 năm 1998.

3-Nhà xuất bản giáo dục: Các kỹ xảo lập trình với Microsoft Visual

Basic & Borland Delphi.

4-Nhà xuất bản giáo dục: Vật lý 12 nâng cao.

5-Nhà xuất bản lao động-xã hội: Giáo trình lý thuyết & bài tập Borland

Delphi.

6-Khoa khoa học Đại học Cần Thơ: Giáo trình Lập trình căn bản B

(Delphi).

7-Tạp chí Vật lý & Tuổi trẻ - Hội Vật lý Việt Nam 2009. 8-Các Website:

www.onthi.com www.giaovien.net

www.vatlysupham.com.vn www.wikipedia.vn

Một phần của tài liệu CHƯƠNG TRÌNH VẬT LÝ LỚP 12 NÂNG CAO NGÔN NGỮ LẬP TRÌNH DELPHI (Trang 32 - 62)