Previewing an image in an TOpenDialog?

Posted on 2004-08-13
Last Modified: 2010-04-05

I'm trying to create an image preview in a standard TOpenDialog, similar to the ones found in many image-editing programs like Paint Shop Pro. That is, the user clicks an image file in the filelist and the image shows a scaled down preview.

However, I'm unsure about how to go about this. Is it possible to easily incorporate this somehow in a standard TOpenDialog, and if so, how can this be accomplished?

Question by:wileyecoyote
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1

Accepted Solution

DavidBirch2dotCom earned 250 total points
ID: 11792147
try using OpenPictureDialog and SavePictureDialog on the dialogs toolbar

Expert Comment

ID: 11792154
TOpenPictureDialog and TSavePictureDialog its the same dialogue as you are talking about it will preview images for you

Author Comment

ID: 11792395
It appears that TOpenPictureDialog cannot display jpeg files, despite the fact that the filter does list jpeg as format. However, it crashes the application when I'm trying to. Unfortunately, it is essential for my application to preview jpeg files.

Can this be fixed?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 17

Expert Comment

by:Wim ten Brink
ID: 11792418
If you don't like the TOpenPictureDialog/TSavePictureDialog then you're out of luck. In those cases you'd have to write your own dialogs as new forms in Delphi. The standard dialogs are just timesafers for generic solutions. If you want something specific, you have to create it yourself.

Now, for the preview you create a new form and drop the explorer components and other visual components that allow you to select drive/folder/file/mask/edit and whatever else. You also drop a TImage on this form and from you download GraphicEx so you can support all kinds of formats. Then, whenever the user selects a file, you try to show it in the TImage. On success, great. On failure you'll get an exception that you silently ignore.

It's a pain to have to do this but many others are doing this in sililar ways. It's easier than trying to modify the existing dialogs...
LVL 17

Expert Comment

by:Wim ten Brink
ID: 11792424
If it cannot display JPeG's then the image format is not registered in runtime.
LVL 14

Assisted Solution

by:Pierre Cornelius
Pierre Cornelius earned 50 total points
ID: 11793171
Simply add JPeg to your uses clause and your problem will be solved.


Pierre Cornelius

Expert Comment

ID: 11795191
thanks for the points :-)

Author Comment

ID: 11795210
Thanks guys. The combination of TOpenPictureDialog and JPeg addes to the use clause did the trick. Appreciate the help.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question