delphi4arab منتديات دلفي للعرب
تحميل ملف نصي الى قائمة popupmenu - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : تمارين دلفي وحلول (https://delphi4arab.net/forum/forumdisplay.php?fid=16)
+--- الموضوع : تحميل ملف نصي الى قائمة popupmenu (/showthread.php?tid=7947)



تحميل ملف نصي الى قائمة popupmenu - getsource - 22-06-2016

السلام عليكم 
كنت بحاجة الى هذا الكود واححبت ان اشارككم فيه ، لمن عنده طريقة افضل الرجاء الرد ومشكورين  الاخوة 
كود :
unit Unit1; interface uses  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  StdCtrls, Menus; type  TForm1 = class(TForm)    Edit1: TEdit;    Label1: TLabel;    Label2: TLabel;    Button1: TButton;    OpenDialog1: TOpenDialog;    Label3: TLabel;    Label4: TLabel;    PopupMenu1: TPopupMenu;    j1: TMenuItem;    procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  procedure LoadTextFileToPopup (Popup:TPopupMenu;TextFileName:String;uEvent:TNotifyEvent);  procedure Myclick(Sender: TObject);  end; var  Form1: TForm1; implementation {$R *.DFM} procedure TForm1.MyClick(Sender: TObject); begin    Edit1.Text := (sender as TMenuItem).Caption; end; procedure Tform1.LoadTextFileToPopup (Popup:TPopupMenu;TextFileName:String;uEvent:TNotifyEvent); var lst : TStringlist; i : integer; item:  TmenuItem; BEGIN     Lst := TStringlist.Create;     lst.LoadFromFile(TextFileName);     Popup.Items.Clear;     for i:=0 to lst.Count-1 do     begin          item      :=TMenuItem.Create(nil);          Item.caption := lst.Strings[i];          item.OnClick := uEvent;          Popup.Items.Add(item);     end;     lst.Sorted := true;     lst.Sort; END; procedure TForm1.Button1Click(Sender: TObject); begin    if OpenDialog1.Execute then    if Not FileExists(OpenDialog1.fileName) then    showmessage('fiel not found .. ')    else    begin      LoadTextFileToPopup( PopupMenu1,OpenDialog1.FileName,Myclick);      label4.Caption := OpenDialog1.FileName;    end; end; end.