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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Help (!) with loading dialog settings
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 04/07/2005 :  3:59:09 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR5
Operating System: Win2000

Hi,

Can anyone please help?

My attempt at code below is to read & save dialog settings from an xml file for a simple dialog. Try as I might I can't get to set the dialog controls from the xml file but can save the settings. All attempts result in 'calling unattacvhed wrapper class..' error. I must be missing a simple (important step).

Example code is :
/*------------------------------------------------------------------------------*
* File Name: *
* Creation: *
* Purpose: OriginC Source C file *
* Copyright (c) ABCD Corp. 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 *
* All Rights Reserved *
* *
* Modification Log: *
*------------------------------------------------------------------------------*/

////////////////////////////////////////////////////////////////////////////////////
// Including the system header file Origin.h should be sufficient for most Origin
// applications and is recommended. Origin.h includes many of the most common system
// header files and is automatically pre-compiled when Origin runs the first time.
// Programs including Origin.h subsequently compile much more quickly as long as
// the size and number of other included header files is minimized. All NAG header
// files are now included in Origin.h and no longer need be separately included.
//
// Right-click on the line below and select 'Open "Origin.h"' to open the Origin.h
// system header file.
#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////
#include <Dialog.h>

////////////////////////////////////////////////////////////////////////////////////
// Include your own header files here.
#include "LinearPlotRes.h" // resource DLL header


//////// ////////////////////////////////////////////////////////////////////////////
// Start your functions here.


