CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2011
    Posts
    21

    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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    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

  3. #3
    Join Date
    Aug 2011
    Posts
    21

    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,
    Code:
                              CVariable instr
    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

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: is it different to put the function in different place?

    Quote Originally Posted by Angela2010 View Post
    Hi VictorN,
    1、I define the instr object in the header file of CTestView,
    Code:
                              CVariable instr
    But you are using it in the CTest1View class?
    Quote Originally Posted by Angela2010 View Post
    ...
    part of the code:
    Code:
    void CTest1View::OnInit() 
    {
       .....
       if(err = WFS_GetMlaCount (instr.handle, &instr.mla_cnt))
    		handle_errors(err);
      ....
    }
    Victor Nijegorodov

  5. #5
    Join Date
    Aug 2011
    Posts
    21

    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
  •  





Click Here to Expand Forum to Full Width

Featured