Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: SelectDirectory Distorted on XPS13 Laptop


This question is answered.


Permlink Replies: 5 - Last Post: Mar 16, 2018 10:02 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Earl Staley

Posts: 99
Registered: 4/9/07
SelectDirectory Distorted on XPS13 Laptop  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2018 9:43 AM
The Select Directory dialog box appears normal on my desktop computer, but completely distorted on a Dell XPS 13 computer. The XPS13 display is set at 3200 x 1800 resolution.

Here is what the Select Directory looks like on the XPS13:

https://www.dropbox.com/s/8y5iq8z1n4nh2li/Screenshot%202018-02-24%2009.09.02.png?dl=0

Any idea how I can detect the XPS13 through program code and set the Select Directory to appear normally?

Earl Staley
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: SelectDirectory Distorted on XPS13 Laptop  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2018 8:58 AM   in response to: Earl Staley in response to: Earl Staley
Earl Staley wrote:

Here is what the Select Directory looks like on the XPS13:

Why are you using the old-style Windows 3.1 version of
SelectDirectory(), and not a modern Windows Shell version?
SelectDirectory() has several overloads available. The one you are
using is severely outdated. Use one of the other overloads instead.

--
Remy Lebeau (TeamB)
Earl Staley

Posts: 99
Registered: 4/9/07
Re: SelectDirectory Distorted on XPS13 Laptop  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 15, 2018 5:04 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Earl Staley wrote:

Here is what the Select Directory looks like on the XPS13:

Why are you using the old-style Windows 3.1 version of
SelectDirectory(), and not a modern Windows Shell version?
SelectDirectory() has several overloads available. The one you are
using is severely outdated. Use one of the other overloads instead.

--
Remy Lebeau (TeamB)

Remy,

The only SelectDirectory() functions I have found on the Embarcadero website and through a Google search are these:

Boolean SelectDirectory(AnsiString Directory, TSelectDirOpts Options, Longint HelpCtx);
Boolean SelectDirectory(const AnsiString Caption, const BSTR Root, AnsiString Directory, TSelectDirExtOpts Options = [sdNewUI], TWinControl * Parent = nil);

Here is what I am using:

	UnicodeString Dir = CurDir;
	if (SelectDirectory(Dir,
		TSelectDirOpts() << sdAllowCreate << sdPerformCreate << sdPrompt,
		SELDIRHELP)) {


What other options do I have?

Earl Staley
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: SelectDirectory Distorted on XPS13 Laptop
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 15, 2018 5:42 PM   in response to: Earl Staley in response to: Earl Staley
Earl Staley wrote:

The only SelectDirectory() functions I have found on the Embarcadero
website and through a Google search are these:

Then you did not look very well, you missed this one:

http://docwiki.embarcadero.com/Libraries/en/Vcl.FileCtrl.SelectDirectory

And even FireMonkey has its own version of SelectDirectory():

http://docwiki.embarcadero.com/Libraries/en/FMX.Dialogs.SelectDirectory

Boolean SelectDirectory(AnsiString Directory, TSelectDirOpts Options,
Longint HelpCtx);

That is the original version that uses a custom TForm with Windows 3.1
style controls on it. That is the one you SHOULD NOT be using in
modern applications.

Boolean SelectDirectory(const AnsiString Caption,
const BSTR Root, AnsiString Directory, TSelectDirExtOpts Options =
[sdNewUI], TWinControl * Parent = nil);

That overload uses the Win32 Shell's SHBrowseForFolder() function to
display a native Windows browse dialog instead of a custom TForm:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb762115.aspx

However, the declaration you showed is outdated. The current
declaration looks more like this instead:

bool SelectDirectory(const String Caption, const WideString Root,
String &Directory, TSelectDirExtOpts Options = (TSelectDirExtOpts() <<
sdNewUI), TWinControl* Parent = 0)


Then there is a 3rd overload, which is a recent addition and only works
on Vista and later as it uses the Win32's IFileDialog interface to
display a newer native Windows browse dialog:

bool SelectDirectory(const String StartDirectory, TArray<String>
&Directories, TSelectDirFileDlgOpts Options = TSelectDirFileDlgOpts(),
const String Title = _D(""), const String FolderNameLabel = _D(""),
const String OkButtonLabel = _D(""))


Here is what I am using:

You are using the original Win3.1 version. Use this instead:

String Dir = CurDir;
 
if (SelectDirectory(_D("Whatever Caption you want"), WideString(), Dir,
TSelectDirExtOpts() << sdNewUI << sdNewFolder << sdShowEdit))
{
    ...
}


Or this:

TArray<String> Dirs;
 
if (SelectDirectory(CurDir, Dirs))
{
    ...
}


--
Remy Lebeau (TeamB)
Earl Staley

Posts: 99
Registered: 4/9/07
Re: SelectDirectory Distorted on XPS13 Laptop  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 15, 2018 6:23 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Earl Staley wrote:

The only SelectDirectory() functions I have found on the Embarcadero
website and through a Google search are these:

Then you did not look very well, you missed this one:

http://docwiki.embarcadero.com/Libraries/en/Vcl.FileCtrl.SelectDirectory

That website did not come up in my Google search. Here is what I got from a Google search using C++ SelectDirectory as the search criteria:

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/FileCtrl_SelectDirectory@string@TSelectDirOpts@Longint.html

which showed the old prototypes for SelectDirectory() and this:

http://docwiki.embarcadero.com/CodeExamples/Tokyo/en/SelectDirectory_(C%2B%2B)

which showed sample C++ code using the old SelectDirectory().

And even FireMonkey has its own version of SelectDirectory():

http://docwiki.embarcadero.com/Libraries/en/FMX.Dialogs.SelectDirectory

Boolean SelectDirectory(AnsiString Directory, TSelectDirOpts Options,
Longint HelpCtx);

Remy Lebeau (TeamB)

Thank you for all your help. I tried the program on an XPS13 laptop and the SelectDirectory() dialog displays normally.

Regards...
Earl Staley
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: SelectDirectory Distorted on XPS13 Laptop  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 16, 2018 10:02 AM   in response to: Earl Staley in response to: Earl Staley
Earl Staley wrote:

That website did not come up in my Google search.

The 2nd search result, right after the one you found, is a C++ example
of the old function, but if you look closer, it is on the current
docwiki site, not the older docs site, and it has a link on the bottom
to the new documentation that I pointed you to.

Here is what I got from a Google search using C++ SelectDirectory as
the search criteria:

docs.embarcadero.com is the old documentation site.

docwiki.embarcadero.com is the current documentation site.

And FYI, you can limit Google searches to a particular site, eg:

"C++ SelectDirectory site:docwiki.embarcadero.com"

The 2nd search result links to the latest documentation that I pointed
you to.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02