1

I want to implement the traditional open and save dialogs (and the underlying items being dealt with are files), but I want to have control over what is displayed in place of the filename, and include some graphics - i.e. I need an "ownerdraw" style of dialog. Apart from that aspect, I want the dialog to look and feel as much like the traditional open/save dialogs as possible.

I figure I'm faced with implementing this myself, I'm just wondering where the best place to start is.

rossmcm
  • 5,493
  • 10
  • 55
  • 118
  • 1
    @Jay, I don't think the Common Dialogs support the level of customization this question is asking about doing. rossmcm, I'd start out with TVirtualTreeView; it allows easy use of custom images, storage of custom data with each node, works in either treeview or listview (grid) mode, and uses load-on-demand to keep memory use down. It's free w/source. I don't have the current link handy, but a quick Google search should find it. – Ken White Aug 20 '12 at 22:19
  • Oh, it's the ListView items. Windows Hook and subclassing would be needed in that case. – Jay Aug 20 '12 at 22:23
  • What could you replace a filename with that would be meaningful? – David Heffernan Aug 21 '12 at 07:21
  • (@David I knew someone would ask that ;)). Not so much replace as augment. If the filename referred to an application datafile for example, I could display display a glyph dependent on the data in the file. The other reason is possibly more contentious. I was thinking of allowing non-legal characters in the filenames - so a user could save their data in "My Project <1>" - and I would then mangle the name to "My Project &lt1&gt" for the purposes of naming the actual file. I would then de-mangle the filename for display in the file load/save dialogs. – rossmcm Aug 21 '12 at 13:24
  • 1
    Both of these are bad ideas. There are already means to customize glyphs according to content. Use them and all shell views will benefit, not just in your app. Likewise filenames. If you don't show the user the real filename, how can they get at the file from other means. Don't fight the system, roll with it. – David Heffernan Aug 21 '12 at 14:01

2 Answers2

1

AFAIK the level of customization which you need is not provided by the standard windows dialogs, but you can try the TShellListView(TCustomShellListView) component which is part of the ShellCtrls unit (this package is not installed in the Delphi IDE by default), from here you can obtain the code to fill your own TListview with the folder contents and draw the items as you want, also take a look to the Shell Interfaces to interact with the elements of the shell.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • Also, beware that there are quite a few bugs in these components (at least until Delphi 2007, I haven't checked with later versions) – dummzeuch Aug 21 '12 at 07:09
0

For an owner-draw control to use as a list view, I would recommend Roy Klever's rkSmartView.

http://rmklever.com/?page_id=299

The demo app Roy posted on the blog above contains a pretty decent sample of a graphics thumbnail browser which could be turned into the core of what you're doing. He adds rating "stars" and all manner of other owner-drawn decoration.

http://rmklever.com/?p=318

Owner draw on a standard common control like TListView is fraught with limitations. If you want to owner draw all or part of the control a completely virtual control that is 100% internally drawn and 100% source code provided is the only way to be sure you won't hit a wall or end up with a 98% solution that you can't bring all the way home.

I recently did something similar by modifying the above component and it turned out well.

Warren P
  • 65,725
  • 40
  • 181
  • 316