#pragma once
/////////////////////////////////////////////////////////////
// Form1.h - Demonstrate C++/CLI Winform //
// //
// Jim Fawcett, CSE775 - Distributed Objects, Spring 2008 //
/////////////////////////////////////////////////////////////
namespace CppWinForm {
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::Runtime::InteropServices; // for MsgBox PInvoke
///
/// 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:
// PInvoke, below, is required to access Win32 MessageBox
[DllImport("User32.dll", EntryPoint="MessageBox", CharSet=CharSet::Auto)]
static int MessageBox(int hWnd, String^ text, String^ caption, unsigned int type);
Form1(void)
{
InitializeComponent();
axDemoControl1->Text = "Hi from control"; // use control property
this->BackColor = Color::Maroon; // use Form property
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private:
AxAxDemoSp08Lib::AxDemoControl^ axDemoControl1;
protected:
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->axDemoControl1 = (gcnew AxAxDemoSp08Lib::AxDemoControl());
(cli::safe_cast(this->axDemoControl1))->BeginInit();
this->SuspendLayout();
//
// axDemoControl1
//
this->axDemoControl1->Anchor = static_cast((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->axDemoControl1->Enabled = true;
this->axDemoControl1->Location = System::Drawing::Point(41, 30);
this->axDemoControl1->Name = L"axDemoControl1";
this->axDemoControl1->Size = System::Drawing::Size(200, 192);
this->axDemoControl1->TabIndex = 0;
this->axDemoControl1->clicked += gcnew System::EventHandler(this, &Form1::axDemoControl1_clicked);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 264);
this->Controls->Add(this->axDemoControl1);
this->Name = L"Form1";
this->Text = L"Form1";
(cli::safe_cast(this->axDemoControl1))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private:
//----< handler for ActiveX control "clicked" event >------------
System::Void axDemoControl1_clicked(System::Object^ sender, System::EventArgs^ e)
{
// Demonstrate using Win32 API via PInvoke
MessageBox(0,axDemoControl1->Text,"Property Text",0);
// Can also simply use System::Windows::Forms::Messagebox
MessageBox::Show("some more text", "Demo");
}
};
}