#pragma once ///////////////////////////////////////////////////////////////////// // demoControl.h - Demonstration control example that illustrates: // // - how to expose events (with delegates) // // - how to expose properties (by defining them) // // // // 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 // ///////////////////////////////////////////////////////////////////// using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace control { public ref class controlControl : public System::Windows::Forms::Control { public: // mouse up and mouse down events defined here // Note: // These events are really not necessary, as the base // Control class already publishes MouseDown and MouseUp // events. This redefinition simply demonstrates how to // define an event. delegate void MseDown(Object^ sender, MouseEventArgs^ e); event MseDown^ mousedown; delegate void MseUp(Object^ sender, MouseEventArgs^ e); event MseUp^ mouseup; // text property defined here property String^ controlText; controlControl(void); protected: ~controlControl() { if (components) { delete components; } } //----< define painted control view >---------------------------- virtual void controlControl::OnPaint(PaintEventArgs^ e) override; private: 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->SuspendLayout(); // // controlControl // this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler( this, &controlControl::controlControl_MouseDown ); this->MouseUp += gcnew System::Windows::Forms::MouseEventHandler( this, &controlControl::controlControl_MouseUp ); this->ResumeLayout(false); } #pragma endregion private: // Respond to base Control's MouseDown and MouseUp System::Void controlControl_MouseDown( System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e ); System::Void controlControl_MouseUp( System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e ); SolidBrush^ bkgrBrush; }; }