Delphi runtime theme enabled, but not used - delphi

In a legacy application (created in Delphi 6 under WinXP in 32-bit, recently ported to Delphi XE2 under Win7 in 64-bit) at design time, the standard controls look "modern", with color gradients etc. In run-time though, they look just like an old Win95 version.
That would not bother me much if, in particular, the default colors in TPageControl and TTabControl wouldn't make it really difficult to tell which tab is currently selected.
So my questions are:
What could make the theme not active at run time?
Is it possible to easily (e.g. through IDE configuration) make the design time look like the run time?
Note:
In the project options, I enabled runtime themes for each existing target. It didn't help.
I also tried to enable GlassFrame in the forms containing those controls. Unfortunately, the runtime look and feel stayed unthemed.
This application is built on a lot of in-house and external code that
I don't master (just a dwarf standing on shoulders of giants),
but whose source are available to me. Suspecting that some
instruction would disable themes at application startup, I looked for
some keywords like "Theme", "Skin", "TStyleManager", "SetWindowTheme"
hoping to solve this by myself. I could not find anything significant (to me, at least).
I tried to skin a small application as a test, using infos from
Question
Delphi XE2 VCL styles tutorial - how to change the style at runtime,
and it worked perfectly.
Skinning my application is not my goal. I just would like to be able to visually tune some GUI elements at design time, and it is easier if design and run time look alike.

