我在visual studio c ++ 2010 express中生成了两个文件。
测试2.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;
}
和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();
}
};
}
如何在命令提示符下使用参数?例如如何改变
this->timer1->Interval = 10000;
用户var?像
这样的东西this->timer1->Interval = time;