Wednesday, September 27, 2017

ໂປຣແກຣມ ທຳອິດຂອງທ່ານ ໃນ Delphi (Lesson 1)

ຄວາມແຕກຕາງຂອງໂປຣແກຣມ
ໃນ Delphi ໃຫ້ທ່ານສາມາດສ້າງໂປຣແກຣມ ແບບ GUI (Graphical User Interface) ຫລື Console (text-only) ແລະ ປະເພດອື່ນໆ
ໃນບົດນີ້ ເຮົາຈະຮຽນການຂຽນໂປຣແກຣມ ແບບ GUI
ຕົວຢ່າງ ສ້າງ ‘Hello World’ ໂປຣແກຣມ
ເມື່ອເຮົາເປີດໂປຣແກຣມ Delphi ມາທຳອິດ ຈະມີຫນ້າຕາງ ສຳລັບ ອອກແບບ ຫລື ຟອມນັ້ນເອງ ໃນນັ້ນຈະມີ ເມນູ, Code Editor ແລະ ອື່ນໆ
ຟອມ:
Image does not exist: https://image.ibb.co/n8hYdk/Blank_Form.gif

ເມນູ control ຕ່າງໆ:
Image does not exist: https://image.ibb.co/dozDdk/Standard_A.gif

ເມື່ອເຮົາເລືອກໃຊ້ Control Label ໃສ່ຟອມຈະເປັນແບບນີ້
Image does not exist: https://image.ibb.co/cPO0PQ/Form_Label.gif
ນອກນັ້ນເຮົາຍັງສາມາດກຳນົດ Property ຂອງ label ໃນ ຟອມໄດ້ທີ່ Object Inspector
Image does not exist: https://image.ibb.co/i8bbyk/Label_Caption.gif

ໃນຂັ້ນຕອນນີ້ ແມ່ນໃຫ້ທ່ານເພີ່ມ Button control ໃສ່ຟອມ
Image does not exist: https://image.ibb.co/dQffPQ/Form_Button.gif
ໃຫ້ Double Click ທີ່ Button control
Image does not exist: https://image.ibb.co/cRd0PQ/Button_Action.gif

ຈາກຮູບ ເຮົາຈະກຳນົດໃຫ້ Label1 ມີຄ່າ ດ້ວຍການກົດຄຳສັ່ງຈາກ Button ນັ້ນ
Image does not exist: https://image.ibb.co/gmBvPQ/Set_Caption.gif
ຂຽນໂຄ້ດ ກຳນົດໃຫ້ Label1 ມີຄ່າເທົ່າກັບ Hello Word
Image does not exist: https://image.ibb.co/iJGvPQ/Set_Caption_Done.gif
ຫລັງຈາກນັ້ນ ຣັນໂປຣແກຣມ ກົດ F9
Image does not exist: https://image.ibb.co/gm7kPQ/Run.gif
ເມື່ອກົດ Button ຈະເຫັນວ່າ Label1 ມີຄ່າເທົ່າ Hello Word
Image does not exist: https://image.ibb.co/fGF5PQ/RunPress.gif
ໃນ Delphi ຈະມີໂຄ້ດລວມໆໃນລັກສະນະນີ້ ທີ່ເກັບໃນໄຟ Unit1.pas

unit Unit1;
 
 interface
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls;
 
 type
   TForm1 = class(TForm)
     Label1: TLabel;      // The label we have added
     Button1: TButton;    // The button we have added
     procedure Button1Click(Sender: TObject);
   private
     { private declarations }
   public
     { public declarations }
   end;
 
 var
   Form1: TForm1;
 
 implementation
 
 {$R *.dfm}
 
 // The button action we have added
 procedure TForm1.Button1Click(Sender: TObject);
 begin
   Label1.Caption := 'Hello World';    // Label changed when button pressed
 end;
 
 end.

Subscribe

  • RSS Atom

ອອນລາຍ: 1 | ມື້ນີ້: 324 | ວານນີ້: 343 | ທິດນີ້: 762 | ເດືອນນີ້: 1541 | ປີນີ້: 12501 | ລວມ: 79604