Kommandozeilenparameter und Forms Anwendung



  • Hallo?

    Ist es möglich, Kommandozeilenparameter bei einer Forms Anwendung zu nutzen? Irgendwie finde ich nichts darüber. Danke!



  • In deiner "main" werden diese i.d.R. übergeben... bei mir sieht die "main" so aus:

    [STAThreadAttribute]
    int main(array<System::String ^> ^args)
    {
    	// Enabling Windows XP visual effects before any controls are created
    	Application::EnableVisualStyles();
    	Application::SetCompatibleTextRenderingDefault(false); 
    
    	// Create the main window and run it
    	Application::Run(gcnew Form1());
    	return 0;
    }
    

    Wenn Du nun die Argumente in Deinem "Form" brauchst, dann übergib sie einfach dem Konstruktor!
    =>

    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
      Form1(array<System::String ^> ^args)
      {
        // ...
      }
      // ...
    };
    

    und dann musst Du sie nur noch übergeben:

    [STAThreadAttribute]
    int main(array<System::String ^> ^args)
    {
    	// Enabling Windows XP visual effects before any controls are created
    	Application::EnableVisualStyles();
    	Application::SetCompatibleTextRenderingDefault(false); 
    
    	// Create the main window and run it
    	Application::Run(gcnew Form1(args));
    	return 0;
    }
    


  • Genau das brauche ich, vielen Dank!


Anmelden zum Antworten