It turns out that removing the line "{$R *.res}" in the dpr file had made the themes unavailable.
Under D6, I disabled version information in the project and replaced "{$R *.res}" with "{$R 'myApp.res' 'myApp.rc'}", to use my own rc file to have the version information in a separate, easy to edit file, and not to be forced to go through the project options.
Under XE2, that did not work anymore because the resource would often be overwritten (or not taken into account, I'm not quite sure) by Delphi during the build. I had to rename the rc file so that it does not match the application name, thus replacing "{$R 'myApp.res' 'myApp.rc'}" with "{$R 'myApp_rc.res' 'myApp_rc.rc'}".
Putting the "{$R *.res}" again (along with "{$R 'myApp.res' 'myApp.rc'}") seems to make things right with themes and not break the version information.
Thank you Brian for having me look in the good direction.

In my experience this is often due to project differences between DEBUG mode (used by default when in the IDE) and RELEASE mode. Open your project options and scroll to application (where themes styles and icon are defined). Notice that the platform and build option combo at the top holds separate values for each setting and I expect you will find that your DEBUG build config has runtime themes enabled but RELEASE does not.

Related

Bug: Cannot edit hints/warnings in BPL project options

I took advantage of the (time limited) upgrade offer I received via email from Embarcadero and upgraded to Delphi XE7. I like it. Good versions like this appear ever 7 years :)
But I have a problem: I don't know how to silence some warnings. For example 'W1011 Text after final END'. The 'Project Options' box is different. All those editable values are gone. Instead I have 3 entries like 'Value from: Debug configuration - All platforms.'
Where I can configure the global "Debug configuration - All platforms" thing?
Edit: Updated after the screenshot. Old answer below labeled 'General projects' since it's still useful in the general case, for EXEs, DLLs, etc.
BPL projects in XE7 only (okay in XE6-, fixed in XE8+)
Update: this bug has been marked as resolved in XE8.
I see in your screenshot you have a BPL project open (btw, you're using the XE2 Graphics32 package in XE7 - better to use the dedicated XE7 one.)
I can verify that BPLs do not show the list of warnings and hints the way other project types do. EXEs, DLLs, etc list them, as below. I think this is a bug: RSP-8980. It is a regression from XE6; XE6 shows the hints and warnings as expected but XE7 does not.
Edit the DPROJ manually
David Heffernan points out that these options are supposed to be in the project, even though the UI isn't letting you edit them. One way would be to create another project (eg a DLL), set up the options as you need, and edit the BPL's project file (.dproj) manually to include them, copying from the correctly set up other project.
This is complicated - it's XML, you need to get all the named configurations exactly right, etc - but will mimic what the UI does for you.
BPK file
You can workaround this by specifying them in the .bpk file itself. You can see a number of project options are in the GR32 .bpk file:
The BPK is analogous to the DPR file, only for BPLs. To find this file, right-click the BPL project and click 'View Source'.
If you add the line
{$WARN GARBAGE OFF}
and rebuild (not recompile, but build) the project, you will see all units which previously showed warning W1011 now do not.
How do you know what a particular warning is called, when you have to refer to them by name not number? Look them up on this handy blog post.
I have added two Quality bug reports:
Allow hints and warnings to be referring to in compiler directives by number, not just name
Packages do not allow hints/warnings to be set in the Project Options the way other project types do
General projects
A project has a number of targets (such as Windows 32bit Debug, vs OSX 32bit Release, etc) and setting can be set for each of those. In addition, these settings are inheritable, so you can set settings for all debug targets, all release targets, etc.
In general, you should set a setting at the highest level possible, and override at the most specific level.
With that as background, to change W1011 Text after final end open the Project Options and navigate to the Hints and Warnings section. In the 'Target' dropdown combo at the top, choose the highest-level target where you want to make the change (for example, in this screenshot I've chosen 'Debug configuration - all platforms' which means that Win32 Debug and Win64 Debug and any other platform debug will use this setting with the value specified here.)
Expand the 'Output warnings' tree and ignore the dark red 'Value from Foo' nodes which are referring to the inherited values - it's impossible to use here and makes more sense for other settings. These are the ones that I think are confusing you, from your question. Instead, scroll down until you see 'Text after final end' (warnings are sorted alphabetically.)
Select it, and choose the option you're interested in.
Key things to avoid confusion:
Options are inherited
Use the combo box at the top to select the level at which you are applying the setting
Override at the most specific possible
Set at the most generic possible
When setting a value, ignore the dark red "Value from Foo" inherited nodes; just scroll down or expand, and set the setting you want

VCL Components not rendering pretty Windows styles

My delphi application looks nice and pretty in the editor, but when compiled it's seemed to being using super old rendering for the buttons and stuff. I thought my compiled applications used to look pretty like the editor. What could I have screwed up for this to be happening?
One suspicion: a while back I was messing with manifests on a different app that needed to find the actual program files directory. Could I have screwed up my delphi project trying too hard for that? This project is set to use runtime themes.
The top is in the editor, the bottom is the compiled version
Your program is being rendered without themes. Possible causes for that:
Your executable has no manifest.
Your executable has a manifest, but it does not specify v6 comctl32.
Your manifest does specify v6 comctl32 but the process is using an external compatibility mode.
Your program disables visual styles in code. For example with a call to SetThemeAppProperties.
Your program uses activation contexts to activate a different manifest from that linked to the executable.
These possibilities get progressively more far-fetched. Most likely you've somehow fluffed your manifest. That's easy to check with a resource editor.

Form/Button/other component styles

Ok, so I downloaded a .zip file of all different kinds of examples from embarcadero... the way the buttons look and among other things are completely different from when I just create an application within my Delphi 7. I believe these examples were made for or made at a new time... because the button look way different from the way the button when I put them on my application. the buttons from the example look very modern and sleek and have mouse over effects (This applies for all the examples..its not a custom component ) I was wondering I can get this effect in my own applications within Delphi 7.. I can do this by opening one of the examples and just erasing all the code... but that's not what im trying to do..im wondering how I can accomplish these styles.. how come the examples have these nice looking buttons and such..but when I make an app within D7 its much older looking and such..
I apologize if my question is hard to understand.. and I appreciate any help on this.
Thank you in advance.. I appreciate it.
If I understand your question correctly, you're asking about the native control appearance changes that were added by the addition of Windows Themes in Windows XP.
Delphi 7 supported themes by use of the XPManifest component, which does nothing but add a manifest to your application which tells Windows your app is theme-aware and therefore it should load a more recent version of the common controls library. You can find the XPManifest component in the VCL component palette on the Win32 tab, or simply add the XPMan.pas unit to your uses clause. Note that the themed drawing does not work for all controls (grids, for instance, are not drawn using themes, and IIRC neither is TSpeedButton - it's been a long time since I used D7, so I'm not sure exactly what is and isn't supported, but the support is limited).
Starting with Delphi 2007, there is built-in support for Windows Themes, which is available by default in new projects. It can also be enabled in older projects using a checkbox in the Project->Options->Application dialog.
(Of course the real answer is that if you want your app to have the features included in modern versions of Windows, you should upgrade from your Windows-95 era version of Delphi to one that is more recent.)

New Firemonkey iOS application - File not found unit1.lfm

I started my first iOS application in Firemonkey, and the compiler immediately started complaining "File not found unit1.lfm". There is no such file in my project, and my application has no main form, just a unit with a form referenced...
{$R *.lfm}
What's wrong?
I'm asking/answering this Q/A style. I faced this issue and quickly knew what was wrong, and a lot of other people are bound to face this.
This is because the IDE's form designer for iOS (and all Firemonkey) applications requires that you have the "Embedded Designer" enabled. By default, this is enabled in these later versions of Delphi which have the option. However, many people disable this to mimic the old fashioned Delphi versions (where the forms are floating separate from everything else). These forms cannot be shown as their own windows in Delphi XE2, so they need to be designed in the embedded designer.
To fix this, go to "Tools > Options > VCL Designer" and then check the option "Embedded Designer". This will require you to restart your IDE for it to take effect.
Unfortunately, you will have to delete any saved files and create your project again. The links are broken after you've started a new project with this disabled. (technically it can be recovered, but it's easier to start over anyway)

Delphi 2006 Application messing up the GUI on Windows 7

I've been searching the Internet for a solution. Also here on Stackoverflow. But I haven't had any luck so far.
We're having a problem with a Delphi 2006 application running on Windows 7. Some ComboBoxes are not shown. The exactly same application runs fine on Windows XP.
I been trying to locate any patches. Do any one of you know any links or hack to make to GUI look as it should when running a Delphi 2006 application on Vista/Windows 7?
I've found this link: http://www.theabsolute.net/sware/delphivista.html. But it doesn't solve my problems.
Any help are welcome.
/Brian
This may be one of a couple of issues; you haven't given much in the way of details. "Some comboboxes are not shown" doesn't help a lot.
The things I've run across that caused these kinds of problems:
Large fonts when the app was designed with normal fonts
Custom DPI settings (eg., 120 DPI instead of the "standard" 96 DPI)
EDIT after Brian's comment:
That's really strange. I've never seen visual differences between apps compiled in the IDE and command-line.
The only thing I can think of is that the command-line version might have some compiler defines that are affecting the comboboxes (unlikely), or the command-line version is seeing a different version of the .pas and .dfm and that version doesn't have the comboboxes on the form.
You might try making sure that there is only a single copy of the affected .dfm and .pas files on the build machine, and then verify they have the right appearance before compilation. (Use Windows search to check for multiple copies of the source files, and search the entire system just to make sure.)
I've never had this issue with visual controls, but have had it with source changes that didn't seem to take effect, or breakpoints that didn't break because the compiler was seeing a different version of the file than I was... I don't know if that's the case here, but it might be worth checking.

Resources