Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting filename property for TOpenFileDialog

When I set the Filename property of a TFileOpenDialog and then execute it I see just the final 14 characters of the filename selected in the Filename field. If I press Home I can see that the entire string is there, but I'd like it to display properly of course. I've tested on two Windows 7 and one Windows 8 machine with the same results. Does anyone have any suggestions or hints on how to solve the issue?

FileOpenDialog1.FileName :=
  'C:\Program Files (x86)\Embarcadero\RAD Studio\9.0\available_downloads_en.htm';
if FileOpenDialog1.Execute then
  ShowMessage(FileOpenDialog1.FileName);

Initial display showing problem: Image showing problem

The entire string after pressing Home: How I think it should look

like image 928
MarkF Avatar asked Mar 12 '13 18:03

MarkF


People also ask

Which property of OpenFileDialog is set to add extension to file names if the user does not supply an extension?

From FileDialog. AddExtension Property: "Gets or sets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension."

How do I open a file using OpenFileDialog in VB net?

Step 1: Drag the OpenFileDialog control from the toolbox and drop it to the Windows form, as shown below. Step 2: Once the OpenFileDialog is added to the form, we can set various properties of the OpenFileDialog by clicking on the OpenFileDialog. Video Player is loading.

How do I get OpenFileDialog in C#?

To create an OpenFileDialog control at design-time, you simply drag and drop an OpenFileDialog control from Toolbox to a Form in Visual Studio. After you drag and drop an OpenFileDialog on a Form, the OpenFileDialog looks like Figure 2. Adding an OpenFileDialog to a Form adds following two lines of code.

How do I open an OpenFileDialog file?

Windows. Forms. OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog.


1 Answers

TFileOpenDialog is just a thin wrapper around Microsoft's IFileDialog interface on Windows Vista and later. You don't have control over how the dialog itself behaves when it is shown. If it only shows the last characters (and I was able to reproduce that behavior on my Win7 box), than that is simply how the dialog works in general. However, with that said, IFileDialog does allow the absolute folder path and just the filename to be set separately, and that is how they should be used, but TFileOpenDialog does not make or expose that separation, unfortunately (Embarcadero bug?). So if you need that functionality, you will have to use IFileDialog directly and not use TFileOpenDialog at all.

like image 68
Remy Lebeau Avatar answered Sep 28 '22 05:09

Remy Lebeau