Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: TOpenDialog variable behavior


This question is answered. Helpful answers available: 0. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Jan 6, 2016 12:57 PM Last Post By: Paul Rice
Paul Rice

Posts: 12
Registered: 5/7/98
TOpenDialog variable behavior  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 5, 2016 11:42 AM
With XE8.1 Win7 I'm updating two projects that share a frame. In one project the TOpenDialog of the shared frame comes up like a TFileOpenDialog and in the other project the dialog comes up like XP.

What should I look for that would cause the old behavior? Both projects have the same project options. They use different components suites.

Thanks
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TOpenDialog variable behavior
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 5, 2016 12:23 PM   in response to: Paul Rice in response to: Paul Rice
Paul wrote:

With XE8.1 Win7 I'm updating two projects that share a frame. In
one project the TOpenDialog of the shared frame comes up like a
TFileOpenDialog and in the other project the dialog comes up like XP.

There are several factors that affect how TOpenDialog behaves in this regard.

What should I look for that would cause the old behavior?

TOpenDialog displays the "older" style dialog if either (in this order):

1. the app is running on Windows XP or earlier.

2. the Vcl.Dialogs.UseLatestCommonDialogs variable is false.

3. the app is not using ComCtrl32.dll v6 (requires a Visual Style manifest
to enable).

4. The TOpenDialog.Template property is assigned a non-blank string value.

5. the Win32 IsAppThemed() function (https://msdn.microsoft.com/en-us/library/windows/desktop/bb759809.aspx)
returns false.

6. an event handler is assigned to the TOpenDialog's OnIncludeItem, OnClose,
or OnShow event.

--
Remy Lebeau (TeamB)
Paul Rice

Posts: 12
Registered: 5/7/98
Re: TOpenDialog variable behavior  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 5, 2016 2:10 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Paul wrote:

With XE8.1 Win7 I'm updating two projects that share a frame. In
one project the TOpenDialog of the shared frame comes up like a
TFileOpenDialog and in the other project the dialog comes up like XP.

There are several factors that affect how TOpenDialog behaves in this regard.

What should I look for that would cause the old behavior?

TOpenDialog displays the "older" style dialog if either (in this order):

1. the app is running on Windows XP or earlier.

Check, Windows 7.

2. the Vcl.Dialogs.UseLatestCommonDialogs variable is false.

Check.

3. the app is not using ComCtrl32.dll v6 (requires a Visual Style manifest
to enable).

Problem. Both projects use Embarcadero's Sky style, but IsThemeActive is False in the OpenDialog old style.

4. The TOpenDialog.Template property is assigned a non-blank string value.

Don't see where this is assigned anything.

5. the Win32 IsAppThemed() function (https://msdn.microsoft.com/en-us/library/windows/desktop/bb759809.aspx)
returns false.

Problem, IsAppThemed is False in one project although both use Embarcadero's Sky style.

6. an event handler is assigned to the TOpenDialog's OnIncludeItem, OnClose,
or OnShow event.

Check.

Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TOpenDialog variable behavior
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 5, 2016 3:43 PM   in response to: Paul Rice in response to: Paul Rice
Paul wrote:

Problem. Both projects use Embarcadero's Sky style, but IsThemeActive
is False in the OpenDialog old style.

Problem, IsAppThemed is False in one project although both use
Embarcadero's Sky style.

VCL Styles is a feature of VCL itself. It hooks UI controls at runtime and
custom-drawing them according to the current active theme/style.



Visual Styles (aka Runtime Themes) is a feature of Windows itself, drawing
UI controls based on themes defined by the user in the system Control Panel.

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

IsThemeActive() is a Win32 API function, not a VCL function:

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

See also:

How do IsThemeActive, IsAppThemed, and IsCompositionActive differ?
https://blogs.msdn.microsoft.com/oldnewthing/20110526-00/?p=10563

If IsThemeActive() is false, Windows-based styles/theming are disabled for
all apps on the PC.

If IsAppThemed() is false, Windows-based styles/theming are disabled only
for the calling app.

AFAIK, VCL Styling is not dependant on Windows Visual Styles. Though, if
Visual Styles are enabled and a VCL Style is not assigned, the VCL uses the
standard Windows theming.

So, what I said earlier about TOpenDialog applies to Windows Visual Styles, not to VCL Styles. It sounds like you have Windows-based Visual Styles enabled in one project and disabled in the other project. Visual Styles is enabled through the application manifest, by enabling Runtime Themes in the Project Options, or using a custom manifest. The resulting manifest must declare a dependency on ComCtrl32.dll v6, which is what controls Windows-based styling, and is also required to use the IFileDialog interface (which is the newer dialog that TFileOpenDialog uses, and that TOpenDialog uses when the conditions I outlined earlier are not met).

--
Remy Lebeau (TeamB)
Paul Rice

Posts: 12
Registered: 5/7/98
Re: TOpenDialog variable behavior  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2016 12:57 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
So, what I said earlier about TOpenDialog applies to Windows Visual Styles, not to VCL Styles. It sounds like you have Windows-based Visual Styles enabled in one project and disabled in the other project. Visual Styles is enabled through the application manifest, by enabling Runtime Themes in the Project Options, or using a custom manifest. The resulting manifest must declare a dependency on ComCtrl32.dll v6, which is what controls Windows-based styling, and is also required to use the IFileDialog interface (which is the newer dialog that TFileOpenDialog uses, and that TOpenDialog uses when the conditions I outlined earlier are not met).

--
Remy Lebeau (TeamB)

Thanks Remy! I overlooked Enable Runtime Themes and that was the difference between the two projects.

I ended up not enabling runtime themes, however, because it messed up some controls' coloring used for guided workflow - something like Follow the Yellow Brick Road. I replaced the frame's TOpenDialog with the TFileOpenDialog to give them the updated look.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02