|
-
September 8th, 2011, 04:22 AM
#1
is it different to put the function in different place?
Hi all ,
I have written a program ,I want to realize the two different functions in respective Menu lists in MFC.one menu is "Init" to initiate the instrument ,the other is "zernike" to calculate something .
there is nothing wrong after compiling , but the result is different when I put the code in the two menu response functions. in fact if I put them in either "oninit()"or "onzernike()", I can get the result I want , but then the two different functions mixed together.if I put the corresponding part of the code in each responding function . nothing is wrong with compiling. but the result is strange when execute .
part of the code:
Code:
void CTest1View::OnInit()
{
.....
if(err = WFS_GetMlaCount (instr.handle, &instr.mla_cnt))
handle_errors(err);
....
}
void CTest1View::OnZernike()
{
......
if(err = WFS_CalcBeamCentroidDia (instr.handle, &beam_centroid_x))
handle_errors(err);
......
}
in the above code, instr is an object of a class I defined to put some variables. I define the object in C**view,public, why the result is different when the code is like this:
Code:
void CTest1View::OnInit()
{
.....
if(err = WFS_GetMlaCount (instr.handle, &instr.mla_cnt))
handle_errors(err);
....
if(err = WFS_CalcBeamCentroidDia (instr.handle, &beam_centroid_x))
handle_errors(err);
......
}
Last edited by Angela2010; September 8th, 2011 at 08:02 AM.
-
September 8th, 2011, 07:05 AM
#2
Re: is it different to put the function in different place?
1. Closing tags use slash, not a backslash. So, please, edit your OP.
2. Where and how did you define the instr object?
3. What are all the other parameters you are passing in the WFS_CalcBeamCentroidDia and WFS_GetMlaCount functions?
4. What and how these WFS_CalcBeamCentroidDia and WFS_GetMlaCount functions do?
Victor Nijegorodov
-
September 8th, 2011, 08:17 AM
#3
Re: is it different to put the function in different place?
Hi VictorN,
1、I define the instr object in the header file of CTestView,
mla_cnt、handle ...these variables are defined in the CVariable class, and are initiated in the constructor function.
2、other parameters such as beam_centroid_x is directly defined in the function of "oninit() "or "onzernike()"
3、instr.handle represents the ID of the instrument I am to detect. &instr.mla_cnt, &beam_centroid_x are the output of the WFS_GetMlaCount() and WFS_CalcBeamCentroidDia ()
where instr.handle is the output in the first function and is the input of the second function.
is there something wrong with the CVarialbe class I defined ? instr is defined in CTestView , I think the value of instr.handle can be used in the second function.
or is there something wrong when I define the instr object in the CTestView but I initiate the variables in the class constructor function of CVariable;
Regards
-
September 8th, 2011, 08:23 AM
#4
Re: is it different to put the function in different place?
 Originally Posted by Angela2010
Hi VictorN,
1、I define the instr object in the header file of CTestView,
But you are using it in the CTest1View class?
 Originally Posted by Angela2010
...
part of the code:
Code:
void CTest1View::OnInit()
{
.....
if(err = WFS_GetMlaCount (instr.handle, &instr.mla_cnt))
handle_errors(err);
....
}
Victor Nijegorodov
-
September 8th, 2011, 09:11 AM
#5
Re: is it different to put the function in different place?
sorry ,I have a typo. It is CTest1View, but this is not the problem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|