Where do VCL styles come from? - delphi

In my programming team we all use Delphi XE2 Professional. We just figured out that on different computers different numbers of VCL styles are available.
Where do VCL styles come from? Do I have to take care to move styles from one Delphi installation to another?

Q : Where do VCL styles come from?
A : The Vcl Styles files are part of the Delphi XE2 and XE3 versions, and are installed in two locations C:\Users\Public\Public Documents\RAD Studio\<n.n>\Styles and C:\Program Files (x86)\Embarcadero\RAD Studio\<n.n>\Redist\styles\vcl folders.
Also you the Vcl Styles files can be created from the scratch or customized, so maybe some of the machines contains custom Vcl Styles and that explain the different numbers of vsf files.
Q : Do I have to take care to move styles from one Delphi installation to another?
That's depends of how the Vcl Styles are added to the Delphi project. Basically exist 3 ways of add the Vcl styles to your project.
Using the Projects->Options->Application->Appearance Menu option. In this case a new entry by each style is added to the .dproj (Delphi project file) with the path to the style. After when you compile you project the styles referenced by the .dproj file are embedded as a resource.
Loading the styles manually (from a external file or resource) using the TStyleManager class.
Editing directly the .dproj file and adding a new entry called VCL_Custom_Styles in the <PropertyGroup Condition="'$(Base)'!=''"> Key.
So if you Delphi project is referencing the Vcl styles using the method 1 or 3, you will need copy the Vcl Styles between machines to avoid compilations problems if a Vcl style is missing.
Note : As recommendation you can create a style folder (and add that folder as part of you source control scheme) in your Delphi project location and here copy the vcl styles used by you Application, and then modify your code to load the styles using the method 2.

Related

How to name files to differentiated VCL and FireMonkey code

I have a VCL component that runs on Delphi 7 to 10.3. I am now porting it to FMX.
To avoid maintaining two codebases, I will use conditional defines in my source to separate any custom FMX and VCL code. When I compile the component for distribution a script will output either the VCL or FMX source files.
My problem is how to make the VCL DCUs and FMX DCUs co-exist on the same system (for users who have both the VCL and FMX versions of my component) as both folders will need to be on the Delphi path.
In other words, my VCL units are named: myunit1.pas, myunit2.pas, etc.
And the FMX versions: fmx.myunit1.pas, fmx.myunit2.pas, etc
(Ideally I would name the VCL ones vcl.myunit1.pas, vcl.myunit2.pas, etc. That way the VCL version of the component would only see the vcl.-.pas files and the FireMonkey only the fmx.-.pas files. Unfortunately I cannot do this because then it won't work on older Delphi versions).
Now when I compile a FireMonkey app it tries to use the non-fmx prefixed source files, in preference to the fmx._.pas ones. I need to "hide" the vcl source folder to get it to compile (re-ordering the Delphi paths does not help).
If there another way to make FireMonkey avoid using the vcl files?
(I fear I will need to write a script to give all the files a new name, e.g. FMXmyunit1.pas and update all of the references in all of the files).
Because Delphi does not provide predefined compiler conditionals to distinguish between the Firemonkey and the VCL framework you can add the symbol $(FrameworkType) into the conditional defines list of the application project settings. This enables the differentiation of the framework within your library by using the conditional compiling symbols FMX and VCL.
Example of typical usage:
uses
{$IFDEF FMX}
FMX.Forms,
{$ENDIF}
{$IFDEF VCL}
VCL.Forms,
{$ENDIF}
This works in my own cross-platform library for pure VCL and FMX projects, where I let integrate the source files directly into the project. In this simple way, the DCU will be recompiled each time. In the case of mixed projects, the $(FrameworkType) contains the initial framework of the application.
When you deliver a package (bpl) things get more complex. You must provide two versions of your bpl for FMX and VCL. If you also provide the source code for debugging purposes, the only option is to completely differentiate the source code files for the FMX and VCL versions, as long as they have platform-dependent code.
Well, I don't know if it's really a solution, but it works for me.
I wrote an application that copies all my VCL files to my FireMonkey folder and renames them with an FMX prefix, i.e myunit.pas becomes FMXmyunit.pas. It also updates all the references in the pas files and adds a {$DEFINE FMX} to the header. Now both my VCL and FMX versions coexist happily.
Also, I have set my merge tool (Beyond Compare) to ignore the FMX prefix, so I can merge either platform version directly to my local Git copy.

Delphi DualListBox module - where to find?

I am supporting some legacy Delphi project. This project is divided into modules that stored in DLLs.
I need to compile one of the modules (last compiled in 2007). This module uses module DualListBox and has a variable of type TDualListBox:
uses DualListBox ....;
...
lbMasterOrders: TDualListBox;
lbChildOrders: TDualListBox;
The problem is, I don't know where to find module DualListBox. I can't find it on my machine, and I can't find it on the internet.
As far as I understand, the TDualListBox component must be something like ListBox that can Add rows at runtime.
At first, i thought that DualListBox is a part of RxLib, but RxLib's component is called DualListDialog and it's something completely else.
So maybe this is the self-written module by prev developer, that was deleted somehow.
But somehow the compiled DLL (that was comiled in 2007) is working perfectly fine. Maybe I can investigate where to find that module by decompiling that DLL?
If so, where should I look in the decompiled project? I'm using DeDe for decompiling.
The unit is called duallist and is automatically generated by Delphi 2007 (and also Delphi 10.1 and 10.2, don't know about other versions, but I would be surprised if they didn't have it) when you open a VCL project and click:
File
New
Other
Delphi Projects
Delphi Files
Dual list box
These units are usually taken from the object repository, which by default is located in the ObjRepos subdirectory of the Delphi installation.

Cannot add TMS async components to win32 firemonkey program

I have a firemonkey app targeted only at win32. I want to add the tms async serial communications component. When I do so and try to build it gets upset trying to compile the tms source code. It is non-trivial to change the tms source code.
Where is it picking up the library path to the source code? If I remove that path will it use the existing .dcu files and work? Is there any other suggestions?
What was catching me is that even though I had removed the directories from the options search path,, I had one of the tms rtl files still open in the ide. As a precaution, I also went and moved the tms source files elsewhere...
The form compiled and the components work.

Add fmx form to Delphi Package

As the title says really. How can I add an FMX form to a delphi package? In the package I have a Tpanel descendant component - which is all installed fine. What I'd like to do is include a form in the package so that when I click on the panel at runtime the form pops up for example. (I don't want to use the FMX form at design time - just at runtime, so I just want to include the FMX form as in the package, the component has design time properties though)
It seems I can only add a VCL form to the package - when I right click and 'add new' to the package, it tries to add the VCL to the package - which I don't want. I want to run it on OSX.
I've found plenty of adding VCL forms e.g. Adding forms and frames to packages probably something obvious I'm missing - tia
Delphi XE6 on Windows 8/OSX target
Packages have affinity to a particular framework. Your package appears to be a VCL package. In the .dproj file you will find
<FrameworkType>VCL</FrameworkType>
Change this to
<FrameworkType>FMX</FrameworkType>
to have affinity to FireMonkey.
Although I've not done so recently, I expect that you get to make the framework affinity choice when you create the package. Presumably you chose VCL. Or the package was created before FMX existed and the project upgrade process added (correctly) the VCL framework setting.

