返回信息流刚刚照书上的示例,敲了一段 在CLR中创建windows窗口程序 代码,但不知道为什么不能运行,百度也无果····求大神帮忙看一下,
关键是不知道MyForm.cpp里面写什么
//MyForm.cpp
#include "MyForm.h"
//MyForm.h
#pragma once
namespace Project6 {
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>
/// MyForm 摘要
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: 在此处添加构造函数代码
//
}
protected:
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::DateTimePicker^ dateTimePicker1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::MonthCalendar^ monthCalendar1;
protected:
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());
this->label1 = (gcnew System::Windows::Forms::Label());
this->monthCalendar1 = (gcnew System::Windows::Forms::MonthCalendar());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(97, 36);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"OK ";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// dateTimePicker1
//
this->dateTimePicker1->Location = System::Drawing::Point(84, 3);
this->dateTimePicker1->Name = L"dateTimePicker1";
this->dateTimePicker1->Size = System::Drawing::Size(200, 21);
this->dateTimePicker1->TabIndex = 1;
this->dateTimePicker1->ValueChanged += gcnew System::EventHandler(this, &MyForm::dateTimePicker1_ValueChanged);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(9, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(71, 12);
this->label1->TabIndex = 2;
this->label1->Text = L"Choose Date";
//
// monthCalendar1
//
this->monthCalendar1->Location = System::Drawing::Point(29, 65);
this->monthCalendar1->Name = L"monthCalendar1";
this->monthCalendar1->TabIndex = 3;
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 261);
this->Controls->Add(this->monthCalendar1);
this->Controls->Add(this->label1);
this->Controls->Add(this->dateTimePicker1);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"Date";
this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Application::Exit();
}
private: System::Void dateTimePicker1_ValueChanged(System::Object^ sender, System::EventArgs^ e) {
label1->Text = String::Format("New date:{0}", dateTimePicker1->Text);
}
};
}
这是一条镜像帖。来源:北邮人论坛 / cpp / #77239同步于 2014/3/1
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
关于VS在CLR中创建windows窗口程序
heamon7
2014/3/1镜像同步18 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
缺少CLR风格入口:
// AppEntry.cpp
#include "stdafx.h"
#include "MyForm.h"
using namespace Project6;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew MyForm());
return 0;
}
【 在 heamon7 的大作中提到: 】
: 刚刚照书上的示例,敲了一段 在CLR中创建windows窗口程序 代码,但不知道为什么不能运行,百度也无果····求大神帮忙看一下,
: 关键是不知道MyForm.cpp里面写什么
: //MyForm.cpp
: ...................
【 在 tonyjansan 的大作中提到: 】
: 缺少CLR风格入口:
: // AppEntry.cpp
: #include "stdafx.h"
: ...................
恩,试试,谢啦
【 在 heamon7 的大作中提到: 】
: 恩,也想学C#,但想先学好C++,接触一点C#,然后再深入了解
Managed C++和标准的C++很不一样。如果真的想学C++(虽然我一点也不喜欢C++),可以跟着www.cplusplus.com的tutorial学学(不很深入但很简明)。
如果要学C#倒是比较好入手,既然你已经有VS了。
【 在 nuanyangyang 的大作中提到: 】
:
: Managed C++和标准的C++很不一样。如果真的想学C++(虽然我一点也不喜欢C++),可以跟着www.cplusplus.com的tutorial学学(不很深入但很简明)。
: 如果要学C#倒是比较好入手,既然你已经有VS了。
恩,一方面我们课现在上的是C++,另一方面我们以后的要求也是C++,
而且听说C#和Java很像,我现在也在学Java,所以在权衡之中还是
先选择C++,这样以后再学C#也比较容易,不过现在好多的VS的教程都是C#的,C++的比较少
这倒有点麻烦,
所以是想C#也不丢,只是现在不当主要的,带着学
你说的这个网站倒真不错,学英语很好的,要是有点Video就好,
如果学C#的话,有什么类似的网站吗?
谢了啊[ema25]
【 在 heamon7 的大作中提到: 】
: 恩,一方面我们课现在上的是C++,另一方面我们以后的要求也是C++,
: 而且听说C#和Java很像,我现在也在学Java,所以在权衡之中还是
: 先选择C++,这样以后再学C#也比较容易,不过现在好多的VS的教程都是C#的,C++的比较少
: ...................
学C++对C#没有帮助。学C#的时候也尽可能把C++忘干净。C#和Java相似是真的。
想权衡的话,不如Java和C#都学学,我C#只学过一点点,比Java差很远。这样你可以比较一下哪个符合你的口味。
学C#的话可以去图书馆借一本书。最新版的C#是5.0,选一本比较新的书。视频……节奏太慢,还是按自己的节奏看书吧。