![]() |
![]() ![]() ![]() |
dcShellProperties component.
|
function ShowContextMenu: Boolean;
|
The ShowContextMenu method executes the shell context menu, for the shell object specified in the FileName property. The popup menu will appears at current mouse position. ShowContextMenu method returns True if succeeed, or False otherwise.
|
|
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
|
FileName := ListItem.Caption // ?
|
|
if ListView1.ReadOnly then
|
MenuOptions := MenuOptions - [moCanRename]
|
else
|
MenuOptions := MenuOptions + [moCanRename];
|
|
ShowContextMenu;
|
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;
|
ShowContextMenuByFile method.
|