#pragma once
namespace WndProc_Test {
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::Security::Permissions;
using namespace System::Runtime::InteropServices;
/// <summary>
/// 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.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: array<System::Windows::Forms::TabControl ^> ^tabControls;
private: array<System::Windows::Forms::TabPage ^> ^tabPages;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->tabControls = gcnew array<System::Windows::Forms::TabControl ^>(4);
this->tabPages = gcnew array<System::Windows::Forms::TabPage ^>(4);
this->SuspendLayout();
// erstelle 4 TabControls mit jeweils 4 Pages
for (int idx_TabCtrl = 0; idx_TabCtrl < this->tabControls->Length; ++idx_TabCtrl)
{
this->tabControls[idx_TabCtrl] = gcnew System::Windows::Forms::TabControl();
this->tabControls[idx_TabCtrl]->Location = Point( 15, idx_TabCtrl * 100 + idx_TabCtrl * 5 );
this->tabControls[idx_TabCtrl]->Name = L"tabControl" + idx_TabCtrl;
this->tabControls[idx_TabCtrl]->Size = System::Drawing::Size(240, 100);
this->tabControls[idx_TabCtrl]->Deselecting += gcnew System::Windows::Forms::TabControlCancelEventHandler(this, &Form1::tabControl_Deselecting);
this->tabControls[idx_TabCtrl]->SuspendLayout();
for (int idx_TabPage = 0; idx_TabPage < this->tabPages->Length; ++idx_TabPage)
{
this->tabPages[idx_TabPage] = gcnew System::Windows::Forms::TabPage();
this->tabPages[idx_TabPage]->Location = System::Drawing::Point(4, 22);
this->tabPages[idx_TabPage]->Name = L"tabPage"+idx_TabPage;
this->tabPages[idx_TabPage]->Text = L"tabPage"+idx_TabPage;
this->tabPages[idx_TabPage]->Padding = System::Windows::Forms::Padding(3);
this->tabPages[idx_TabPage]->Size = System::Drawing::Size(232, 74);
this->tabControls[idx_TabCtrl]->Controls->Add(this->tabPages[idx_TabPage]);
}
this->tabControls[idx_TabCtrl]->ResumeLayout(false);
this->Controls->Add(this->tabControls[idx_TabCtrl]);
}
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(270, 420);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
this->Name = L"Form1";
this->Text = L"TabPageChange Locker";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void tabControl_Deselecting(System::Object^ sender, System::Windows::Forms::TabControlCancelEventArgs^ e)
{
/* wenn ein TabChange ausgeführt werden soll, überprüfe, ob die angegebene Page (in diesem Fall TabPage0 mindestens einmal aktiv ist, ansonsten Abbruch*/
int count = 0;
if (e->TabPage->Name == "tabPage0")
{
for each(System::Windows::Forms::TabControl^ tab in this->tabControls)
{
if(tab->SelectedTab->Name == "tabPage0")
{
count ++;
}
}
if (count <= 1)
e->Cancel = true;
}
}
};
}