-----------------------share.h---------------------
#pragma once extern bool is[30]; extern int* jilucmark; extern Int16 jilucount; namespace Need_For_Share { 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> /// share 摘要 /// </summary> public ref class share : public System::Windows::Forms::Form { public: share(void) { InitializeComponent(); // //TODO: 在此处添加构造函数代码 // } protected: /// <summary> /// 清理所有正在使用的资源。 /// </summary> ~share() { if (components) { delete components; } } public : System::Windows::Forms::ListView^ sharelist; protected: protected: private: System::Windows::Forms::ColumnHeader^ columnHeader1; private: System::Windows::Forms::Label^ label1; public : System::Windows::Forms::ImageList^ imageList1; public : System::Windows::Forms::TreeView^ sharetree; private: System::Windows::Forms::Button^ btnyes; public: private: private: System::ComponentModel::IContainer^ components; private: /// <summary> /// 必需的设计器变量。 /// </summary> #pragma region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> void InitializeComponent(void) { this->components = (gcnew System::ComponentModel::Container()); System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(share::typeid)); this->sharelist = (gcnew System::Windows::Forms::ListView()); this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader()); this->imageList1 = (gcnew System::Windows::Forms::ImageList(this->components)); this->label1 = (gcnew System::Windows::Forms::Label()); this->sharetree = (gcnew System::Windows::Forms::TreeView()); this->btnyes = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // sharelist // this->sharelist->CheckBoxes = true; this->sharelist->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(1) {this->columnHeader1}); this->sharelist->Dock = System::Windows::Forms::DockStyle::Top; this->sharelist->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->sharelist->Location = System::Drawing::Point(0, 0); this->sharelist->Name = L"sharelist"; this->sharelist->Size = System::Drawing::Size(241, 397); this->sharelist->SmallImageList = this->imageList1; this->sharelist->TabIndex = 0; this->sharelist->UseCompatibleStateImageBehavior = false; this->sharelist->View = System::Windows::Forms::View::Details; this->sharelist->ItemChecked += gcnew System::Windows::Forms::ItemCheckedEventHandler(this, &share::sharelist_ItemChecked); this->sharelist->Click += gcnew System::EventHandler(this, &share::sharelist_Click); // // columnHeader1 // this->columnHeader1->Text = L" 用户"; this->columnHeader1->Width = 212; // // imageList1 // this->imageList1->ColorDepth = System::Windows::Forms::ColorDepth::Depth32Bit; this->imageList1->ImageSize = System::Drawing::Size(50, 50); this->imageList1->TransparentColor = System::Drawing::Color::Transparent; // // label1 // this->label1->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->label1->Location = System::Drawing::Point(12, 419); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(211, 24); this->label1->TabIndex = 1; this->label1->Text = L"请选择对其私密分享的好友"; // // sharetree // this->sharetree->CheckBoxes = true; this->sharetree->Location = System::Drawing::Point(16, 199); this->sharetree->Name = L"sharetree"; this->sharetree->Size = System::Drawing::Size(121, 97); this->sharetree->TabIndex = 4; // // btnyes // this->btnyes->Enabled = false; this->btnyes->Font = (gcnew System::Drawing::Font(L"微软雅黑", 9)); this->btnyes->Location = System::Drawing::Point(60, 446); this->btnyes->Name = L"btnyes"; this->btnyes->Size = System::Drawing::Size(102, 33); this->btnyes->TabIndex = 5; this->btnyes->Text = L"确定"; this->btnyes->UseVisualStyleBackColor = true; this->btnyes->Click += gcnew System::EventHandler(this, &share::btnyes_Click); // // share // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(241, 491); this->Controls->Add(this->sharelist); this->Controls->Add(this->btnyes); this->Controls->Add(this->sharetree); this->Controls->Add(this->label1); this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon"))); this->Location = System::Drawing::Point(760, 99); this->MaximizeBox = false; this->MaximumSize = System::Drawing::Size(257, 530); this->MinimizeBox = false; this->MinimumSize = System::Drawing::Size(257, 530); this->Name = L"share"; this->StartPosition = System::Windows::Forms::FormStartPosition::Manual; this->Text = L"share"; this->Load += gcnew System::EventHandler(this, &share::share_Load); this->ResumeLayout(false); } #pragma endregion //窗体加载函数 private: System::Void share_Load(System::Object^ sender, System::EventArgs^ e) { if(sharetree->Nodes->Count==0) return; Int16 a=1; TreeNode^ temp=sharetree->Nodes[0]; sharelist->Items->Add(temp->Text); sharelist->Items[0]->ImageIndex=0; while(temp->NextNode!=nullptr) { temp=temp->NextNode; sharelist->Items->Add(temp->Text); sharelist->Items[a]->ImageIndex=a; a++; } } //单击控件函数 private: System::Void sharelist_Click(System::Object^ sender, System::EventArgs^ e) { if(sharelist->SelectedItems->Count>=1) { Int16 a=sharelist->SelectedIndices[0]; sharelist->Items[a]->Checked=!sharelist->Items[a]->Checked; } } //更改项的选中状态时函数 private: System::Void sharelist_ItemChecked(System::Object^ sender, System::Windows::Forms::ItemCheckedEventArgs^ e) { if(sharelist->CheckedItems->Count!=0) btnyes->Enabled=true; else btnyes->Enabled=false; } //选中对其私密分享按钮 private: System::Void btnyes_Click(System::Object^ sender, System::EventArgs^ e) { delete[] jilucmark; for(Int16 i=0;i<sharelist->Items->Count;i++) sharetree->Nodes[i]->Checked=sharelist->Items[i]->Checked; //令树节点的checked属性等于列视图的checked属性 jilucount=sharelist->CheckedItems->Count; jilucmark=new int[jilucount]; Int16 a=0; TreeNode^ temp=sharetree->Nodes[0]; if(temp->Checked) { jilucmark[a]=safe_cast<sharetn^>(temp)->CMark; a++; } while(temp->NextNode!=nullptr) { temp=temp->NextNode; jilucmark[a]=safe_cast<sharetn^>(temp)->CMark; a++; } is[9]=true; this->Close(); } }; }
#pragma once namespace Need_For_Share { 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> /// shuxing 摘要 /// </summary> public ref class shuxing : public System::Windows::Forms::Form { public: shuxing(void) { InitializeComponent(); // //TODO: 在此处添加构造函数代码 // } protected: /// <summary> /// 清理所有正在使用的资源。 /// </summary> ~shuxing() { if (components) { delete components; } } public: System::Windows::Forms::PictureBox^ pictureBox1; protected: private: System::Windows::Forms::Label^ label1; public: private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::Label^ label4; public: System::Windows::Forms::Label^ name; private: public: System::Windows::Forms::Label^ text; public: System::Windows::Forms::Label^ sex; protected: private: /// <summary> /// 必需的设计器变量。 /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(shuxing::typeid)); this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox()); this->label1 = (gcnew System::Windows::Forms::Label()); this->label2 = (gcnew System::Windows::Forms::Label()); this->label4 = (gcnew System::Windows::Forms::Label()); this->name = (gcnew System::Windows::Forms::Label()); this->text = (gcnew System::Windows::Forms::Label()); this->sex = (gcnew System::Windows::Forms::Label()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit(); this->SuspendLayout(); // // pictureBox1 // this->pictureBox1->Location = System::Drawing::Point(12, 12); this->pictureBox1->Name = L"pictureBox1"; this->pictureBox1->Size = System::Drawing::Size(119, 140); this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage; this->pictureBox1->TabIndex = 0; this->pictureBox1->TabStop = false; // // label1 // this->label1->AutoSize = true; this->label1->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->label1->Location = System::Drawing::Point(153, 29); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(79, 20); this->label1->TabIndex = 1; this->label1->Text = L"用户昵称:"; // // label2 // this->label2->AutoSize = true; this->label2->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->label2->Location = System::Drawing::Point(153, 75); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(79, 20); this->label2->TabIndex = 2; this->label2->Text = L"用户备注:"; // // label4 // this->label4->AutoSize = true; this->label4->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->label4->Location = System::Drawing::Point(153, 120); this->label4->Name = L"label4"; this->label4->Size = System::Drawing::Size(79, 20); this->label4->TabIndex = 4; this->label4->Text = L"用户性别:"; // // name // this->name->AutoSize = true; this->name->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->name->Location = System::Drawing::Point(238, 29); this->name->Name = L"name"; this->name->Size = System::Drawing::Size(50, 20); this->name->TabIndex = 5; this->name->Text = L"label3"; // // text // this->text->AutoSize = true; this->text->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->text->Location = System::Drawing::Point(238, 75); this->text->Name = L"text"; this->text->Size = System::Drawing::Size(50, 20); this->text->TabIndex = 6; this->text->Text = L"label5"; // // sex // this->sex->AutoSize = true; this->sex->Font = (gcnew System::Drawing::Font(L"微软雅黑", 10)); this->sex->Location = System::Drawing::Point(238, 120); this->sex->Name = L"sex"; this->sex->Size = System::Drawing::Size(50, 20); this->sex->TabIndex = 7; this->sex->Text = L"label6"; // // shuxing // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(444, 179); this->Controls->Add(this->sex); this->Controls->Add(this->text); this->Controls->Add(this->name); this->Controls->Add(this->label4); this->Controls->Add(this->label2); this->Controls->Add(this->label1); this->Controls->Add(this->pictureBox1); this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon"))); this->MaximizeBox = false; this->MinimizeBox = false; this->Name = L"shuxing"; this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; this->Load += gcnew System::EventHandler(this, &shuxing::shuxing_Load); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void shuxing_Load(System::Object^ sender, System::EventArgs^ e) {ing } }; }
-------------------我自己的头文件.h-----------------------
#ifndef HEAD #define HEAD #include<ctime> #include<Windows.h> using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; using namespace System::Text; //本地用户记载类 ref class Customer { public: String^ CName; //用户名 String^ CText; //用户备注名 String^ CPicture; //用户头像路径名 bool CSex; //性别 Int32 CMark; //用户标志位 bool isok; //判断用户是否还连接好 Customer(String^ a,String^ b,bool c); //a是用户名,b是头像路径,c是性别 ~Customer(){}; //析构函数 array<Byte>^ ConvertByte(); //用户转换为流数据 UInt32 size; }; //用户节点派生类 ref class yonghu:public TreeNode { public: Int16 choice; //分辨树节点类型123456分别为用户、秘密文件夹、秘密文件项、一般项、秘密文件夹2号、一般文件夹 String^ CName; //用户名\必要时刻成为Text记载 String^ CText; //用户备注名或者秘密文件夹标志位序列号 String^ CPicture; //路径名 bool CSex; //性别 Int32 CMark; //用户标志位 Double size; //记录总大小 yonghu(){} yonghu(Int16); array<Byte>^ ConvertByte(Int16 ); //类转换为流数据 private: array<Byte>^ c1(); //类型转换函数选择体系 array<Byte>^ c2(); array<Byte>^ c3(); array<Byte>^ c4(); array<Byte>^ c5(); array<Byte>^ c6(); }; //分享时供选择的用户类 ref class sharetn:public TreeNode //share用户树节点 { public: Int32 CMark; sharetn(String^ ,Int32 ); }; //设置缓存数据结构 value struct huancun { array<Byte>^ date; Int32 hCount; //huancun接收的字节数 bool is; }; //下载状态的封装类 //参数分别是 //a i标志位的赋值 //b 名字 //c 总容量大小 //d 下载文件的路径 //e 被下载掩码 ref class down { public : down(Int16 ,String^ ,Double ,String^ ,Int16 ); Int16 di; //下载栏标志位,0开始 Label^ name; //下载的文件名 Label^ size; //大小变化 Label^ time; //时间剩余计算 Label^ speed; //下载速度 LinkLabel^ pause; //暂停 LinkLabel^ cancel; //取消 ProgressBar^ progress;//进度条 ToolTip^ namehelp; //名字长度过长时产生的提示符 static Int16 count=0; //下载任务总数 static Int16 ding=0; //正在下载的任务 Double zsize; //下载任务的总大小记录 Double dsize; //已经下载了的大小记录,以上2个变量是以m为单位的 UInt32 tsize; //计时器的刷新时已经下载的数据,以b为单位 String^ CPicture; //下载的路径记录 bool first; //是否已经接收到下载信息 int zbaocount; //总 包 长度 ,下载内容的总大小 int tbaocount; //已经写入的包长度 array<Int32>^ ybaojilu; //写过的包的记录 FileStream^ fs; //下载流处理 Int16 cmark; //被下载方掩码 bool situation; //下载状态记录 }; //帮助进行拖放操作的类 value struct drog { String^ fileName; //文件名 bool is; //是否是文件夹 true是,false不是 }; //下载线程中的用户结构体 ref class zidown { public: zidown(Int16 a,Int16 b) { CMark=a; di=b; situation=true; //设置状态为下载状态 } Int16 CMark; //用户掩码 Int16 di; //用户本地下载标志位 bool situation; }; //下载的开辟线程类 ref class downing { public: downing(Int16 ,Int16,String^ ); //,a下载方的用户掩码,b下载标志位,c路径 array<zidown^>^ joindyh; //join down yonghu String^ CPicture; //关联的发送路径 Int16 dcount; //down count,加入的下载用户数,最大为100,从1开始 static Int16 zdcount=0; //总共的下载线程数 bool running; //判断它什么时候完成使命 }; ref class f4help //多线程参数传递 { public: f4help(Int16 a) { zheng=a; } Int16 zheng; }; void qidong(); //启动程序时调用登陆界面的函数 int random(); //如果用户选择男生,返回1-5的随机数。否则返回6-10的随机数 //返回应用程序被安装的文件夹地址!!如果安装路径和名字是中文字符,则失效 char* AppName(); //返回上次用户登录时是否选择记住 bool isCheck(); //返回用户昵称 char* UserName(); //返回用户头像的地址 char* UserPictureLocation(); //返回用户性别 bool isBoy(); //Int32转换为字节数组 array<Byte>^ IntToByte(Int32 i); //进行消息判断处理 Int32 trigger(String^ a); //类内部的消息判断 Int32 trigger1(String^ a); //返回是否首次运行该程序,true是 bool isshouci(); //返回默认下载路径 char* pathdown(); //下载前调用这个函数,提示默认路径的存在,同时检查路径是否存在 void beforedown(); //修改默认下载路径 void xiugaipath(String^ a); //判断文件是否是文件夹,true是 bool panduan(drog a); //判断一个多层文件夹是否为空,空true bool nulldirectory(String^ a); //返回文件名 char* getname(String^ a); //传size过来,返回char*,返回表示容量的标准模式 char* getsize(Double a); //获取表示速度的标准模式 char* getspeed(UInt32 a); //计算剩余时间 char* gettime(Double a,UInt32 b); //解除套接字的占用 void beforesend(); //规范化ip地址 char* formatip(String^ a); //写入或者获取ip地址,b 为true写入 char* getip(String^ a,bool b); #endif
-------------------头文件到此结束,接下来是cpp文件------------------------