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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. Passing Arguments

Passing Arguments

Scheduled Pinned Locked Moved The Lounge
c++tutorialhelpquestion
9 Posts 7 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.
  • L Offline
    L Offline
    luke_ratliff
    wrote on last edited by
    #1

    I have been trying to create a CFormView (via Visual C++ 6 AppWizard) that will receive 6 parameter by way of the command line. I want to display each parameter in its own edit box. I have tried several different method of accessing the command line but most give some type of compile error (undefined, etc.). Does anyone have an example and explanation as to how to do this?:confused: Luke Ratliff

    T N Z C 4 Replies Last reply
    0
    • L luke_ratliff

      I have been trying to create a CFormView (via Visual C++ 6 AppWizard) that will receive 6 parameter by way of the command line. I want to display each parameter in its own edit box. I have tried several different method of accessing the command line but most give some type of compile error (undefined, etc.). Does anyone have an example and explanation as to how to do this?:confused: Luke Ratliff

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Just pass a FT_DISPLAY_EACH_PARAMETER_IN_ITS_OWN_BOX flag to CFormView::DoWhatIMean. Tomasz Sowinski -- http://www.shooltz.com

      A 1 Reply Last reply
      0
      • L luke_ratliff

        I have been trying to create a CFormView (via Visual C++ 6 AppWizard) that will receive 6 parameter by way of the command line. I want to display each parameter in its own edit box. I have tried several different method of accessing the command line but most give some type of compile error (undefined, etc.). Does anyone have an example and explanation as to how to do this?:confused: Luke Ratliff

        N Offline
        N Offline
        NormDroid
        wrote on last edited by
        #3

        Right, use the Visual C++ forum but... m_lpCmdLine contains parameters, you need to *do* some programming to walk along the parameters (strtok) and extract out the params maybe in CStringList (for simplist sake). Next Many ways to do this, here's one thats cheap and cheerful way of doing doing this: (Time permitted) Before InitInstance returns TRUE; CMainFrame* pFrame = static_cast(m_pMainWnd); CMyFormView* pView = static_cast(GetActiveView()); pView->SetEditParams(slStringList); and in void CMyFormView::SetEditParams(const CStringList& slStringList) { // I assume you've know the dialog ID's // or DDX'd the controls? POSITION pos = slStringList.GetHeadPostion(); int nIndex = 0; while (pos) { switch (nIndex) { CString str = slStringList.GetNext(pos); case 0: // Param 1 SetWindowText(str); break; // etc. etc. case 1: // Param 2 break; } } Personal preference I'd do this when OnInitUpdate gets called in the form view and get a pointer back from CWinApp also I'd use parse the objects without creating a list. } } Norm Almond Chief Technical Architect FS Walker Hughes Limited

        1 Reply Last reply
        0
        • T Tomasz Sowinski

          Just pass a FT_DISPLAY_EACH_PARAMETER_IN_ITS_OWN_BOX flag to CFormView::DoWhatIMean. Tomasz Sowinski -- http://www.shooltz.com

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #4

          :-D Actually, he first needs to call CCodeProject::PostProgrammingQuestionsInTheProgrammingForums. Then he should be OK. Regards, Alvaro

          1 Reply Last reply
          0
          • L luke_ratliff

            I have been trying to create a CFormView (via Visual C++ 6 AppWizard) that will receive 6 parameter by way of the command line. I want to display each parameter in its own edit box. I have tried several different method of accessing the command line but most give some type of compile error (undefined, etc.). Does anyone have an example and explanation as to how to do this?:confused: Luke Ratliff

            Z Offline
            Z Offline
            Zoltan Csizmadia
            wrote on last edited by
            #5

            You can use these ( instead of using GetCmdLine ) __argc for argument count (DWORD) __argv for arguments (TCHAR**) Zolee

            R 1 Reply Last reply
            0
            • Z Zoltan Csizmadia

              You can use these ( instead of using GetCmdLine ) __argc for argument count (DWORD) __argv for arguments (TCHAR**) Zolee

              R Offline
              R Offline
              Rick York
              wrote on last edited by
              #6

              I believe these are declared in stdlib.h. What is somewhat amusing is that MFC uses these to build a string that GetCmdLine accesses. They paste them all together for us to peel back apart. ;)

              T 1 Reply Last reply
              0
              • R Rick York

                I believe these are declared in stdlib.h. What is somewhat amusing is that MFC uses these to build a string that GetCmdLine accesses. They paste them all together for us to peel back apart. ;)

                T Offline
                T Offline
                Tomasz Sowinski
                wrote on last edited by
                #7

                They paste them all together for us to peel back apart. Who told you that? Tomasz Sowinski -- http://www.shooltz.com

                R 1 Reply Last reply
                0
                • L luke_ratliff

                  I have been trying to create a CFormView (via Visual C++ 6 AppWizard) that will receive 6 parameter by way of the command line. I want to display each parameter in its own edit box. I have tried several different method of accessing the command line but most give some type of compile error (undefined, etc.). Does anyone have an example and explanation as to how to do this?:confused: Luke Ratliff

                  C Offline
                  C Offline
                  Carlos Antollini
                  wrote on last edited by
                  #8

                  If you need to get the command line parameters use my class. CCommandLine. It is easy to use Cheers!!! Please post your question in the question forum. Best Regards Me:-D Carlos Antollini.

                  1 Reply Last reply
                  0
                  • T Tomasz Sowinski

                    They paste them all together for us to peel back apart. Who told you that? Tomasz Sowinski -- http://www.shooltz.com

                    R Offline
                    R Offline
                    Rick York
                    wrote on last edited by
                    #9

                    Oops, I have this backwards. I had a recollection of looking at the MFC source and seeing a CString of the command args built up that was later parsed by ParseCommandLine. I just looked again and MFC accesses __targv to get the command line args in appcore.cpp. It is windoze that internally builds a command line and passes it to WinMain. Sorry about that. How embarrassing. :)

                    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