Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. about parameter passing

about parameter passing

Scheduled Pinned Locked Moved C / C++ / MFC
c++comhelptutorialquestion
15 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    savitri
    wrote on last edited by
    #1

    Hi everyone, Please Help me that how to pass the parameters to the activex controls.Please tell me. i am writing one OCX file.in that file i am doing read and write functions. and in another project i am using that OCX.When i am passing parameters to that function then that time values taking as null.in runtime when i given some values to that parameters that time also they are takingas null only.in VC++ how can i pass the parameters by refence please. In OCX file write function is READBLK(LPCTSTR MemId, LPCTSTR MemName, LPCTSTR eDate, LPCTSTR Balance, LPCTSTR TagId); and in my main project write block is like this: OCX.READBLK(MemId,Memname,Date,Balance,Tagig) {m_MemId=MemId;}like this i am assigning the value. these MemId,Memname,Date,Balance and Tagid are of type CString after writing the data in the card.after writing i want read that data from the card but the data is not printing on the form or not returning to my project from OCX file. Please Help me i am in tension. THANKU IN ADVANCE, savitriX|

    C D 2 Replies Last reply
    0
    • S savitri

      Hi everyone, Please Help me that how to pass the parameters to the activex controls.Please tell me. i am writing one OCX file.in that file i am doing read and write functions. and in another project i am using that OCX.When i am passing parameters to that function then that time values taking as null.in runtime when i given some values to that parameters that time also they are takingas null only.in VC++ how can i pass the parameters by refence please. In OCX file write function is READBLK(LPCTSTR MemId, LPCTSTR MemName, LPCTSTR eDate, LPCTSTR Balance, LPCTSTR TagId); and in my main project write block is like this: OCX.READBLK(MemId,Memname,Date,Balance,Tagig) {m_MemId=MemId;}like this i am assigning the value. these MemId,Memname,Date,Balance and Tagid are of type CString after writing the data in the card.after writing i want read that data from the card but the data is not printing on the form or not returning to my project from OCX file. Please Help me i am in tension. THANKU IN ADVANCE, savitriX|

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      You post is not clear. Please explain you problem neatly and elaborate whenever necessary. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      S 1 Reply Last reply
      0
      • C CPallini

        You post is not clear. Please explain you problem neatly and elaborate whenever necessary. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        S Offline
        S Offline
        savitri
        wrote on last edited by
        #3

        ok i will explain. i am creating one ACtiveX control called ACRRW. in that ACTiveX control i am writing methods called ReadBlk() and WriteBlk(). ReadBlk(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and Write(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and i am using this ACtiveX Control in my another project called ACRReadWrite Automation Project. in this project i am creating m_ACRRW variable as ActiveX control. in my i am putting two buttons called Read and Write.in this Read and Write button functions i am calling the functions those are already present in ACtiveX Control. m_ACRRW.ReadBlk(MemId,MemName,eDate,Balance,TagId); MemId,MemName,eDate,Balance and TagId are of type CString. m_ACRRW.WriteBlk(m_MemId,m_MemName,m_eDate,m_Balance,m_TagId); m_MemId...m_TagId are of type CString. i am facing problem in Read Block that is my values are written in card but after reading those data they are not printing on the screen. i thought that i did mistake in passing parameters.PLEASE HELP ME OUT. give me some solution. THANKU IN ADVANCE, savitri :doh:

        C 1 Reply Last reply
        0
        • S savitri

          ok i will explain. i am creating one ACtiveX control called ACRRW. in that ACTiveX control i am writing methods called ReadBlk() and WriteBlk(). ReadBlk(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and Write(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and i am using this ACtiveX Control in my another project called ACRReadWrite Automation Project. in this project i am creating m_ACRRW variable as ActiveX control. in my i am putting two buttons called Read and Write.in this Read and Write button functions i am calling the functions those are already present in ACtiveX Control. m_ACRRW.ReadBlk(MemId,MemName,eDate,Balance,TagId); MemId,MemName,eDate,Balance and TagId are of type CString. m_ACRRW.WriteBlk(m_MemId,m_MemName,m_eDate,m_Balance,m_TagId); m_MemId...m_TagId are of type CString. i am facing problem in Read Block that is my values are written in card but after reading those data they are not printing on the screen. i thought that i did mistake in passing parameters.PLEASE HELP ME OUT. give me some solution. THANKU IN ADVANCE, savitri :doh:

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Hence WriteBlk works fine while ReadBlk not. Could you post ReadBlk relevant code?

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          S 1 Reply Last reply
          0
          • C CPallini

            Hence WriteBlk works fine while ReadBlk not. Could you post ReadBlk relevant code?

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            S Offline
            S Offline
            savitri
            wrote on last edited by
            #5

            [Message Deleted]

            D C 2 Replies Last reply
            0
            • S savitri

              [Message Deleted]

              D Offline
              D Offline
              Demian Panello
              wrote on last edited by
              #6

              Did you try to debug the OCX project putting a breakpoint in the ReadBlk and see what is happening?

              Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

              S 1 Reply Last reply
              0
              • D Demian Panello

                Did you try to debug the OCX project putting a breakpoint in the ReadBlk and see what is happening?

                Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

                S Offline
                S Offline
                savitri
                wrote on last edited by
                #7

                Ya i tried the control is passing from project to ocx nad vice versa but the problemis that the data is not coming back to my project and not printing on the screen. please give some solution. Thanku in advance, savitri:confused:

                1 Reply Last reply
                0
                • S savitri

                  [Message Deleted]

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #8

                  The problem is in your approach on passing strings that actually are OUT parameters. As simple solution you may mimic WIN32 API GetWindowText behaviour, i.e. for each string that must be filled by the ActiveX control, pass the pointer of a buffer (allocated by the client) and the buffer size to the control. A simple example: ActiveX code

                  BOOL ReadBlk(LPSTR MemId, LONG MemIdSize)
                  {
                  if ( !MemId || MemIdSize < 1)
                  return FALSE;

                  strncpy(MemId, "Hello Client!", MemIdSize-1);
                  MemId[MemIdSize-1]='\0';
                  return true;
                  }

                  Client code

                  const int SIZE=0x100;
                  CHAR MemId[SIZE];
                  m_ActiveX.ReadBlk((LPSTR) MemId, SIZE);

                  :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                  1 Reply Last reply
                  0
                  • S savitri

                    Hi everyone, Please Help me that how to pass the parameters to the activex controls.Please tell me. i am writing one OCX file.in that file i am doing read and write functions. and in another project i am using that OCX.When i am passing parameters to that function then that time values taking as null.in runtime when i given some values to that parameters that time also they are takingas null only.in VC++ how can i pass the parameters by refence please. In OCX file write function is READBLK(LPCTSTR MemId, LPCTSTR MemName, LPCTSTR eDate, LPCTSTR Balance, LPCTSTR TagId); and in my main project write block is like this: OCX.READBLK(MemId,Memname,Date,Balance,Tagig) {m_MemId=MemId;}like this i am assigning the value. these MemId,Memname,Date,Balance and Tagid are of type CString after writing the data in the card.after writing i want read that data from the card but the data is not printing on the form or not returning to my project from OCX file. Please Help me i am in tension. THANKU IN ADVANCE, savitriX|

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    savitri wrote:

                    ...or not returning to my project from OCX file.

                    Exactly how are you expecting this to happen? You effectively have the following:

                    BOOL CACR120RWCtrl::ReadBlk( LPCTSTR MemId )
                    {
                    CString dStr;
                    ...
                    MemId = dStr;
                    }

                    In this context, the MemId can be changed to point to something else, but only within ReadBlk(). Once ReadBlk() goes out of scope, MemId goes back to pointing to whatever it pointed to before ReadBlk() was called. If you want MemId to point elsewhere, you'll likely need to change the parameters to char ** instead. You can also change it to a char * and use strcpy() to change its contents.

                    "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    C S 2 Replies Last reply
                    0
                    • D David Crow

                      savitri wrote:

                      ...or not returning to my project from OCX file.

                      Exactly how are you expecting this to happen? You effectively have the following:

                      BOOL CACR120RWCtrl::ReadBlk( LPCTSTR MemId )
                      {
                      CString dStr;
                      ...
                      MemId = dStr;
                      }

                      In this context, the MemId can be changed to point to something else, but only within ReadBlk(). Once ReadBlk() goes out of scope, MemId goes back to pointing to whatever it pointed to before ReadBlk() was called. If you want MemId to point elsewhere, you'll likely need to change the parameters to char ** instead. You can also change it to a char * and use strcpy() to change its contents.

                      "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #10

                      Of course you are right. However I don't think passing a char ** will be the best approach there. Probably passing an allocated buffer (like GetWindowText behaviour) will be better. I know it's a matter of taste but whenever the OP isn't an expert I'm afraid of suggesting the "server-memory-allocation, client-memory-deallocation" approach. :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                      D 1 Reply Last reply
                      0
                      • C CPallini

                        Of course you are right. However I don't think passing a char ** will be the best approach there. Probably passing an allocated buffer (like GetWindowText behaviour) will be better. I know it's a matter of taste but whenever the OP isn't an expert I'm afraid of suggesting the "server-memory-allocation, client-memory-deallocation" approach. :)

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        CPallini wrote:

                        However I don't think passing a char ** will be the best approach there.

                        I never said it was. It was merely a suggestion for the OP to explore.

                        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        1 Reply Last reply
                        0
                        • D David Crow

                          savitri wrote:

                          ...or not returning to my project from OCX file.

                          Exactly how are you expecting this to happen? You effectively have the following:

                          BOOL CACR120RWCtrl::ReadBlk( LPCTSTR MemId )
                          {
                          CString dStr;
                          ...
                          MemId = dStr;
                          }

                          In this context, the MemId can be changed to point to something else, but only within ReadBlk(). Once ReadBlk() goes out of scope, MemId goes back to pointing to whatever it pointed to before ReadBlk() was called. If you want MemId to point elsewhere, you'll likely need to change the parameters to char ** instead. You can also change it to a char * and use strcpy() to change its contents.

                          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                          S Offline
                          S Offline
                          savitri
                          wrote on last edited by
                          #12

                          hi DavidCrow, I modified Cstring to char** but the control is not passing.i modified in OCX project.but i am not getting anything.please tell me how can i do it. PLEASE HELP ME.I am TRYING MY LEVEL BEST BUT I AM FED UP.PLEASE HELP ME. I AM VERY THANK FUL TO U ALL.REALLY I LEARNED SO MUCH BUT I AM NOT GETTING ONLY THIS OUTPUT.i am having data in OCX but it is not returning to my project.PLEASE...... THANKU, savitri :rolleyes:

                          D 1 Reply Last reply
                          0
                          • S savitri

                            hi DavidCrow, I modified Cstring to char** but the control is not passing.i modified in OCX project.but i am not getting anything.please tell me how can i do it. PLEASE HELP ME.I am TRYING MY LEVEL BEST BUT I AM FED UP.PLEASE HELP ME. I AM VERY THANK FUL TO U ALL.REALLY I LEARNED SO MUCH BUT I AM NOT GETTING ONLY THIS OUTPUT.i am having data in OCX but it is not returning to my project.PLEASE...... THANKU, savitri :rolleyes:

                            D Offline
                            D Offline
                            David Crow
                            wrote on last edited by
                            #13

                            savitri wrote:

                            I modified Cstring to char**...

                            Why?

                            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                            S 1 Reply Last reply
                            0
                            • D David Crow

                              savitri wrote:

                              I modified Cstring to char**...

                              Why?

                              "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                              S Offline
                              S Offline
                              savitri
                              wrote on last edited by
                              #14

                              u only mentioned that if it is Cstring then data will pass to the parameters so i did like this.in ocx or in my project shall i change that data. REPLY ME AS SOON AS POSSIBLE: Thakns in advance, savitri,:confused:

                              D 1 Reply Last reply
                              0
                              • S savitri

                                u only mentioned that if it is Cstring then data will pass to the parameters so i did like this.in ocx or in my project shall i change that data. REPLY ME AS SOON AS POSSIBLE: Thakns in advance, savitri,:confused:

                                D Offline
                                D Offline
                                David Crow
                                wrote on last edited by
                                #15

                                savitri wrote:

                                u only mentioned that if it is Cstring then data will pass to the parameters...

                                This makes no sense. Go back and read this thread again, and then reply with a bit more coherency.

                                "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups