Passing Arguments
-
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
-
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
Just pass a FT_DISPLAY_EACH_PARAMETER_IN_ITS_OWN_BOX flag to CFormView::DoWhatIMean. Tomasz Sowinski -- http://www.shooltz.com
-
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
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
-
Just pass a FT_DISPLAY_EACH_PARAMETER_IN_ITS_OWN_BOX flag to CFormView::DoWhatIMean. Tomasz Sowinski -- http://www.shooltz.com
:-D Actually, he first needs to call CCodeProject::PostProgrammingQuestionsInTheProgrammingForums. Then he should be OK. Regards, Alvaro
-
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
You can use these ( instead of using GetCmdLine ) __argc for argument count (DWORD) __argv for arguments (TCHAR**) Zolee
-
You can use these ( instead of using GetCmdLine ) __argc for argument count (DWORD) __argv for arguments (TCHAR**) Zolee
-
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. ;)
They paste them all together for us to peel back apart. Who told you that? Tomasz Sowinski -- http://www.shooltz.com
-
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
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.
-
They paste them all together for us to peel back apart. Who told you that? Tomasz Sowinski -- http://www.shooltz.com
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. :)