4

I'm using Delphi XE and would like to add "recent items" in the Windows 7 taskbar jump list for my application, like when right-clicking on Microsoft Word brings up recently opened documents. I've found information on how to set the progress but nothing on jump-list items. Any help would be greatly appreciated.

RRUZ
  • 130,998
  • 15
  • 341
  • 467
jonjbar
  • 3,588
  • 22
  • 44

3 Answers3

7

This will happen automatically if, for instance, you only use the standard Windows file dialogs. At least my text editor, Rejbrand Text Editor, has got such a MRU list by Windows. It lists all files I have recently edited using Rejbrand Text Editor, even though I have not written any code at all for it.

Windows 7 jump list

I think that Windows observes the files you

  • open and save in your application by means of standard Windows file dialogs
  • open in your application by starting yourapp.exe <file name>, for instance by double-clicking a file that opens in your application

and automatically display these in the list.

If you want to control the task bar button and menu programmatically, you can use the Windows API. Delphi-specific examples are found in this blog post.

Andreas Rejbrand
  • 95,177
  • 8
  • 253
  • 351
  • 1
    +1; Btw. there was a complex package of components for Windows 7 written in Delphi by Daniel Wischnewski. It was mentioned e.g. [in this post](http://stackoverflow.com/questions/4588151/how-to-create-own-control-in-windows-7-aero-task-preview/4588209#4588209). But the website is dead now and I can't even find it anymore. It would be fine to re-upload it somewhere. –  Apr 27 '11 at 15:50
  • Thanks but this is not working for me at all. I've tried to pin the software, I've tried to move it to the program file folder.. nothing works. Even if I call SHAddToRecentDocs manually. Any idea ? – jonjbar Apr 28 '11 at 07:59
  • OK Found it there: http://msdn.microsoft.com/en-us/library/bb762105%28v=vs.85%29.aspx - The application must be registered under HKEY_CLASSES_ROOT\Applications - The application's HKEY_CLASSES_ROOT\Applications registration must have a set of default verbs defined under a HKEY_CLASSES_ROOT\Applications\ExampleApp.exe\shell subkey... This wasn't the case for my application in development :( – jonjbar Apr 28 '11 at 08:10
  • @user532231 - Used archive.org to bring up [Daniel's Site](http://web.archive.org/web/20110126123302/http://www.gumpi.com/Blog/default.aspx#abb307f7d-73a6-4b26-88ec-3770924c9941) – Michael Riley - AKA Gunny Jul 06 '13 at 20:18
4

In my opinion the best way to do this is to make the following simple API call:

  SHAddToRecentDocs(SHARD_PATH, PChar(FileName));

This not only deals with Windows 7 jump lists but also adds your file into the system's list of recently used documents which has an effect on early versions of Windows too.

Call the function whenever you open or save a file.

For your convenience, a link to the documentation of SHAddToRecentDocs().

David Heffernan
  • 572,264
  • 40
  • 974
  • 1,389
  • Isn't the function getting called automatically by the Windows file dialogues? – Andreas Rejbrand Apr 27 '11 at 16:33
  • not everything goes through the dialogs. For example MRU menus. – David Heffernan Apr 27 '11 at 17:42
  • 1
    Thanks, this is of great help for my MRU however as I said to the other answer, it doesn't work at all. Any idea what could cause the problem ? – jonjbar Apr 28 '11 at 08:00
  • 3
    OK Found it there: http://msdn.microsoft.com/en-us/library/bb762105%28v=vs.85%29.aspx - The application must be registered under HKEY_CLASSES_ROOT\Applications - The application's HKEY_CLASSES_ROOT\Applications registration must have a set of default verbs defined under a HKEY_CLASSES_ROOT\Applications\ExampleApp.exe\shell subkey... This wasn't the case for my application in development :( – jonjbar Apr 28 '11 at 08:11
  • I accept your answer as it helps with the MRU problem which the other one didn't solve automatically. Thanks. – jonjbar Apr 28 '11 at 08:12