A
das problem ist folgendes:
ich wollte mir ein formular schreiben, das als inputbox gebraucht werden kann. Wie eine MessageBox, einfach das sie noch den Wert im Textfeld zurückgeben soll.. Das Formular sieht ja gut aus, aber wie stelle ich das an das ich da den String aus der TextBox kriege?
Hier der Code:
//InputBox.h
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class InputBox : public System::Windows::Forms::Form
{
public:
InputBox(int length, String^ text)
: text(text)
{
if (length < 90)
length = 90;
this->length = length;
InitializeComponent();
}
protected:
~InputBox()
{
if (components)
{
delete components;
}
}
private:
System::Windows::Forms::TextBox^ TextIn;
System::Windows::Forms::Button^ ButtonOK;
System::ComponentModel::Container ^components;
System::String^ text;
int length;
void InitializeComponent(void)
{
this->TextIn = gcnew System::Windows::Forms::TextBox();
this->ButtonOK = gcnew System::Windows::Forms::Button();
this->TextIn->Location = System::Drawing::Point(10, 10);
this->TextIn->Name = L"TextIn";
this->TextIn->Size = System::Drawing::Size(length, 20);
this->TextIn->TabIndex = 0;
this->ButtonOK->Location = System::Drawing::Point(length+20, 10);
this->ButtonOK->Name = L"ButtonOK";
this->ButtonOK->Size = System::Drawing::Size(30, 20);
this->ButtonOK->TabIndex = 1;
this->ButtonOK->Text = L"OK";
this->ButtonOK->UseVisualStyleBackColor = true;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
this->ClientSize = System::Drawing::Size(length+60, 40);
this->Controls->Add(this->TextIn);
this->Controls->Add(this->ButtonOK);
this->Name = L"InputBox";
this->Text = text;
this->ResumeLayout(false);
this->PerformLayout();
}
private:
System::Void ButtonOK_Click(System::Object^ sender, System::EventArgs^ e)
{
this->Close();
}
};