class LINEARPLOT : public Dialog
{
public:
LINEARPLOT() : Dialog(IDD_LINEARPLOT, "LinearPlot")
{
}

int DoModal(HWND hParent = NULL)
{
InitMsgMap();// will be called from internal later
int nRet = Dialog::DoModal(hParent);
return nRet;
}

public:
///----------------- Message Map ----------------
EVENTS_BEGIN
ON_INIT(OnInitDialog)
ON_OK(OnOK)
ON_CANCEL(OnCancel)
EVENTS_END
///----------------------------------------------

BOOL OnInitDialog()
{
m_ebxXLABEL = GetItem(IDC_XLABEL);
m_ebxYLABEL1 = GetItem(IDC_YLABEL1);
m_ebxYLABEL2 = GetItem(IDC_YLABEL2);
m_ebxYLABEL3 = GetItem(IDC_YLABEL3);
m_ebxYLABEL4 = GetItem(IDC_YLABEL4);
m_ebxYLABEL5 = GetItem(IDC_YLABEL5);
m_ebxYLABEL6 = GetItem(IDC_YLABEL6);
m_ebxYLABEL7 = GetItem(IDC_YLABEL7);
m_ebxYLABEL8 = GetItem(IDC_YLABEL8);
m_ebxYLABEL9 = GetItem(IDC_YLABEL9);
m_ebxYLABEL10 = GetItem(IDC_YLABEL10);
m_ebxYLABEL11 = GetItem(IDC_YLABEL11);
m_ebxYLABEL12 = GetItem(IDC_YLABEL12);
m_ebxYLABEL13 = GetItem(IDC_YLABEL13);
m_ebxYLABEL14 = GetItem(IDC_YLABEL14);
m_ebxYLABEL15 = GetItem(IDC_YLABEL15);

m_btnREADYLABELS = GetItem(IDC_READYLABELS);
m_chkTHROUGHORIGIN = GetItem(IDC_THROUGHORIGIN);
m_chkSAMEGRADIENT = GetItem(IDC_SAMEGRADIENT);
m_chkSAMEINTERCEPT = GetItem(IDC_SAMEINTERCEPT);
m_chkDISPLAYGRADIENT = GetItem(IDC_DISPLAYGRADIENT);
m_chkDISPLAYINTERCEPT = GetItem(IDC_DISPLAYINTERCEPT);
m_chkDISPLAYR = GetItem(IDC_DISPLAYR);
m_chkDISPLAYSEGRADIENT = GetItem(IDC_DISPLAYSEGRADIENT);
m_chkDISPLAYSEINTERCEPT = GetItem(IDC_DISPLAYSEINTERCEPT);

m_rbXYYDATA = GetItem(IDC_XYYDATA);
m_rbXYXYDATA = GetItem(IDC_XYXYDATA);

// Need to initialise controls
m_ebxXLABEL.Text = "a";
m_ebxYLABEL1.Text = "a";
m_ebxYLABEL2.Text = "a";
m_ebxYLABEL3.Text = "a";
m_ebxYLABEL4.Text = "a";
m_ebxYLABEL5.Text = "a";
m_ebxYLABEL6.Text = "a";
m_ebxYLABEL7.Text = "a";
m_ebxYLABEL8.Text = "a";
m_ebxYLABEL9.Text = "a";
m_ebxYLABEL10.Text = "a";
m_ebxYLABEL11.Text = "a";
m_ebxYLABEL12.Text = "a";
m_ebxYLABEL13.Text = "a";
m_ebxYLABEL14.Text = "a";
m_ebxYLABEL15.Text = "a";

m_btnREADYLABELS.Check=1;
m_chkTHROUGHORIGIN.Check=1;
m_chkSAMEGRADIENT.Check=1;
m_chkSAMEINTERCEPT.Check=1;
m_chkDISPLAYGRADIENT.Check=1;
m_chkDISPLAYINTERCEPT.Check=1;
m_chkDISPLAYR.Check=1;
m_chkDISPLAYSEGRADIENT.Check=1;
m_chkDISPLAYSEINTERCEPT.Check=1;

m_rbXYYDATA.Check=1;
m_rbXYXYDATA.Check=0;

//if(SetData()) {
return TRUE;
//} else {
//return FALSE;
//}
}


BOOL SetData()
{

//m_ebxXLABEL.Text=trData.MainSheet.XLABEL.strVal;
m_ebxXLABEL.Text="pete";
return TRUE;

}


BOOL OnOK()
{

Tree trData;
TreeNode tnData;
tnData = trData.AddNode("MainSheet");
tnData.AddTextNode(m_ebxXLABEL.Text, "XLABEL");
tnData.AddTextNode(m_ebxYLABEL1.Text, "YLABEL1");
tnData.AddTextNode(m_ebxYLABEL2.Text, "YLABEL2");
tnData.AddTextNode(m_ebxYLABEL3.Text, "YLABEL3");
tnData.AddTextNode(m_ebxYLABEL4.Text, "YLABEL4");
tnData.AddTextNode(m_ebxYLABEL5.Text, "YLABEL5");
tnData.AddTextNode(m_ebxYLABEL6.Text, "YLABEL6");
tnData.AddTextNode(m_ebxYLABEL7.Text, "YLABEL7");
tnData.AddTextNode(m_ebxYLABEL8.Text, "YLABEL8");
tnData.AddTextNode(m_ebxYLABEL9.Text, "YLABEL9");
tnData.AddTextNode(m_ebxYLABEL10.Text, "YLABEL10");
tnData.AddTextNode(m_ebxYLABEL11.Text, "YLABEL11");
tnData.AddTextNode(m_ebxYLABEL12.Text, "YLABEL12");
tnData.AddTextNode(m_ebxYLABEL13.Text, "YLABEL13");
tnData.AddTextNode(m_ebxYLABEL14.Text, "YLABEL14");
tnData.AddTextNode(m_ebxYLABEL15.Text, "YLABEL15");

tnData.AddNumericNode(m_btnREADYLABELS.Check, "READYLABELS");
tnData.AddNumericNode(m_chkTHROUGHORIGIN.Check, "THROUGHORIGIN");
tnData.AddNumericNode(m_chkSAMEINTERCEPT.Check, "SAMEINTERCEPT");
tnData.AddNumericNode(m_chkDISPLAYGRADIENT.Check, "DISPLAYGRADIENT");
tnData.AddNumericNode(m_chkDISPLAYINTERCEPT.Check, "DISPLAYINTERCEPT");
tnData.AddNumericNode(m_chkDISPLAYR.Check, "DISPLAYR");
tnData.AddNumericNode(m_chkDISPLAYSEGRADIENT.Check, "DISPLAYSEGRADIENT");
tnData.AddNumericNode(m_chkDISPLAYSEINTERCEPT.Check, "DISPLAYSEINTERCEPT");
tnData.AddNumericNode(m_rbXYYDATA.Check, "XYYDATA");
tnData.AddNumericNode(m_rbXYXYDATA.Check, "XYXYDATA");

// Save settings
trData.Save("c:\pete\pete.XML");

// Set LabTalk Variables
LT_set_var("THROUGHORIGIN", tnData.THROUGHORIGIN.nVal);
LT_set_var("SAMEINTERCEPT", tnData.SAMEINTERCEPT.nVal);
LT_set_var("DISPLAYGRADIENT", tnData.DISPLAYGRADIENT.nVal);
LT_set_var("DISPLAYINTERCEPT", tnData.DISPLAYINTERCEPT.nVal);
LT_set_var("DISPLAYR", tnData.DISPLAYR.nVal);
LT_set_var("DISPLAYSEGRADIENT", tnData.DISPLAYSEGRADIENT.nVal);
LT_set_var("DISPLAYSEINTERCEPT", tnData.DISPLAYSEINTERCEPT.nVal);
LT_set_var("XYYDATA", tnData.XYYDATA.nVal);
LT_set_var("XYXYDATA", tnData.XYXYDATA.nVal);
LT_set_str("YLABEL1$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL2$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL3$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL4$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL5$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL6$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL7$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL8$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL9$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL10$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL11$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL12$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL13$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL14$", tnData.YLABEL1.strVal);
LT_set_str("YLABEL15$", tnData.YLABEL1.strVal);


return TRUE;

}

BOOL OnCancel()
{
return TRUE;
}


public:
Edit m_ebxXLABEL;
Edit m_ebxYLABEL1;
Edit m_ebxYLABEL2;
Edit m_ebxYLABEL3;
Edit m_ebxYLABEL4;
Edit m_ebxYLABEL5;
Edit m_ebxYLABEL6;
Edit m_ebxYLABEL7;
Edit m_ebxYLABEL8;
Edit m_ebxYLABEL9;
Edit m_ebxYLABEL10;
Edit m_ebxYLABEL11;
Edit m_ebxYLABEL12;
Edit m_ebxYLABEL13;
Edit m_ebxYLABEL14;
Edit m_ebxYLABEL15;

Button m_btnREADYLABELS;

Button m_chkTHROUGHORIGIN;
Button m_chkSAMEGRADIENT;
Button m_chkSAMEINTERCEPT;
Button m_chkDISPLAYGRADIENT;
Button m_chkDISPLAYINTERCEPT;
Button m_chkDISPLAYR;
Button m_chkDISPLAYSEGRADIENT;
Button m_chkDISPLAYSEINTERCEPT;

Button m_rbXYYDATA;
Button m_rbXYXYDATA;

Tree m_trData;
Tree m_tnData;

};


