如何使用参数?
我在 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;
}
和 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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过调用 string 数组rel="nofollow noreferrer">
Environment::GetCommandLineArgs
。You can get a
string
array containing the command-line arguments by callingEnvironment::GetCommandLineArgs
.