how to show the files thumbnails like windows explorer in delphi?

I use the TFileListBox control to show lists of files. But I wonder how to show the file thumbnails in the same way that Windows Explorer does?
You should try using the ShellControls components included in Delphi. (Note that David Heffernan sort of mentioned, and TLama made the initial specific suggestion in the first two comments to your question.) They're not installed by default in recent versions, so you'll have to install them yourself.
These instructions are for the version of Delphi you've indicated you're using (Delphi 2010) - they're the same basically for XE/XE2, except they're in the Samples\Delphi\VCL\ShellControls folder instead (and the Start entry contains XE or XE2 instead of 2010, of course).
Use Start->All Programs, navigate to the Embarcadero RAD Studio or Embarcadero Delphi 2010 item, expand it, and choose Demos. It's in the Win32 folder under DelphiWin32\VCLWin32\ShellControls. Open and build the vclshlctrls.dproj first, and then build and install the dclshlctrls.dproj. You'll need to add the folder above to your Project->Options in the search path for the compiler to be able to find them.
To install the components after building the second package, right-click on the project in the 'Project Manager' and choose 'Install' from the popup (context) menu. The 'Project Manager' in the default configuration is the area on the right edge of the screen that displays the files in the project. Remember, you need to build vclshlctrls first, and then install dclshlctrls, which is the design-time package.
You should then find the TShellListView, TShellTreeView, TShellComboBox, and TShellChangeNotifier components on your palette in the Samples category.
.thumb files are ordinary png files, just with a different file suffix.
Knowing this one can display them in a TImage.
First the .thumb extension needs to be registered as new file format.
For this include PngImage in your uses and call this:
MyImage.Picture.RegisterFileFormat('thumb', 'PNG based thumbnails', TPngImage);
Later you can display the thumb file you like like this:
MyImage.Picture.LoadFromFile('d:\Pictures\Pictures.thumb');

Resources