[VC++ .NET] WinProc / WndProc Messages abfangen

Also in .NET 2.0 kann ich leider nicht sagen ob es da schon Funktionalitäten gibt,
mit denen Du das erreichst.

Wenn Du dir aber die Beispiele auf TheCodeProject anschaust,
wirst Beispiele finden, in denen die TabReiter selber gezeichnet werden.
Wenn Du die erweiterst, sprich die Rectngles der einzelnen Reiter speicherst,
wirst das sicher hinbekommen...
 
Gut, ich habe mein Problem gelöst... der ganze Aufwand mit den WinProc oder Reiter->Bounds was komplett unnötig, ich kann das eh simpel über Events regeln :D

C++:
#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;
			}
		}
};
}

Nun ist die TabPage0 (in diesem Beispiel) immer mindestens einmal offen :D
Wenn man versucht, die letzte Page0 wegzuklicken, wird die Aktion abgebrochen und es wird keine neue TabPage geöffnet...
Flackert nicht, funktioniert einwandfrei *gg*

Und wenigstens versteh ich jetzt endlich wie Windows Processe ablaufen und wie ich die Messages abfangen kann *gg*

War eigentlich ganz einfach :D hab mich halt nur in den Möglichkeiten verloren -.-

Also

Ham wir wieder was gelernt
Auf wiedersehn

:D
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück