Just installed Delphi 11 (Alexandria) and starting to convert our project to it (from 10.4, we try to keep up-to-date). I was surprised to see that our pixel-perfect (and quite crowded) data entry forms with dozens of TDBEdits were out of shape.
After a short research I found that amongst other changes, "For VCL applications, the default font is now Segoe UI, 9 pt.". Our forms are designed for "Tahoma, 8 pt", the former default font. At runtime I can fix it with altering the Application.DefaultFont at the start of the application, but we just cannot do development work on the forms while the fonts are bigger than the form was designed for.
All of our forms use the ParentFont = True setting, so I would like to change the default fonts for the form designer. For older Delphi versions there was a registry setting that controlled this, as seen at https://suretalent.blogspot.com/2011/07/how-to-set-default-form-font-delphi.html
I did the changes as mentioned on the url above, with no luck. Is there a setting I could use for this?
Related
Following on from my previous questions (Delphi 6 TDateTimePicker Windows Visual Theme support via Manifest), we are updating a legacy application developed in Delphi 6 to support Windows Visual Themes (to freshen up the UI). We have included a Manifest and now also Mike Lischke's Windows XP Theme Manager (WXPTM) components, as per previous recommendations.
We can see three components on a new XP tab (palette) in Delphi, have included the path to the library's in our project and dropped the components onto one of the forms. The recompiled EXE is now displaying controls differently from prior to including WXPTM and it seems to have fixed a number of issues, so I am fairly certain (and hope) we have implemented WXPTM correctly.
However, we have some third-party component controls that are descendants of the standard ones, which we thought (hoped) would simply inherit from the replacement/updated controls in WXPTM. Unfortunately, it appears they do not, unless we have missed something out in the WXPTM implementation. Therefore, is it possible to make third-party controls inherit from the updated standard controls in WXPTM? Any tips, tricks, suggestions or advice to point us in the right direction would be greatly appreciated.
Just for test how hard to convert my Delphi 7 program to Delphi XE 5 i wrote simple application on Delphi 7 - placed TStringGrid on Form, and added code on form create:
procedure TFMain.FormCreate(Sender: TObject);
begin
With StringGrid1 do
begin
Cells[0,0]:='čęжэ€';
end;
end;
(actually it wrote as Cells[0,0]:='ce??€', but i expected that). Compile, build, run, no Unicode, of cause. Then reopened project in Delphi XE 5, changed line again to Cells[0,0]:='čęжэ€', compile, build, run - and no Unicode (got something like čę|||) ! That was strange to me. New project build from zero on Delphi Xe 5 with the same code, same TStringGrid is working as expected. I know here is some simple trick, maybe some change in project settings, but i can't google it... Maybe someone can help ?
Best regards.
The default font used by Delphi 7 is MS Sans Serif. When you use this font under Unicode Delphi, the string grid control appears not to draw text correctly with that font. Many other controls will draw your text correctly in that font. But for some reason the string grid control cannot manage to do so.
When you upgrade an old project to XE5 you inherit that Delphi 7 default. When you create a new project in XE5 the default font is different, Tahoma I think, and the string grid painting correctly shows your Cyrillic in that font.
You can work around this problem by using a different font like Tahoma or Segoe UI. You surely don't want to be using MS Sans Serif anyway. A list view in report view style would be another good option. Not least because it is the native platform control.
I must admit that I do not really understand why the string grid control is not behaving better. It would be great if somebody else could shed some light on this.
As David mentions, the issue is the font used in your string grid. However, it is not strictly accurate to say that the default font in Delphi is MS Sans Serif. It used to be MS Sans Serif but was changed (in Delphi 2006) to Tahoma.
You can see how a particular version of Delphi chooses the default font by inspecting the source of the Graphics unit in the RTL source of that particular Delphi version (since the IDE is built using that code). Specifically the InitDefFontData procedure (and, in older versions of Delphi, the DefFontData record).
As of (at least) Delphi XE4 the default Tahoma font will be replaced by any setting for a font substitution for a value identified as MS Shell Dlg 2, as set in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes\
NB - from inspecting the code in XE4 it is possible that if this key does not exist or cannot be accessed, or if there is no substitution entry for MS Shell Dlg 2 font, then MS Sans Serif will still be used. It is hard to tell since this is the behaviour when "CLR" is defined, which should not be the case any more since Delphi no longer supports .NET and the IDE is presumably not compiled with CLR defined, but there is no way to be certain simply from inspecting the code what conditional defines might be applied when the IDE is compiled.
However, whichever font the IDE is using and however it is choosing that font, this affects only new forms created in the IDE.
For existing forms, as in this case, the issue is not with TStringGrid as such but rather the fact that you created the project in a version of Delphi which applied a default font which did/does not support Unicode.
The act of opening the project in the newer version of Delphi did not change the font used in your form(s), so the form saved in Delphi 7 using the MS Sans Serif font is still using that font when opened in Delphi XE5.
The TStringGrid control is then using the MS Sans Serif font because this is the font set on the form, and the default for controls on a form is to use their parent control font.
i.e. This specific instance of TStringGrid is using MS Sans Serif because the form on which it is placed is (still) using MS Sans Serif.
In such cases you should change the form font to Tahoma or a. n. other suitable, Unicode enabled font.
All controls on the form still set to use their parent control's font will then adopt this font also. When performing this on an actual application you may find some controls with ParentFont set FALSE which will need to be addressed individually and that even where font settings are being "inherited" your form designs may need further work to tidy things up due to changes in appearance resulting from the change of font.
Note that even this change to Tahoma has been overtaken by changes in Windows itself, and if you wish to apply some other default font (in new forms/projects) you may find useful information here.
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.)
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.
I recently experienced some unusual behavior in using a 3rd party Navigator component in Delphi 2007 whereby upon setting the 'Flat' property to True, the buttons didn't remain Flat as they should with Themes Enabled but did so once I unchecked Enable Themes from within my project file and recompiled my program. This obviously didn't seem right since another 3rd party Navigator component I experimented with performed accordingly with 'Flat' set to True and Themes Enabled. I then tried the same with Delphi's TDBNavigator and once again I experienced the same problem as I did with the first 3rd party Navigator component. In researching this matter online, I have found very little other than the fact that, unlike previous versions of Delphi, Delphi 2007 supports Themed Applications out of the box as opposed to having to add another component to support WinXP Themes. All considered, I am hoping that someone else may have experienced similar problems in using TDBNavigator or other 3rd party Navigator components in Themed Applications with the flat property set to true. Any comments or suggestions regarding this matter are appreciated.
Theme support was added to Delphi 2007, but doesn't apply to 100% of the VCL (grids, for example, don't have theme support). I'd suspect that's the issue you're having with the TDBNavigator.
As far as your "3rd party Navigator" problems, it's impossible to give you any advice because you didn't indicate which "3rd party Navigator" controls you're using. Without knowing the specific component names, you've given no information to us to use in trying to help.
Delphi 2010 provides full theme support, including grids. I haven't tested the DBNavigator, as I haven't used it since Delphi 2 or so. Note, however, that Delphi 2009/2010 introduces other issues with older code, because as of Delphi 2009 the VCL is Unicode-based. Some code that uses strings and assumes that a Char is 1 byte in size can be an issue.
Workaround on TDBNavigator,TSpeedButton bug
http://blog.issamsoft.com/index.php?q=en/node/37