unit
Unit28;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls;
type
TForm28 =
class
(TForm)
procedure
FormCreate(Sender: TObject);
procedure
PopupMenuItemClick(Sender: TObject);
end
;
var
Form28: TForm28;
implementation
Uses
IniFiles, Clipbrd;
{$R *.dfm}
procedure
TForm28
.
FormCreate(Sender: TObject);
Var
IniFile: TIniFile;
IniSection: TStringList;
SubMenu: TMenuItem;
i:
Integer
;
begin
PopupMenu := TPopupMenu
.
Create(Self);
PopupMenu
.
AutoHotkeys := maManual;
PopupMenu
.
Items
.
Add(TMenuItem
.
Create(Self));
SubMenu := PopupMenu
.
Items[PopupMenu
.
Items
.
Count -
1
];
SubMenu
.
Caption :=
'Text'
;
IniSection := TStringList
.
Create;
IniFile := TIniFile
.
Create(ExtractFilePath(ParamStr(
0
)) +
'IniFile.ini'
);
IniFile
.
ReadSection(
'Text'
, IniSection);
for
i :=
0
to
IniSection
.
Count -
1
do
begin
SubMenu
.
Add(TMenuItem
.
Create(Self));
SubMenu
.
Items[SubMenu
.
Count -
1
].Caption := IniFile
.
ReadString(
'Text'
, IniSection
.
Strings[i],
''
);
SubMenu
.
Items[SubMenu
.
Count -
1
].OnClick := PopupMenuItemClick;
end
;
IniSection
.
Free;
IniFile
.
Free;
end
;
procedure
TForm28
.
PopupMenuItemClick(Sender: TObject);
begin
Clipboard
.
Open;
Clipboard
.
AsText := TMenuItem(Sender).Caption;
Clipboard
.
Close;
end
;
end
.