Information générale
Catégorie:
The Mere Mortals Framework
Titre:
Integration SDT - MM
I would like to integrate SDT with Mere Mortals CodeBook to automaticly fill in properties from the data dictionary into the controls, like the caption, format, width etc.
I have tried this by putting the following code into the Init() event of the cTextBoxL class:
*-------------------------------------------------------------------
DODEFAULT()
LOCAL loPrimaryBizObj,;
lcDatabaseName,;
llUseLocalData,;
oMetaMgr, ;
liID, ;
lcProp
loPrimaryBizObj = ThisForm.oPrimaryBizObj
IF TYPE('loPrimaryBizObj') != 'O'
WAIT WINDOW 'Primary Business Object (oPrimaryBizObj) is not instantiated'
RETURN
ELSE
loPrimaryBizObjEnvironment = loPrimaryBizObj.GetDataEnvironment()
lcDatabaseName = loPrimaryBizObjEnvironment.cDefaultDatabaseName
llUseLocalData = loPrimaryBizObjEnvironment.lUseLocalData
ENDIF
IF TYPE('goApp') # 'O'
WAIT WINDOW 'Application Object (goApp) not instantiated'
RETURN
ENDIF
* If we have a ControlSource and there's a application oMeta object or the oMeta
* property of the form this control is in has an oMeta object, use
* DBGetDBCKey() to get the ID for the field.
WITH This.TextBox
IF not empty(.ControlSource) and (type('goApp.oMeta') = 'O' and ;
not isnull(goApp.oMeta)) or (type('Thisform.oMeta') = 'O' and ;
not isnull(Thisform.oMeta))
oMetaMgr = iif(type('goApp.oMeta') = 'O' and not isnull(goApp.oMeta),;
goApp.oMeta, Thisform.oMeta)
slcFieldName = IIF(llUseLocalData,'L','V')+.ControlSource
liID = oMetaMgr.DBGetDBCKey(lcDatabaseName, 'Field', slcFieldName)
* Set InputMask and format to the appropriate properties if they aren't blank.
lcProp = dbgetprop(slcFieldName, 'Field', 'InputMask')
.InputMask = iif(empty(lcProp), .InputMask, lcProp)
lcProp = dbgetprop(slcFieldName, 'Field', 'Format')
.Format = iif(empty(lcProp), .Format, lcProp)
* Set ToolTipText to the appropriate property if it isn't blank.
lcProp = oMetaMgr.DBCXGetProp('CBmToolTip', liID)
.ToolTipText = iif(empty(lcProp), .ToolTipText, lcProp)
* Set StatusBarText to the appropriate property if it isn't blank.
lcProp = oMetaMgr.DBCXGetProp('CBmMessage', liID)
.StatusBarText = iif(empty(lcProp), .StatusBarText, lcProp)
ENDIF not empty(.ControlSource) ...
slcType = oMetaMgr.DBCXGetProp('CBcType',liID)
slnSize = oMetaMgr.DBCXGetProp('CBnSize',liID)
DO CASE
CASE slcType = 'D' AND ((SET('CENTURY') = 'ON' AND .Century = 2) ;
OR .Century = 1)
.Width = 77+.Margin
IF .Parent.Class = 'Column'
.Parent.Width = 77+.Margin
ENDIF
CASE slcType = 'D'
.Width = 63+.Margin
CASE LEN(ALLTRIM(.InputMask)) > slnSize
.Width = (LEN(ALLTRIM(.InputMask))+1)*7+.Margin
OTHERWISE
.Width = (slnSize+1)*7+.Margin
ENDCASE
ENDWITH
*------------------------------------------------------------------
The problem is that when I put this in the Init() event, the Business Object is not instantiated yet.
Does anyone have any suggestions of where to put this code, or is there already some documentation about this type of integration?
Thanks!
Jaco
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement