#pragma once /////////////////////////////////////////////////////////////////// // Form1.h - Test demoControl // // - use its controlText property for titlebar // // - handle its mousedown and mouseup events by // // toggling background color and setting title // // text. // // // // Language: Visual C++/CLI, VS8 // // Platform: Dell Dimension 9250, Windows XP Pro, SP2 // // Application: CSE775 - Distributed Objects Demo // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // Note: // Don't include controls header - that causes multiple definitions // #include "../control/controlControl.h" // When you pull the control onto a form, the designer copies the // control's DLL into the same directory that houses the container's // exe, where it is implicitly loaded. That is equivalent to setting // a reference in C# namespace TestContainer { 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 ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } protected: ~Form1() { if (components) { delete components; } } private: control::controlControl^ controlControl1; System::ComponentModel::Container ^components; // #pragma region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// void InitializeComponent(void) { this->controlControl1 = (gcnew control::controlControl()); this->SuspendLayout(); // // controlControl1 // this->controlControl1->controlText = L"demoControl"; this->controlControl1->Dock = System::Windows::Forms::DockStyle::Fill; this->controlControl1->Location = System::Drawing::Point(0, 0); this->controlControl1->Name = L"controlControl1"; this->controlControl1->Size = System::Drawing::Size(444, 161); this->controlControl1->TabIndex = 0; this->controlControl1->Text = L"controlControl1"; this->controlControl1->MouseLeave += gcnew System::EventHandler(this, &Form1::controlControl1_MouseLeave); this->controlControl1->mousedown += gcnew control::controlControl::MseDown(this, &Form1::controlControl1_mousedown); this->controlControl1->mouseup += gcnew control::controlControl::MseUp(this, &Form1::controlControl1_mouseup); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(444, 161); this->Controls->Add(this->controlControl1); this->Name = L"Form1"; this->Text = L"Form1"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); } // #pragma endregion private: //----< set title text to control's controlText property >------- System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { this->Text = controlControl1->controlText; } //----< on mousedown, set title text >--------------------------- System::Void controlControl1_mousedown( // note lower case, e.g. our System::Object^ sender, // control's event not base. System::Windows::Forms::MouseEventArgs^ e ) { this->Text = "Mouse Down in Control"; } //----< on mouseup, set title text >----------------------------- System::Void controlControl1_mouseup( System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e ) { this->Text = "Mouse Up in Control"; } //----< on mouse out, reset title text >------------------------- System::Void controlControl1_MouseLeave( System::Object^ sender, System::EventArgs^ e) { this->Text = controlControl1->controlText; } }; }