Miscellaneous CDK
From TeamDeveloperWiki
This page covers miscellaneous CDK Tips & Tricks
Contents |
Why do old CDK tools fail to work on newer TD versions
You have to use the command line parameter "-MTX" with apps using CDK.
Gupta introduced this with TD 2005 PTF1, TD 2005.1 and TD 3.1 PTF4.
Place the -MTX parameter behind all other parameters in the user tool settings :
"$Outline $MainWindow $File -MTX"
How to merge an application using CDK
The following sample shows how to merge an application and save it back to disk.
First include cdk.apl.
The next function performs the task, it merges Test.apt and saves it as Test_merged.apt:
Function: MergeAndSaveApplication
Local variables
cdkApplication: uApplication
Actions
If uApplication.InitFromFile( "c:\\Test.apt" )
Call SalOutlineMergeIncludes( uApplication.GetOutline( ) )
Call uApplication.SaveOutlineAsText( "c:\\Test_merged.apt", FALSE )
Call uApplication.CloseApp( )
How to get object attributes at runtime
You can query the attributes of GUI objects like datafields, forms, pictures etc at runtime.
Everything you can set at design time using the attribute inspector can be queried programatically.
(even when running as executable).
All elements in your sources have an equivalent in the CDK, represented as a outline item or type ID.
For instance, a datafield is represented as the CDK constant CDK_IT_DataField having a value of 0x0004.
A datafield has a Justification attribute (left, center, right) represented as CDK_IT_Justify with value 0x008E.
Have a look in the library CDK.apl (which is installed in your TD installation folder when you have specified CDK during installation).
All possible objects, types, variables, attributes etc etc can be found as represented constants in the Constants/System section.
Using some undocumented functions, you can query attributes of GUI objects at runtime using the CDK constant values.
You don't need to include CDK.apl in your project, you may just use the constant values of the wanted CDK items.
For instance, to get the type of a dialog (Modal, System Modal or Modeless) do the following :
Set nCurrentOutline = SalOutlineCurrent( )
Set nFormItemHandle = SalOutlineItemOfWindow( hWndForm )
If nFormItemHandle > 0
! You can use 0x0044 instead of the CDK_IT_DialogType constant
Call SalOutlineItemTypeText( nCurrentOutline, nFormItemHandle, CDK_IT_DialogType, FALSE, sAttributeValue )
!
! sAttributeValue equals "Modal", "System Modal" or "Modeless"
Another example to get the justification of a datafield (Left, Center or Right):
Set nCurrentOutline = SalOutlineCurrent( )
Set nDatafieldItemHandle = SalOutlineItemOfWindow( dfCustomer )
If nDatafieldItemHandle > 0
! You can use 0x008E instead of the CDK_IT_Justify constant
Call SalOutlineItemTypeText( nCurrentOutline, nDatafieldItemHandle, CDK_IT_Justify, FALSE, sAttributeValue )
!
! sAttributeValue equals "Left", "Center" or "Right"
Here you can download a sample:
How to generate a GUID
The CDK has a standard function to generate GUID strings.
A GUID is a Globally Unique Identifier, used in applications for references using a unique number.
(MS Com system uses it for identifying ActiveX/COM objects).
For example :
{F43334A2-4EF5-4411-9281-7265CB4107F9}
Include the library CDK.apl, there you will find this external function:
sGUID = CDKRegenerateGUID( )
Here you can download a sample:
List of features CDK does not offer
The following list contains features which CDK does NOT supply.
This could save you some time in searching wanted functionality which is known not to be present.
- Compiling applications
- Suppressing the load information window (when opening a TD source from CDK)
TODO: add more items to this list. When others know other not supported features, please add this to the list.