bool DoLINEARPLOT()
{
LINEARPLOT myDlg;

Tree trData;
TreeNode tnData;

int iret;

tnData = trData.AddNode("MainSheet");
tnData.AddTextNode("", "XLABEL");
tnData.AddTextNode("", "YLABEL1");
tnData.AddTextNode("", "YLABEL2");
tnData.AddTextNode("", "YLABEL3");
tnData.AddTextNode("", "YLABEL4");
tnData.AddTextNode("", "YLABEL5");
tnData.AddTextNode("", "YLABEL6");
tnData.AddTextNode("", "YLABEL7");
tnData.AddTextNode("", "YLABEL8");
tnData.AddTextNode("", "YLABEL9");
tnData.AddTextNode("", "YLABEL10");
tnData.AddTextNode("", "YLABEL11");
tnData.AddTextNode("", "YLABEL12");
tnData.AddTextNode("", "YLABEL13");
tnData.AddTextNode("", "YLABEL14");
tnData.AddTextNode("", "YLABEL15");

tnData.AddNumericNode(1, "READYLABELS");
tnData.AddNumericNode(1, "THROUGHORIGIN");
tnData.AddNumericNode(1, "SAMEINTERCEPT");
tnData.AddNumericNode(1, "DISPLAYGRADIENT");
tnData.AddNumericNode(1, "DISPLAYINTERCEPT");
tnData.AddNumericNode(1, "DISPLAYR");
tnData.AddNumericNode(1, "DISPLAYSEGRADIENT");
tnData.AddNumericNode(1, "DISPLAYSEINTERCEPT");
tnData.AddNumericNode(1, "XYYDATA");
tnData.AddNumericNode(1, "XYXYDATA");

//trData=CreateDialogTree();
out_tree(trData);
trData.Load("c:\pete\pete.XML");
out_tree(trData);
//if(myDlg.SetData()) {
//iret=1;
//} else {
//iret=0;
//};
myDlg.DoModal( GetWindow() );

return TRUE;


}


