I have a Listbox which contain a list of files . can i access the Windows right-click menu in the listbox to access the open , properties , delete and rename items ?
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
- DBGrid - How to set an individual background color
相关文章
- Does JavaScript allow getters and setters?
- Notice: Undefined property - how do I avoid that m
- Using the typical get set properties in C#… with p
- Best way to implement MVVM bindings (View <-> V
- Windows EventLog: How fast are operations with it?
- Add selected attribute to option in select menu wi
- How to force Delphi compiler to display all hints
- Mocking nested properties with mock
Kermia check the
JclShell
unit from the JEDI JCL library, inside of this unit exist a function calledDisplayContextMenu
which show the context menu associated to a file. this function encapsulate the calls to the IContextMenu interface and makes your work more easy.I'd recommend looking at something like tpShellShock when you want to show shell like controls in your Delphi app. It offers tree views, list views etc. that can be connected together much like an Explorer Windows. It will display the appropriate icons for the files. I'm sure it offers the facilities you talk about too.
It might need some porting work if you are on a modern Unicode Delphi, but when I have done that it proved relatively straightforward.
No doubt there are other libraries that offer shell controls, this is just the one I am familiar with.
Otherwise if you want to stick with your current solution it's easiest to implement your own menu actions. Open and Properties are just simple calls to ShellExecute with the appropriate verb. Delete is a call to DeleteFile and Rename is a call to MoveFile.
Here is an implementation example using the 'OnContextPopup' event of a list box, which is populated with file names in the project directory, to launch the shortcut menu of a file when right-clicked on its name:
Check the IContextMenu interface. But be aware that Windows shell doesn't identify its objects by filename - actually they could not be files. It uses a concatenation of ids, and you may need to get what item id list a file is assigend to before invoking some shell functions on it.