Hallo Zusammen,
ich schreibe momentan an einem Lan-Chat das ganze funktioniert auch soweit bis auf eine kleinigkeit...
Wenn ich eine Nachricht schicke, kommt die erste nicht an Bzw. wird nicht im
Memo gepostet sondern erst die 2. erscheint dann im Memo. Hier die Entsprechenden Quellcode Zeilen die ich Programmiert habe Kommentare sind vorhanden:
Main: Hier ist der ServerSocket
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:
| procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket); var da : boolean; i,temp : Integer; SL : tStringlist; begin da := false; temp := 0; sl := tstringlist.create; for I := 0 to stringgrid3.RowCount - 1 do begin if stringgrid3.Cells[0,i] = socket.Remoteaddress then begin da := true; temp := StrToInt(stringgrid3.cells[1,i]); end; end; if da = true then begin TForm11( FormList[ temp ] ).Memo1.Lines.Add( Socket.ReceiveText ); end else begin sl.Delimiter := ':'; sl.DelimitedText := socket.ReceiveText; formlist.add(Tform11.Create(application)); stringgrid3.Cells[0,stringgrid3.RowCount-1] := socket.Remoteaddress; TForm11( FormList[formlist.Count-1] ).clientsocket1.Host := socket.RemoteHost; TForm11( FormList[ formlist.count-1 ] ).clientsocket1.Active := true; stringgrid3.Cells[1,stringgrid3.RowCount-1] := IntToStr(formlist.Count-1); stringgrid3.RowCount := stringgrid3.RowCount +1; TForm11( FormList[ formlist.count-1 ] ).caption := 'Chat mit ' + sl[0]; TForm11( FormList[ formlist.count-1 ] ).index := formlist.count -1; TForm11( FormList[ formlist.count-1 ] ).show; TForm11( FormList[ formlist.count-1 ] ).Memo1.Lines.Add( Socket.ReceiveText );
end; end; end; sl.free; end; |
Chatfenster hier ist der Clientsocket
Delphi-Quelltext
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:
| procedure TForm11.Button1Click(Sender: TObject); begin if (ClientSocket1.Active=true) and (Edit1.Text<>'') then ClientSocket1.Socket.SendText(form1.edit3.text+': '+Edit1.Text); memo1.Lines.Add(form1.edit3.text + ': ' + edit1.text); Edit1.Text:=''; end;
procedure TForm11.FormClose(Sender: TObject; var Action: TCloseAction); begin self.Destroy; end;
procedure TForm11.FormDestroy(Sender: TObject); var I: Integer; begin for I := 0 to form1.StringGrid3.RowCount - 1 do begin if inttoStr(index) = (form1.stringgrid3.Cells[1,i]) then begin griddeleterow(form1.stringgrid3,i); end; end; |
ich hoffe ihr könnt mir helfen
ich wäre euch sehr dankbar
Schöne Grüße Manuel
---
Moderiert von
Narses: Beiträge zusammengefasst---
Habe bemerkt das wenn ich einen Statischen Text adde (ins memo) dann postet er ihn auch spricht ich füge jetzt einfach SL.Delimatedtext hinzu und es funktioniert
Moderiert von
Narses: Topic aus VCL (Visual Component Library) verschoben am Fr 12.12.2008 um 12:56