Hey there, just wondering if anyone could tell me where I can go to learn about using classes in external files (how to link them) and if anyone has a link to download a sample Windows Forms project using dll's (nothing specific, just a basic idea of how it all works together).
------> Below added November 27th
Ok, here's what I'm playing around with:
<<This is a VC++ Windows Forms .NET project>>
My CMainDLL.cpp reads:
And my CMainDLL.h reads:
// This is the main DLL file.
I'm just seeing if I can use (for now until I get better at it) these stupid little things:
using namespace System;
public __gc class Class1
// TODO: Add your methods for this class here.
and Form1.cpp reads:
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 for Form1
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
public __gc class Form1 : public System::Windows::Forms::Form
void Dispose(Boolean disposing)
if (disposing && components)
private: System::Windows::Forms::Button * button1;
/// Required designer variable.
System::ComponentModel::Container * components;
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
this->button1 = new System::Windows::Forms::Button();
this->button1->Location = System::Drawing::Point(112, 216);
this->button1->Name = S"button1";
this->button1->TabIndex = 0;
this->button1->Text = S"button1";
this->button1->Click += new System::EventHandler(this, button1_Click);
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(292, 266);
this->Name = S"Form1";
this->Text = S"Form1";
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
//Something like this, obviously it's not finished, just an example:
Rob.dare = 23.3;
When I compile my error reads:
using namespace CMain;
int APIENTRY _tWinMain(HINSTANCE hInstance,
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
error C2262: 'Rob': cannot be destroyed.
Seems like a lot of code to go through above...
Sure would be nice to be able to use the same code over and over instead of having to re-write it every time I add a new .cpp!
Is there a link somewhere that can teach me how to do this?