开发者

How to use arguments?

I have two file generated in visual studio c++ 2010 express.

test2.cpp

// test2.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace test2;

[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;
}

and Form1.h

#pragma once

namespace test2 {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
    Form1(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::WebBrowser^  webBrowser1;
public: System::Windows::Forms::Timer^  timer1;
private: 

private: System::ComponentModel::IContainer^  components;
protected: 

private:
    /// <summary>
    /// Required designer variable.
    /// </summary>


#pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
  开发者_开发问答  {
        this->components = (gcnew System::ComponentModel::Container());
        this->webBrowser1 = (gcnew System::Windows::Forms::WebBrowser());
        this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
        this->SuspendLayout();
        // 
        // webBrowser1
        // 
        this->webBrowser1->Dock = System::Windows::Forms::DockStyle::Fill;
        this->webBrowser1->IsWebBrowserContextMenuEnabled = false;
        this->webBrowser1->Location = System::Drawing::Point(0, 0);
        this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20);
        this->webBrowser1->Name = L"webBrowser1";
        this->webBrowser1->ScrollBarsEnabled = false;
        this->webBrowser1->Size = System::Drawing::Size(284, 262);
        this->webBrowser1->TabIndex = 0;
        this->webBrowser1->Url = (gcnew System::Uri(L"http://wp.pl", System::UriKind::Absolute));
        this->webBrowser1->DocumentCompleted += gcnew System::Windows::Forms::WebBrowserDocumentCompletedEventHandler(this, &Form1::webBrowser1_DocumentCompleted);
        // 
        // timer1
        // 
        this->timer1->Enabled = true;
        this->timer1->Interval = 10000;
        this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
        // 
        // Form1
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(284, 262);
        this->Controls->Add(this->webBrowser1);
        this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
        this->Name = L"Form1";
        this->ResumeLayout(false);

    }
#pragma endregion
private: System::Void webBrowser1_DocumentCompleted(System::Object^  sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^  e) {
         }
public: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
            Application::Exit();
         }
};
}

How to using argument from command prompt? For example how change

this->timer1->Interval = 10000;

on user var? Something like

this->timer1->Interval = time;


You can get a string array containing the command-line arguments by calling Environment::GetCommandLineArgs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