We use SQL Direct version 6.4 in Delphi XE2 (Win7, 64-bit, but we only do 32-bit development).
I was making a new test app and found the following:
In the tool palette, when I'm on a form, there are 10 components available:
In the tool palette, when I'm on a datamodule, only 3 of these are available:
This was in a new project. I found this out when I tried to copy a TSDDatabase from another project to a datamodule in my new project.
This tells you that we have (several) other projects containing TSDDatabase (and other from the 10 minus 3) components on a datamodule, which still build and run fine.
I was actually already writing another question into SO when I noticed the following:
The datamodule I try to place a TSDDatabase contains the new
{%CLASSGROUP 'System.Classes.TPersistent'}
And the source file responsible for the component registration starts with this:
procedure Register;
begin
{$IFDEF EVAL}
ShowReminderBox;
{$ENDIF}
{$IFDEF SD_VCL10}
// Restrict these components to only be used with VCL components.
GroupDescendentsWith(TSDDatabase, Controls.TControl);
GroupDescendentsWith(TSDDataSet, Controls.TControl);
GroupDescendentsWith(TSDSession, Controls.TControl);
GroupDescendentsWith(TSDUpdateSQL, Controls.TControl);
{$ENDIF}
RegisterComponents(srSQLDirect, [TSDSession, TSDDatabase, TSDQuery, TSDMacroQuery, TSDStoredProc, TSDTable, TSDUpdateSQL, TSDScript, TSDMonitor, TSDSQLBaseServer]);
RegisterPropertyEditor(TypeInfo(Boolean), TSDDatabase, 'Connected', TSDDatabaseConnectedProperty);
RegisterPropertyEditor(TypeInfo(string), TSDDatabase, 'RemoteDatabase', TSDDatabaseProperty);
RegisterPropertyEditor(TypeInfo(string), TSDDatabase, 'SessionName', TSDSessionNameProperty);
RegisterPropertyEditor(TypeInfo(string), TSDDatabase, 'ParamsFileName', TSDFileNameProperty);
RegisterPropertyEditor(TypeInfo(string), TSDDataSet, 'DatabaseName', TSDDatabaseNameProperty);
RegisterPropertyEditor(TypeInfo(string), TSDDataSet, 'SessionName', TSDSessionNameProperty);
RegisterPropertyEditor(TypeInfo(string), TSDScript, 'DatabaseName', TSDDatabaseNameProperty);
RegisterPropertyEditor(TypeInfo(string), TSDScript, 'SessionName', TSDSessionNameProperty);
RegisterPropertyEditor(TypeInfo(string), TSDStoredProc, 'StoredProcName', TSDStoredProcNameProperty);
RegisterPropertyEditor(TypeInfo(string), TSDTable, 'TableName', TSDTableNameProperty);
When I removed the %CLASSGROUP statement the issue was gone.
Obviously 'grouping the descendants with' Controls.TControl together with the CLASSGROUP was the cause.
But despite looking up %CLASSGROUP pseudo-property and GroupDescendentsWith I fail to understand what that last statement does specifically.
Can anyone explain in more detail what's going on here? And specifically, how should the registration code be changed (since we have the Pro version with source, we could patch this) to prevent other colleagues wasting hours as I did? ;-)
(And: 10 minus 4 GroupDescendentsWith statements makes 6, not 3)??