The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 GETN Dialog Focus

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
peter.cook Posted - 08/19/2010 : 08:17:58 AM
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
4   L A T E S T    R E P L I E S    (Newest First)
jingting Posted - 08/25/2010 : 8:50:46 PM
您好皮特

对于第一个问题:
我希望我没有误解你。在运行你的代码, GetN对话总是集中在创建时,而不是其他层。要检查或取消选中一个复选框的“矩形“ ,我只需点击一次。所以,请你提供更多的步骤细节如何重现这个问题?

对于第二个问题:
目前,还没有这样的事件处理程序你提到的崩溃和扩大分支机构。

佩恩
Penn Posted - 08/20/2010 : 04:56:38 AM
Hi Pete,

1st issue:
This problem is weird, because when the GetN dialog is open, other windows (such as graph, sheet, etc) can not be focused any more. So, only the GetN dialog is focused. It is better that you can provide the code before creating the dialog.

2nd issue:
It can not be done currently. However, with the current version (Origin 8.1), you can use the GETN_CHECKBOX_BRANCH as a trick. Also refer to this example for details on event handler function.

You can get a demo version to have a try.

Penn
peter.cook Posted - 08/20/2010 : 03:20:12 AM
Hi Penn,

Thanks for reply.

1st Issue : the GetNDialog is NOT in focus. If for example I have a multi-layer page and I click on a checkbox then the layer corresponding to the position of the checkbox is activated. I have to click again to 'tick' the checkbox. Thereafter the GetNDialog is in focus. Having looked at this again : if I run SaveAndPrint in the script window then the GetNDialog is in focus straightaway. What I actually have though is a button which runs more code before creating the dialog. Apologies as I'm now not sure where the problem is but any advice on how to try and get (ensure) the dialog into focus would be good..

2nd issue : OK. Is there any way then of just detecting via code if the branch is collapsed or expanded.

Thanks,

Cheers,

Pete
Penn Posted - 08/19/2010 : 10:31:04 PM
Hi Pete,

For the first issue:
I hope that I am not misunderstand you. After running your code, the GetN dialog is always focused when it is created, but not other layers. To check or uncheck a check-box, I just click once on the "rectangle". So, could you please provide more step details on how to reproduce this problem?

For the second issue:
Currently, there is no such a event handler as you mentioned for collapsing and expanding branches.

Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000