Tree CreateDialogTree()
{

Tree trData;
TreeNode tnData;
tnData = trData.AddNode("MainSheet");
tnData.AddTextNode("", "XLABEL");
tnData.AddTextNode("", "YLABEL1");
tnData.AddTextNode("", "YLABEL2");
tnData.AddTextNode("", "YLABEL3");
tnData.AddTextNode("", "YLABEL4");
tnData.AddTextNode("", "YLABEL5");
tnData.AddTextNode("", "YLABEL6");
tnData.AddTextNode("", "YLABEL7");
tnData.AddTextNode("", "YLABEL8");
tnData.AddTextNode("", "YLABEL9");
tnData.AddTextNode("", "YLABEL10");
tnData.AddTextNode("", "YLABEL11");
tnData.AddTextNode("", "YLABEL12");
tnData.AddTextNode("", "YLABEL13");
tnData.AddTextNode("", "YLABEL14");
tnData.AddTextNode("", "YLABEL15");

tnData.AddNumericNode(1, "READYLABELS");
tnData.AddNumericNode(1, "THROUGHORIGIN");
tnData.AddNumericNode(1, "SAMEINTERCEPT");
tnData.AddNumericNode(1, "DISPLAYGRADIENT");
tnData.AddNumericNode(1, "DISPLAYINTERCEPT");
tnData.AddNumericNode(1, "DISPLAYR");
tnData.AddNumericNode(1, "DISPLAYSEGRADIENT");
tnData.AddNumericNode(1, "DISPLAYSEINTERCEPT");
tnData.AddNumericNode(1, "XYYDATA");
tnData.AddNumericNode(1, "XYXYDATA");

return trData;

}


Thanks in advance. (I know CreateDialogTree isn't used).

Cheers,

Pete

cpyang

USA
1406 Posts

Posted - 04/07/2005 :  11:24:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is an outline of what you should do,

 

class LINEARPLOT : public Dialog
{
public:
LINEARPLOT() : Dialog(IDD_LINEARPLOT, "LinearPlot")
{
}
int DoModal(HWND hParent = NULL)
{
InitMsgMap();// will be called from internal later
int nRet = Dialog::DoModal(hParent);
return nRet;
}
public:
///----------------- Message Map ----------------
EVENTS_BEGIN
ON_INIT(OnInitDialog)
ON_OK(OnOK)
ON_CANCEL(OnCancel)
EVENTS_END
///----------------------------------------------

BOOL OnInitDialog()
{
m_ebxXLABEL = GetItem(IDC_XLABEL);

SetData();
}

BOOL SetData()
{
if(m_trData.Load("c:\\pete\\pete.XML"))
{
if(m_trData.MainSheet) // to ensure that we have the right tree
{
m_ebxXLABEL.Text = m_trData.MainSheet.XLABEL.strVal;
// other controls

return true;
}
}
return false;
}


BOOL OnOK()
{
// tree nodes are automatically created when making assignment
m_trData.MainSheet.XLABEL.strVal = m_ebxXLABEL.Text;
m_trData.MainSheet.YLABEL1.strVal = m_ebxYLABEL1.Text;
// other controls

// Save settings
m_trData.Save("c:\\pete\\pete.XML");

return TRUE;
}

public:
Edit m_ebxXLABEL;
Edit m_ebxYLABEL1;

Tree m_trData;
};

bool DoLINEARPLOT()
{
// tree should be read in OnInitDialog
myDlg.DoModal( GetWindow() );
return TRUE;

}




Go to Top of Page

peter.cook

UK
356 Posts

Posted - 04/08/2005 :  10:18:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi CP,

At last! Thanks for the prompt assistance - I now have a compete OC dialog saving & retrieving settings.

Cheers,

pete

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000