1. Change Item Order 2. Item/Objects from Base class not in Item List

forum.cdk (1998-2005) & forum.td.cdk (2005-2010)
Stefan Müller

1. Change Item Order 2. Item/Objects from Base class not in Item List

Post by Stefan Müller » 10 Oct 2002, 16:16

 Posted by:  Stefan Müller 

Hi,

i have written a little programm generator that creates a Form window that
is derived from a base class with some object in it

Class: cfrmBase
contains df1, df2, df3

frmNewForm is derived from cfrmBase

If my generator add some new datafields on frmNewForm the order in the
source is
dfnewA, dfnewB, dfnewC, df1, df2, df3

1. How can i change the order of the items using the cdk? I didnt find any
"Move" or "Swap" item function
-------------------------------------------------------------
My second problem is:
Class: cfrmBase
contains a ChildTable tblTest with col1, col2

frmNewForm is derived from cfrmBase

I tryed to get the tblTest of frmNewForm but i dont find it. For example the
GetFirstItem, GetNextItem only gets the "normal" items frmNewForm and not
the items that are based on cfrmBase.

How can i get tblTest?

Stefan

bm

Re: 1. Change Item Order 2. Item/Objects from Base class not in Item List

Post by bm » 10 Oct 2002, 17:30

 Posted by:  bm 

1. The tab-order of the objects depends on the order in the outline.
So insert your objects behind the other's.
The way is to navigate to the Object (see the following code) and use
cdkItem.InsertItemAfter.

2. If you have navigate to the form, you have to use GetNextSibling.
The following is a code, which list all object's of a form including all
columns in tables in the form.

!!CB!! 278
Function: OnCreate
Description:
Returns
Parameters
Static Variables
Local variables
: aItem
Class: cdkItem
Boolean: bReturn
Number: nItemSich
Number: nRow
: xMenus[*]
Class: cdkMenu
Actions
Call aItem.Initialize(CDK_App.GetOutline(),
SalStrToNumber(strArgArray[3]))
! Set nItem = aItem.EnumChildObjects( CDK_IT_Menu, xMenus )
! If nItem > -1
Call Test( xMenus[0], '1234' )
Set bReturn=aItem.GetFirstChild(aItem)
While aItem.GetNextSibling( aItem )
If aItem.GetItemType() = 314 OR aItem.GetTitle() = 'Tool Bar'
Break
If aItem.GetItemType() = 314 OR aItem.GetTitle() = 'Tool Bar'
! Ab jetzt jeder Eintrag ein Objekt
Set bReturn=aItem.GetFirstChild(aItem)
Set bReturn=aItem.GetFirstChild(aItem)
While bReturn
! Wenn Eintrag kein Kommentar, d.h. ein Objekt
If aItem.GetItemType()!=188
! in Listbox eintragen
Set nRow = SalTblInsertRow( hWndItem, TBL_MaxRow )
Set colnObjekt = aItem.m_hItem
Set colstrName = ' TB - '||aItem.GetText()
Set colstrClass = aItem.GetClassName()
Set colstrObjekt = aItem.GetStringFromValue(aItem.GetItemType())
If SalStrMidX( colstrObjekt, SalStrLength( colstrObjekt ) - 1, 1 ) =
':'
Set colstrObjekt = SalStrMidX( colstrObjekt, 0,
alStrLength( colstrObjekt ) - 1 )
If SalIsNull( colstrClass )
Set colstrClass = colstrObjekt
Call SalColorSet( SalTblGetColumnWindow( hWndItem, 3, COL_GetPos ),
COLOR_IndexCellText, COLOR_DarkGreen )
Call SalColorSet( SalTblGetColumnWindow( hWndItem, 4, COL_GetPos ),
COLOR_IndexCellText, COLOR_DarkGreen )
! Wenn Tabelle, dann Columns übernehmen
If aItem.GetItemType()=3
Set nItemSich = aItem.GetItem()
! Eintrag "Contents" der Tabelle lesen
Set bReturn=aItem.GetFirstChild(aItem)
! Erste Column lesen
Set bReturn=aItem.GetFirstChild(aItem)
While bReturn
! in Listbox eintragen
Set nRow = SalTblInsertRow( hWndItem, TBL_MaxRow )
Set colnObjekt = aItem.m_hItem
Set colstrName = ' '||aItem.GetText()
Set colstrClass = aItem.GetClassName()
Set colstrObjekt = aItem.GetStringFromValue(aItem.GetItemType())
If SalStrMidX( colstrObjekt, SalStrLength( colstrObjekt ) - 1, 1 ) =
':'
Set colstrObjekt = SalStrMidX( colstrObjekt, 0,
alStrLength( colstrObjekt ) - 1 )
If SalIsNull( colstrClass )
Set colstrClass = colstrObjekt
Call SalColorSet( SalTblGetColumnWindow( hWndItem, 3, COL_GetPos ),
COLOR_IndexCellText, COLOR_DarkRed )
Call SalColorSet( SalTblGetColumnWindow( hWndItem, 4, COL_GetPos ),
COLOR_IndexCellText, COLOR_DarkRed )
! Nächste Eintrag
Set bReturn=aItem.GetNextSibling(aItem)
Call aItem.Initialize( CDK_App.GetOutline(), nItemSich )
! Und nächsten Eintrag
Set bReturn=aItem.GetNextSibling(aItem)
! * Form
Call aItem.Initialize(CDK_App.GetOutline(),
SalStrToNumber(strArgArray[3]))
Set bReturn=aItem.GetFirstChild(aItem)
! Bis "CONTENTS" ignorieren
While aItem.GetNextSibling( aItem )
If aItem.GetItemType() = 114
Break
! Ab jetzt jeder Eintrag ein Objekt
Set bReturn=aItem.GetFirstChild(aItem)
While bReturn
! Wenn Eintrag kein Kommentar, d.h. ein Objekt
If aItem.GetItemType()!=188
! in Listbox eintragen
Set nRow = SalTblInsertRow( hWndItem, TBL_MaxRow )
Set colnObjekt = aItem.m_hItem
Set colstrName = aItem.GetText()
Set colstrClass = aItem.GetClassName()
Set colstrObjekt = aItem.GetStringFromValue(aItem.GetItemType())
If SalStrMidX( colstrObjekt, SalStrLength( colstrObjekt ) - 1, 1 ) = ':'
Set colstrObjekt = SalStrMidX( colstrObjekt, 0,
alStrLength( colstrObjekt ) - 1 )
If SalIsNull( colstrClass )
Set colstrClass = colstrObjekt
! Wenn Tabelle, dann Columns übernehmen
If aItem.GetItemType()=3
Set nItemSich = aItem.GetItem()
! Eintrag "Contents" der Tabelle lesen
Set bReturn=aItem.GetFirstChild(aItem)
! Erste Column lesen
Set bReturn=aItem.GetFirstChild(aItem)
While bReturn
! in Listbox eintragen
Set nRow = SalTblInsertRow( hWndItem, TBL_MaxRow )
Set colnObjekt = aItem.m_hItem
Set colstrName = ' '||aItem.GetText()
Set colstrClass = aItem.GetClassName()
Set colstrObjekt = aItem.GetStringFromValue(aItem.GetItemType())
If SalStrMidX( colstrObjekt, SalStrLength( colstrObjekt ) - 1, 1 ) =
':'
Set colstrObjekt = SalStrMidX( colstrObjekt, 0,
alStrLength( colstrObjekt ) - 1 )
If SalIsNull( colstrClass )
Set colstrClass = colstrObjekt
Call SalColorSet( SalTblGetColumnWindow( hWndItem, 3, COL_GetPos ),
COLOR_IndexCellText, COLOR_DarkRed )
Call SalColorSet( SalTblGetColumnWindow( hWndItem, 4, COL_GetPos ),
COLOR_IndexCellText, COLOR_DarkRed )
! Nächste Eintrag
Set bReturn=aItem.GetNextSibling(aItem)
Call aItem.Initialize( CDK_App.GetOutline(), nItemSich )
! Und nächsten Eintrag
Set bReturn=aItem.GetNextSibling(aItem)
! Ende
Call SalTblSetFlagsAnyRows( hWndItem, ROW_New, FALSE, 0, 0 )
Call SalTblSetFocusRow( hWndItem, 0 )
Call SalTblSetRowFlags( hWndItem, 0, ROW_Selected, TRUE )

