ERLEDIGT
JA
JA
ANTWORTEN
1
1
ZUGRIFFE
350
350
EMPFEHLEN
-
16.11.09 22:39 #1
- Registriert seit
- Nov 2009
- Beiträge
- 2
Hallo!
Ich hab mich vor kurzem mit Visual c++ angefreundet und
bin nun auf mein erstes problem gestoßen:
ich will eine klasse mit
ClientSocket* sockClient = new ClientSocket;
"global" in einem MDI-child aufrufen. Ohne MDI-child konnte ich
dies einfach an einer stelle im quellcode definieren (siehe ROT).
funktionieren tuts auch alles wenn ich den oben besagten quellcodeschnipsel
direkt an der stelle ganz unten (siehe GRÜN) einfüge, dann jedoch ist die funktion
nur für den button verfügbar und nicht für andere buttons.
nun die sicherlich lächerliche frage (hey ich bin erst ne woche dabei
)
wie muss ich den quellcodeschnipsel einfügen damit ich auch mit anderen
buttons auf die funktionen der klasse zugreifen kann? =)
würde mich tierisch über hilfe freuen, fettes mauz!
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
#pragma once #include "Socket.h" #include "WinSock2.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; using namespace System::Threading; // für timer using namespace System::Runtime::InteropServices;//Für Marshal namespace snowleopard { [B][COLOR="Red"]bisher hier definiert[/COLOR][/B] /// <summary> /// Zusammenfassung für P2Pmailer /// /// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch /// die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern, /// das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt. /// Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen /// arbeiten, die diesem Formular zugewiesen sind. /// </summary> public ref class P2Pmailer : public System::Windows::Forms::Form { public: P2Pmailer(void) { InitializeComponent(); // //TODO: Konstruktorcode hier hinzufügen. // } protected: /// <summary> /// Verwendete Ressourcen bereinigen. /// </summary> ~P2Pmailer() { if (components) { delete components; } } private: System::Windows::Forms::Label^ lb_Port2; protected: private: System::Windows::Forms::Label^ lp_IP; private: System::Windows::Forms::Label^ lb_Port1; private: System::Windows::Forms::TextBox^ tb_Port; private: System::Windows::Forms::TextBox^ tb_IP; private: System::Windows::Forms::Button^ bt_ping; private: System::Windows::Forms::Button^ bt_verbindung_trennen; private: System::Windows::Forms::Label^ lb_status; private: System::Windows::Forms::Label^ lb_EventX; private: System::Windows::Forms::TextBox^ tb_Daten; private: System::Windows::Forms::Button^ bt_senden; private: System::Windows::Forms::TextBox^ tb_Eingabe; private: System::Windows::Forms::TextBox^ tb_PortServer; private: System::Windows::Forms::Button^ bt_client_start; private: System::Windows::Forms::Button^ bt_server_start; protected: protected: private: /// <summary> /// Erforderliche Designervariable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Erforderliche Methode für die Designerunterstützung. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. /// </summary> void InitializeComponent(void) { this->lb_Port2 = (gcnew System::Windows::Forms::Label()); this->lp_IP = (gcnew System::Windows::Forms::Label()); this->lb_Port1 = (gcnew System::Windows::Forms::Label()); this->tb_Port = (gcnew System::Windows::Forms::TextBox()); this->tb_IP = (gcnew System::Windows::Forms::TextBox()); this->bt_ping = (gcnew System::Windows::Forms::Button()); this->bt_verbindung_trennen = (gcnew System::Windows::Forms::Button()); this->lb_status = (gcnew System::Windows::Forms::Label()); this->lb_EventX = (gcnew System::Windows::Forms::Label()); this->tb_Daten = (gcnew System::Windows::Forms::TextBox()); this->bt_senden = (gcnew System::Windows::Forms::Button()); this->tb_Eingabe = (gcnew System::Windows::Forms::TextBox()); this->tb_PortServer = (gcnew System::Windows::Forms::TextBox()); this->bt_client_start = (gcnew System::Windows::Forms::Button()); this->bt_server_start = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // lb_Port2 // this->lb_Port2->AutoSize = true; this->lb_Port2->Location = System::Drawing::Point(328, 44); this->lb_Port2->Name = L"lb_Port2"; this->lb_Port2->Size = System::Drawing::Size(29, 13); this->lb_Port2->TabIndex = 12; this->lb_Port2->Text = L"Port:"; // // lp_IP // this->lp_IP->AutoSize = true; this->lp_IP->Location = System::Drawing::Point(337, 18); this->lp_IP->Name = L"lp_IP"; this->lp_IP->Size = System::Drawing::Size(20, 13); this->lp_IP->TabIndex = 11; this->lp_IP->Text = L"IP:"; // // lb_Port1 // this->lb_Port1->AutoSize = true; this->lb_Port1->Location = System::Drawing::Point(11, 18); this->lb_Port1->Name = L"lb_Port1"; this->lb_Port1->Size = System::Drawing::Size(29, 13); this->lb_Port1->TabIndex = 13; this->lb_Port1->Text = L"Port:"; // // tb_Port // this->tb_Port->Location = System::Drawing::Point(366, 45); this->tb_Port->Name = L"tb_Port"; this->tb_Port->Size = System::Drawing::Size(47, 20); this->tb_Port->TabIndex = 17; this->tb_Port->Text = L"666"; // // tb_IP // this->tb_IP->Location = System::Drawing::Point(366, 19); this->tb_IP->Name = L"tb_IP"; this->tb_IP->Size = System::Drawing::Size(123, 20); this->tb_IP->TabIndex = 16; this->tb_IP->Text = L"192.168.2.105"; // // bt_ping // this->bt_ping->Location = System::Drawing::Point(174, 61); this->bt_ping->Name = L"bt_ping"; this->bt_ping->Size = System::Drawing::Size(111, 23); this->bt_ping->TabIndex = 25; this->bt_ping->Text = L"ping feststellen"; this->bt_ping->UseVisualStyleBackColor = true; this->bt_ping->Visible = false; // // bt_verbindung_trennen // this->bt_verbindung_trennen->Location = System::Drawing::Point(175, 32); this->bt_verbindung_trennen->Name = L"bt_verbindung_trennen"; this->bt_verbindung_trennen->Size = System::Drawing::Size(110, 23); this->bt_verbindung_trennen->TabIndex = 24; this->bt_verbindung_trennen->Text = L"verbindung trennen"; this->bt_verbindung_trennen->UseVisualStyleBackColor = true; this->bt_verbindung_trennen->Visible = false; // // lb_status // this->lb_status->AutoSize = true; this->lb_status->Location = System::Drawing::Point(172, 16); this->lb_status->Name = L"lb_status"; this->lb_status->Size = System::Drawing::Size(71, 13); this->lb_status->TabIndex = 23; this->lb_status->Text = L"Status: offline"; // // lb_EventX // this->lb_EventX->AutoSize = true; this->lb_EventX->BackColor = System::Drawing::Color::Red; this->lb_EventX->Font = (gcnew System::Drawing::Font(L"Arial", 48, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->lb_EventX->Location = System::Drawing::Point(21, 79); this->lb_EventX->Name = L"lb_EventX"; this->lb_EventX->Size = System::Drawing::Size(75, 75); this->lb_EventX->TabIndex = 22; this->lb_EventX->Text = L"X"; this->lb_EventX->Visible = false; // // tb_Daten // this->tb_Daten->BackColor = System::Drawing::SystemColors::ControlLightLight; this->tb_Daten->Location = System::Drawing::Point(17, 157); this->tb_Daten->MaxLength = 100; this->tb_Daten->Multiline = true; this->tb_Daten->Name = L"tb_Daten"; this->tb_Daten->ReadOnly = true; this->tb_Daten->ScrollBars = System::Windows::Forms::ScrollBars::Vertical; this->tb_Daten->Size = System::Drawing::Size(452, 140); this->tb_Daten->TabIndex = 20; // // bt_senden // this->bt_senden->Location = System::Drawing::Point(419, 303); this->bt_senden->Name = L"bt_senden"; this->bt_senden->Size = System::Drawing::Size(50, 23); this->bt_senden->TabIndex = 19; this->bt_senden->Text = L"senden"; this->bt_senden->UseVisualStyleBackColor = true; this->bt_senden->Visible = false; // // tb_Eingabe // this->tb_Eingabe->Location = System::Drawing::Point(17, 303); this->tb_Eingabe->Name = L"tb_Eingabe"; this->tb_Eingabe->Size = System::Drawing::Size(396, 20); this->tb_Eingabe->TabIndex = 18; this->tb_Eingabe->Visible = false; // // tb_PortServer // this->tb_PortServer->Location = System::Drawing::Point(49, 19); this->tb_PortServer->Name = L"tb_PortServer"; this->tb_PortServer->Size = System::Drawing::Size(73, 20); this->tb_PortServer->TabIndex = 21; this->tb_PortServer->Text = L"666"; // // bt_client_start // this->bt_client_start->Location = System::Drawing::Point(419, 42); this->bt_client_start->Name = L"bt_client_start"; this->bt_client_start->Size = System::Drawing::Size(70, 23); this->bt_client_start->TabIndex = 26; this->bt_client_start->Text = L"client start"; this->bt_client_start->UseVisualStyleBackColor = true; // // bt_server_start // this->bt_server_start->Location = System::Drawing::Point(43, 42); this->bt_server_start->Name = L"bt_server_start"; this->bt_server_start->Size = System::Drawing::Size(79, 23); this->bt_server_start->TabIndex = 27; this->bt_server_start->Text = L"server start"; this->bt_server_start->UseVisualStyleBackColor = true; this->bt_server_start->Click += gcnew System::EventHandler(this, &P2Pmailer::bt_server_start_Click); // // P2Pmailer // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(506, 343); this->Controls->Add(this->bt_client_start); this->Controls->Add(this->bt_server_start); this->Controls->Add(this->tb_Port); this->Controls->Add(this->tb_IP); this->Controls->Add(this->bt_ping); this->Controls->Add(this->bt_verbindung_trennen); this->Controls->Add(this->lb_status); this->Controls->Add(this->lb_EventX); this->Controls->Add(this->tb_Daten); this->Controls->Add(this->bt_senden); this->Controls->Add(this->tb_Eingabe); this->Controls->Add(this->tb_PortServer); this->Controls->Add(this->lb_Port2); this->Controls->Add(this->lp_IP); this->Controls->Add(this->lb_Port1); this->MaximizeBox = false; this->MinimumSize = System::Drawing::Size(200, 360); this->Name = L"P2Pmailer"; this->Text = L"P2Pmailer"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void bt_server_start_Click(System::Object^ sender, System::EventArgs^ e) { [COLOR="Lime"][B]HIER GEHTS, ABER HALT NUR FÜR DEN BUTTON![/B][/COLOR] tb_Daten->AppendText("SYSTEM >> Hosting... \r\n"); int port=Convert::ToInt32(tb_PortServer->Text); sockClient->StartHosting(port); //unbenutzbar machen: tb_IP->ReadOnly="True"; tb_Port->ReadOnly="True"; tb_PortServer->ReadOnly="True"; //benutzbar machen: bt_senden->Visible="True"; bt_verbindung_trennen->Visible="True"; tb_Eingabe->Visible="True"; lb_EventX->Visible="True"; bt_ping->Visible="True"; lb_status->Text="Status: online"; tb_Daten->AppendText("SYSTEM >> Verbindung hergestellt\r\n"); //leitet zudem backgroundworker ein } }; }
-
17.11.09 00:24 #2
- Registriert seit
- Nov 2009
- Beiträge
- 2
habs: ist erledigt =)
Ähnliche Themen
-
Klasse in ActionListener aufrufen
Von neuling-00 im Forum JavaAntworten: 8Letzter Beitrag: 06.01.10, 20:55 -
Klasse aus Methode aufrufen
Von Morpheyz im Forum Java GrundlagenAntworten: 6Letzter Beitrag: 04.05.09, 13:00 -
Klasse mit paint() aufrufen
Von Margos im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 3Letzter Beitrag: 21.10.08, 10:19 -
Java Klasse in PHP aufrufen
Von wal im Forum PHPAntworten: 3Letzter Beitrag: 01.10.04, 12:35 -
[Java] Klasse aufrufen
Von tefla im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 4Letzter Beitrag: 06.06.03, 11:24





Zitieren
Login






