12-07-2020, 11:18 PM
(23-06-2020, 05:14 AM)zouzou05 كتب :تقدر تعملها بالطريقة التالية :(22-06-2020, 10:25 AM)sofiane201 كتب : يبدو أن لديك خلط في فهم المتغيرات.اليونيت الاولى ..
من فضلك أرفق المشروع ان استطعت
كود :unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Menus, ComCtrls, Grids, DBGrids, DB, ADODB, DBCtrls, Buttons, Vcl.Mask, tlhelp32; type TForm1 = class(TForm) ADOConnection1: TADOConnection; ADOTable1: TADOTable; DataSource1: TDataSource; DBGrid1: TDBGrid; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; label1: TLabel; label3: TLabel; label2: TLabel; DBNavigator1: TDBNavigator; button2: TBitBtn; button1: TBitBtn; procedure button1Click(Sender: TObject); procedure button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} procedure TForm1.button1Click(Sender: TObject); var x: MyThread; begin x := MyThread.Create(false); end; procedure TForm1.button2Click(Sender: TObject); var x: MyThread; begin x.terminate end; end; end.
اليونيت الثانية ..
كود :unit Unit2; interface uses System.Classes, Unit1; type MyThread = class(TThread) private { Private declarations } protected procedure Execute; override; end; implementation procedure MyThread.Execute; begin if Form1.Edit1.Text > '' then begin Form1.ADOTable1.Locate('Field1', Form1.Edit1.Text, [loPartialKey]); Form1.Label1.Caption := Form1.ADOTable1.FieldByName('Field2').Value; Form1.Label2.Caption := Form1.ADOTable1.FieldByName('Field3').Value; Form1.Label3.Caption := Form1.ADOTable1.FieldByName('Field1').Value; end; if Form1.Edit2.Text > '' then begin Form1.ADOTable1.Locate('Field2', Form1.Edit2.Text, [loPartialKey]); Form1.Label1.Caption := Form1.ADOTable1.FieldByName('Field2').Value; Form1.Label2.Caption := Form1.ADOTable1.FieldByName('Field3').Value; Form1.Label3.Caption := Form1.ADOTable1.FieldByName('Field1').Value; end; if Form1.Edit3.Text > '' then begin Form1.ADOTable1.Locate('Field3', Form1.Edit3.Text, [loPartialKey]); Form1.Label1.Caption := Form1.ADOTable1.FieldByName('Field2').Value; Form1.Label2.Caption := Form1.ADOTable1.FieldByName('Field3').Value; Form1.Label3.Caption := Form1.ADOTable1.FieldByName('Field1').Value; end ; end; end.
كود :
procedure TMyThread.Execute;
begin
while not Terminated do begin
// هنا ضع الكود
end;
end;كود :
MyThread.Terminate;

![[-]](https://delphi4arab.net/forum/D4A2020/collapse.png)