![]() |
![]() ![]() ![]() |
dcShellProperties component.
|
function ShowContextMenuByFile(FileName: String): Boolean;
|
The ShowContextMenuByFile method executes the shell context menu for the file specified in the FileName parameter (current value of the FileName property does not matter). The menu will appears at current mouse position.
|
|
Use MenuOptions property to specify some advanced options for the context menu and MenuAlignment to specify the menu position.
|
|
![]() |
procedure TForm1.ListView1MouseDown(Sender: TObject;
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
var
|
ListItem: TListItem;
|
begin
|
if Button = mbRight then
|
begin
|
ListItem := ListView1.GetItemAt(X, Y);
|
if ListItem <> nil then
|
begin
|
SetFocus;
|
ListItem.Selected := True;
|
|
with dcShellProperties1 do
|
begin
|
if ListView1.ReadOnly then
|
MenuOptions := MenuOptions - [moCanRename]
|
else
|
MenuOptions := MenuOptions + [moCanRename];
|
|
ShowContextMenuByFile(ListItem.Caption);
|
end;
|
end;
|
end;
|
end;
|
|
procedure TForm1.dcShellProperties1Rename(Sender: TObject;
|
FileName: String);
|
begin
|
if ListView1.Selected <> nil then
|
ListView1.Selected.EditCaption;
|
end;
|
MenuOptions and MenuAlignment properties;
|
ShowContextMenu method.
|