Author |
Topic |
|
xequte
38615 Posts |
Posted - Aug 25 2014 : 17:07:29
|
Hi
Delphi XE2 introduced styles to the VCL. We are investigating the best way to support these.
In the meantime you can easily add support to ImageEn components as follows:
Add the following to the unit using the component (e.g. a form containing a TImageEnView) above the TForm declaration:
type TImageEnView = class(ImageEnView.TImageEnView);
And in FormCreate:
TStyleManager.Engine.RegisterStyleHook(TImageEnView, TScrollingStyleHook);
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
w2m
USA
1990 Posts |
Posted - Aug 26 2014 : 08:07:41
|
Nigel,
I tried this, but regardless of the theme I select, the TImageEnView scrollbars do not appear with the proper color. As far as I understand, the only thing that will be themed are the scrollbars, so I am not understanding why the scrollbars do not seem to be "skinned" correctly.
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
xequte
38615 Posts |
Posted - Aug 26 2014 : 21:11:44
|
Hi Bill
What version of Delphi is this with?
Also, you need to ensure that this line:
TImageEnView = class(ImageEnView.TImageEnView);
Appears above the TForm class declaration at the top of the unit containing the TImageEnView
Nigel Xequte Software www.xequte.com nigel@xequte.com |
|
|
w2m
USA
1990 Posts |
Posted - Aug 27 2014 : 07:00:14
|
I am using XE4, but anyway I found the problem. I was using type TImageEnView = class(ImageEnView1.TImageEnView); When I changed it to TImageEnView = class(ImageEnView.TImageEnView); It themed nicely.
I also experimented with theming TImageEnMView. TStyleManager.Engine.RegisterStyleHook(TImageEnMView, TScrollingStyleHook);
Without Wallpaper
When a stylehook was registered for TImageEnMView, the TImageEnMView scrollbar themed but the wallpaper area was white even with a black theme, so as a temporary work-around a wallpaper created from the image was used so the wallpaper area was black. This is not the correct approach but it works for a black theme anyway.
With Wallpaper Note: Investigate Theme painting styles at https://code.google.com/p/vcl-styles-utils/ and at http://theroadtodelphi.wordpress.com/category/vcl-styles/
Perhaps a different StyleHook will work better with TImageEnMView.
Update: I tried various stylehook classes but none of them painted the wallpaper area correctly, so further study of the Styles API is required.
Update: Hurray... I figured it out!!!
All you have to do is to add Vcl.Styles.Hooks.pas to uses from http://theroadtodelphi.wordpress.com/2014/08/06/vcl-styles-utils-new-feature/ It works perfectly. It applies the theme painting to both TImageEnView and TImageEnMView background and scrollbars. I have not tested TImageEnVect yet, but I suspect that will work as well. A demo app that includes the Vcl.Styles.Hooks.pas as well as file KOLDetours.pas by Thaddy de Koning may be downloaded here: ./attach/w2m/20148278638_VClStylesWithImageEn.zip
Note: To add full theming support to ImageEn components Vcl.Styles.Hooks.pas. must be added to project uses. The Initial Developer of the original Vcl.Styles.Hooks code is Rodrigo Ruz V. Portions created by Rodrigo Ruz V. are Copyright (C) 2013 Rodrigo Ruz V. The Vcl.Styles.Hooks.pas file are subject to the Mozilla Public License Version 1.1 https://code.google.com/p/vcl-styles-utils/
Note: The TOpenPictureDialog is not themed in this demo. Add Vcl.Styles.SysControls.pas to uses from Rodrigo's website to theme the standard file dialogs. The objective of this demo was to show how to apply theme support to ImageEn components, so I did not bother trying to theme the TOpenPictureDialog.
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
xequte
38615 Posts |
|
xequte
38615 Posts |
Posted - Sep 02 2014 : 22:09:16
|
Hi Bill
You might want to test the latest update on the VCS, it adds VCL theme support without requiring a third party library.
You need only define SupportVclThemes in ie.inc
Note: TImageEnView does not initially fill its background (until it has content) so ensure you blank it on FormShow
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Optical
Netherlands
5 Posts |
Posted - Sep 03 2014 : 09:15:44
|
Instead of TStyleManager use TStyleEngine (however I just tested in Delphi XE6, it must be done at the main form) |
|
|
w2m
USA
1990 Posts |
Posted - Sep 03 2014 : 09:29:37
|
Please explain this in more detail. I am testing this too. I find that after changing styles the image disappears from TImageEnView. Where is TStyleEngine defined?
Update
I had ImageEnView.Blank in OnFormShow so the theme was visible when the app started, but when a theme is changed, the OnFormShow event is executed which explains why the image disappeared after changing themes. I corrected this problem with:
procedure TForm1.FormShow(Sender: TObject);
begin
{ Insure the theme is painted by blanking the image if no image is loaded }
if ImageEnMView1.SelectedImage = -1 then
ImageEnView1.Blank;
end;
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
xequte
38615 Posts |
Posted - Sep 03 2014 : 17:04:56
|
Nice work on the demo, Bill,
It looks particularly good with the new styles in XE6.
One thing I did not mention (though is not relevant to your demo) when text/filenames are displayed in a TImageEnMView their font is handled on a per thumbnail basis. So although the theme will change the default font color of a TImageEnMView users will not see the change take place automatically when the theme changes.
IOW, a user must re-populate the TImageEnMView after changing a theme to show the new font (or for the TImageEnFolderMView call RefreshFileList).
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
|
Topic |
|