ITQuants blog

How to set native Sophis Risque fields using the Low Level Toolkit?

Sep 28

Written by:
9/28/2012 11:33 AM  RssIcon

In most cases, and on versions of Sophis Risque before the 6.0, it is not possible to access to the native fields using the toolkit Sopshis method GetElementByRelativeId, beacause such fields are not natively a CSRElement.

The goal of this post is to show how to use Low Level Toolkit, in order to update the display, and the internal structure on a specific case (Folio creation/modification).

We take as sample the case where we want to change the default entity of the folio by forcing the selection of some specific entity when opening the dialog.

The method on which the C++ implementation will be done is an override of CSRFitDialog::OpenAfterInit.

In most cases, and on versions of Sophis Risque before the 6.0, it is not possible to access to the native fields using the toolkit Sopshis method GetElementByRelativeId, since the field is not natively a CSRElement.

The goal of this post is to show how to use Low Level Toolkit, in order to update the display, and the internal structure on a specific case (Folio creation/modification).

We take as sample the case where we want to change the default entity of the folio by forcing the selection of some specific entity when opening the dialog.

The method on which the C++ implementation will be done is an override of CSRFitDialog::OpenAfterInit.

By editing the native folio configuration dialog stored in SphRiskEn64.dll (drag an drop of this dll in Visual Studio), we can see that the identifier used in the MFC resource is equal to 112 (see figure below).

To find quickly the right dialog identifier (2141) is quite simple: it corresponds to kPortfolioDialogId_BO declared in sphportfolio.h + 2000, where 2000 is the well-known offset  used in Sophis for dialogs. Another possibility is to double-right click on the Sophis icon in the About dialog box, and to right click on the Folio dialog: a popup indicating the dialog id should appear.

 

 In order to modify the display of the field using the internal and native Sophis controls, the TDlog and TItem structures have to be used. it can be done by including the following file:

#include

 If an item of a combobox control has to be set, the TPopup structure has to be used. The text selection in the menu of the combobox can be done with the CSUMenu class and the associated helperfunctions which can retrieved by including the following files:

#include

 #include

 In order to retrieve the TItem object which corresponds to the 112 identifier, the FindUserUserItem has to be used. To set the value on the popup, the TPopup.setValue method can be used.

Finally the following code makes the initiation of the Sophis native entity combobox:

const UINT _entityId = 112; // id of the combobox

char _name[256] = "";

_entity->GetName(_name); // entity name used as key

TDlog* _dialog = GetDlog();

TItem* _item = NULL;

if (_dialog && FindUserItem(_dialog, _entityId - ID_ITEM_SHIFT, &_item))

{

MenuHandle _menu = _item->infos.popup.menu;

short _value = FindMenuItem(_menu, _name, false); // this is the index associated to that string in the combo box

_item->infos.popup.SetValue(_value);

if(_item->infos.popup.action) // to be sure to update the internal structure sotring the entity

// that will be used for saving.

_item->infos.popup.action(_dialog,_entityId - ID_ITEM_SHIFT,_value);

SetModified();

}

The call of the action callback permits the initialisation of the internal structure used to store the information of the current folio being edited. This is required in order to save correctly the folio when the user clicks on the OK button.

Search blog