To see this code in use, search in forum.sourcecode for "Again : Prop32"
from 07.02.2001

Stefan Müller

Re: 1. Change Item Order 2. Item/Objects from Base class not in Item List

Post by Stefan Müller » 11 Oct 2002, 12:36

 Posted by:  Stefan Müller 

Thank you but...

this works for existing code, but if i create a new form with

-> Call oApp.AddTopLevelWindow( CDK_IT_FormWindow, 'frmEdit', oForm )

and change to base class with
-> Call oForm.SetObjectClass( '__TabelleEdit' )

and start to scan all Item, i could not find the __TableEdit-Objects.

If i save the App and open it and scanning this file all object are there.
Do i have to call any REFRESH or something after SetObjectClass?

Stefan

bm

Re: 1. Change Item Order 2. Item/Objects from Base class not in Item List

Post by bm » 11 Oct 2002, 13:39

 Posted by:  bm 

Sorry, I didn't have this problems.
Can you show me the code where you do it?

Stefan Müller

Re: 1. Change Item Order 2. Item/Objects from Base class not in Item List

Post by Stefan Müller » 11 Oct 2002, 14:54

 Posted by:  Stefan Müller 

I found the solution while i was creating the demo-code.

My cfrmBase was defined in an .apl and the apl was included with
Call oApp.AddLibraryFileInclude( 'TblEditbase.apl', oLib )

but i did not call oApp.RefreshLibraries( ) because i thougth that Centura
load an include file automaticly. But he (it) dont do it and so i chanded
the baseclass to an undefind class and im missing the objects.

Thanks

Stefan

Return to “td.cdk”

Who is online

Users browsing this forum: [Ccbot] and 0 guests