Origin Ver. and Service Release (Select Help-->About Origin): 7.5 SR7
Operating System: Windows Vista
Hi,
I have created a GETN dialog but I would like to know how to ensure that the focus is on the dialog whenh it is created. Currently the focus is on the layer underneath and I have to click on the dialog twice before eg a check box is affected.
Another question I have is how can I trap the event of collapsing and expanding branches. Ideally I would like to change a numeric value in the dialog when a branch is collapsed or expanded.
Example code I have used so far is
bool SaveAndPrint()
{
char szBuffer[200];
LT_execute("%Z = SaveGraphsPath$");
LT_get_str("%Z", szBuffer, 200);
string IndividualSavePath = szBuffer;
string MultipleSavePath = szBuffer;
double NGpPSave;
LT_get_var("NGpPSave", &NGpPSave);
double dNumCompResults;
LT_get_var("NumCompResults", &dNumCompResults);
GETN_TREE(tr)
GETN_BEGIN_BRANCH(Save, "Saving Options")
GETN_OPTION_BRANCH(GETNBRANCH_OPEN | GETNBRANCH_KEEP_SIZE_ON_COLLAPSE)
GETN_CHECK(IndividualSave, "Save all individual compounds", false)
GETN_LIST(IndividualType, "Image type", 1, "pdf|wmf")
GETN_BUTTON(IndividualPath, "File path", IndividualSavePath)
GETN_OPTION_COLOR_LABEL(COLOR_GREEN) // Option to color node label green
GETN_OPTION_EVENT(InidividualOnClickButtonEvent) // Option specifying event handler for browsing
GETN_CHECK(MultipleSave, "Save all multiple compounds per page", true)
GETN_LIST(MultipleType, "Image type", 1, "pdf|wmf")
GETN_NUM(SaveGraphsPerPage, "Graphs per page", NGpPSave)
GETN_BUTTON(MultiplePath, "File path", MultipleSavePath)
GETN_OPTION_COLOR_LABEL(COLOR_GREEN) // Option to color node label green
GETN_OPTION_EVENT(MultipleOnClickButtonEvent) // Option specifying event handler for browsing
GETN_END_BRANCH(Save)
GETN_BEGIN_BRANCH(Print, "Printing Options")
GETN_OPTION_EVENT(PrintBranchEvent)
GETN_NUM(PrintGraphsPerPage, "Graphs per page", 1)
GETN_OPTION_EVENT(PrintBranchEvent)
GETN_END_BRANCH(Print)
// Open GetNBox dialog and edit input defaults passing GetN tree named tr
// and having dialog title "Using GetN Macros" and dialog description "This is
// a GetN dialog with options"
if( GetNBox(tr, "Using GetN Options", "This is a GetN dialog with options specified", NULL, NULL) )
{
out_tree(tr); // If user clicks OK to close dialog Output edited GetNBox tree
int iIndividualType = tr.Save.IndividualType.nVal;
int iIndividualSave = tr.Save.IndividualSave.nVal;
IndividualSavePath = tr.Save.IndividualPath.strVal;
int iMultipleType = tr.Save.MultipleType.nVal;
int iMultipleSave = tr.Save.MultipleSave.nVal;
int iNGpPSave = tr.Save.SaveGraphsPerPage.dVal;
MultipleSavePath = tr.Save.MultiplePath.strVal;
int iNGpPPrint = tr.Print.PrintGraphsPerPage.dVal;
string strIndividualType;
switch(iIndividualType)
{
case 0:
strIndividualType = "pdf"; break;
case 1:
strIndividualType = "wmf"; break;
}
string strMultipleType;
switch(iMultipleType)
{
case 0:
strMultipleType = "pdf"; break;
case 1:
strMultipleType = "wmf"; break;
}
LT_set_var("IndividualSave", iIndividualSave);
LT_set_str("%T", strIndividualType);
LT_execute("IndividualType$ = %T");
LT_set_str("%Z", IndividualSavePath);
LT_execute("IndividualGraphPath$ = %Z");
LT_set_var("MultipleSave", iMultipleSave);
LT_set_var("NGpPSave", iNGpPSave);
LT_set_str("%T", strMultipleType);
LT_execute("MultipleType$ = %T");
LT_set_str("%Z", MultipleSavePath);
LT_execute("MultipleGraphPath$ = %Z");
LT_set_var("NGpPPrint", iNGpPPrint);
return true;
}
out_tree(tr);
return false;
}
static bool PrintBranchEvent(TreeNode& tr, int nRow, int nCntrlType, Dialog& getNDlg)
{
out_str("OK");
return true;
}
// This function is executed when the browse button for the Path node is clicked
static bool InidividualOnClickButtonEvent(TreeNode& tr, int nRow, int nCntrlType, Dialog& getNDlg)
{
string strPath = tr.Save.IndividualPath.strVal;
if(!strPath.IsPath()) {
string strPath = GetAppPath(false);
}
string str = BrowseGetPath(strPath, "Select folder to save inidividual graphs");
if( !str.IsEmpty() )
{
tr.Save.IndividualPath.strVal = str;
return true;
}
else
return false;
}
// This function is executed when the browse button for the Path node is clicked
static bool MultipleOnClickButtonEvent(TreeNode& tr, int nRow, int nCntrlType, Dialog& getNDlg)
{
string strPath = tr.Save.MultiplePath.strVal;
if(!strPath.IsPath()) {
string strPath = GetAppPath(false);
}
string str = BrowseGetPath(strPath, "Select folder to save multiple graphs");
if( !str.IsEmpty() )
{
tr.Save.MultiplePath.strVal = str;
return true;
}
else
return false;
}
The dialog is of course launched by eg
if(SavePrint() == 1) {
run code...
}
Thanks!
Cheers,
Pete