Archive for September 2011

JSDialog Pack 2.0.009

A new release of JSDialog Pack is now available.

Changes include:

  1. Added XE2 Support
  2. Added support for custom VCL styles
  3. Added 64-bit support
  4. Improved BiDiMode support
  5. Updated default images used by the command link button
  6. Removed language defined in resource files
  7. Move some methods around in preparation for the next release
  8. Improve large font support
  9. Fix layout issue when dialog has a footer and expanded content is being displayed in the footer section of the dialog.
  10. New wrapper function ShowErrorTitleMessageWithErrorAndFooter, which displays and error dialog with an expandable section that contains additional text. Can also display a footer and footer icon.
  11. Update documentation


Current customers should have already received the required update (two emails were rejected – contact support to resolve if you are missing an expected email).
Please check your spam filters and make sure you white list our domain.


JSDialog Pack information


XE2: TDatamodule v TImageList, TActionList, TTimer etc.

TDataModule has changed in XE2

 

Follow these steps:

  1. File | New | VCL Forms Application
  2. File | New | Other | Delphi Files | DataModule

You should now have a win32 VCL project with a datamodule. Select the data module and drop a TImageList component on it.

I’ll wait while you try it…

You can’t!

Looking at the Tool Palette with the data module selected displays a list of available component categories – so many are now missing (such as TImageList, TTimer and TActionList).

Filtered Tool Palette

As you can see that is a pretty selective list of component categories. The reason there are so few components available to be placed on the data module is because a data module is a multiple framework container (it is declared in System.Classes). This means that only components compatible with the VCL and FireMonkey framework are visible by default. Luckily, there is a way to allow previously filtered components a place on the tool palette.

A new property

Looking at the list of properties for the data module you will see there is a new one.

Data Module Properties

This new property is called ClassGroup and allows you to define what group of classes are allowed on the data module.

Group of Classes (wth)

TComponent descendants (that are only permitted on a data module) can influence which framework they are aligned to. They can either allow use in any framework by grouping with the System.Classes.TPersistent type or can move up in the inheritance chain and choose to be aligned specifically with the VCL or FireMonkey frameworks.

You’ll notice that with all of the unit scoping added to XE2, both frameworks share quite a lot of code. The shared framework code unit names do not start with FMX or Vcl. So the System.Classes unit can be used in either a VCL or FireMonkey application without issue. This is why only dual framework compatible components are displayed when the data module is first created.

Example of how to associate a TComponent descendant to the VCL framework.

  StartClassGroup(Vcl.Controls.TControl);
  ActivateClassGroup(Vcl.Controls.TControl);
  RegisterComponents('jed-software.com', [TJSDialog]);
  RegisterComponents('jed-software.com', [TJSDialogCheck]);
  GroupDescendentsWith(TJSCustomDialog, Vcl.Controls.TControl);

To associate with the FireMonkey framework, replace Vcl.Controls.TControl with FMX.Controls.TControl.

Back to the ClassGroup property

I’d point you to the documentation on the wiki about this “property” except it isn’t documented (http://docwiki.embarcadero.com/VCL/XE2/en/Classes.TDataModule_Properties).

I’ve put the word “property” in quotes because it really isn’t a property as you’d normally expect. The value isn’t persisted to the DFM/FMX file it’s value is stored in the actual pascal unit that accompanies the data module.

Dropping down the property displays four choices:

Available ClassGroup values

 

System.Classes.TPersistent DataModule only allows cross framework enabled components to be placed on it.
Vcl.Controls.TControl DataModule allows components added to the Vcl.Controls.TControl class group to be added to it.
FMX.Types.TControl DataModule allows components added to the FMX.Controls.TControl class group to be added to it.
FMX_Types.TControl This is for iOS controls.

Change the ClassGroup property value to Vcl.Controls.TControl.

Currently the Tool Palette doesn’t always refresh when the value is changed, so you may need to either close and reopen the file or change to another open file in the IDE and back to the data module to see the Tool Palette update.

Filtered Tool Palette

You can now grab a TImageList and place it on the data module.

Friendship rekindled

 

Storing the ClassGroup value

If you hit F12 (and it works) to view the source code you will see a line added to the source file under the implementation section of the unit.

{%CLASSGROUP ‘Vcl.Controls.TControl’}

Don’t delete this line, or you’ll lose the setting of the ClassGroup “property”. This particular property is not stored in the DFM or FMX file. If you do happen to remove the line, the property value is cleared.

 

Changing the ClassGroup value

If you now try to change the value of ClassGroup to FMX.Controls.TControl you will be prompted with the following error. You need to fix these errors before you can change the ClassGroup value successfully.

Changing ClassGroup error

Backwards Compatibility

When loading previously created data modules, you won’t see your non-compliant components disappear or get deleted. They will still happily display and you can still run your application without needing to change the ClassGroup property. You will not be able to add one of these non-compliant components to the data module until you change the ClassGroup value though.