#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    24
    Rep Power
    0

    send&receive text with tmemo


    hi!
    I'm trying to make a procedure that can send&receive text messages using a tmemo control and client/server sockets!!
    when i send a message I press the enter key:

    Procedure TfrmMain.memLogKeyPress(Sender: TObject; var key:char);
    var
    SendString : String;
    ResultString : String;

    begin
    OKDone := False;
    FirstRowDone := False;
    if Key = #13 then
    begin

    {Sends Last Line}
    SendString := memLog.Lines[memLog.Lines.Count-1];
    Client1.Write(SendString);
    ResultString := Client1.ReadLn;
    memLog.Lines.Add(ResultString);
    end; {Send Commands}
    end;

    but it doesn't work because when I press the enter key, nothing happens!!
    can you help me please?? thank you!!@

    Christian
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,645
    Rep Power
    4248
    Most likely it is something to do with the Socket code. This code works fine:
    Code:
    procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    var
    	SendString : string;
    begin
    	if Key = #13 then
    	begin
    		SendString := Memo1.Lines[Memo1.Lines.Count - 1];
    		ShowMessage(SendString);
    	end;
    end;
    When I do this, the message shows up which proves that the code is being triggered when I hit the enter key. I'm pretty certain your problem is elsewhere, but without seeing your code, I cannot tell you where it is.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    24
    Rep Power
    0
    I tried your procedure but is not enough!!
    I send you my code(that's also yours!!), please help me!!
    Another question:this program is able to send text strings to other client connected, is possible to send these strings (just in a time) to all the client connected at the moment using the same socket??
    Thank You!!

    Christian
    Attached Files
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    2
    Rep Power
    0

    ??????


    Xian are you trying to make a chat system? can you give me more information on wot you are wanting??? better still add me on msn so we can chat djgalaxy2k@hotmail.com cheers
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    4
    Rep Power
    0

    memLog-> OnKeyPress


    Uncalled --->procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);


    check ur OnKeyPRess for the memLog ok ... it is blank..

    :-)


    Originally Posted by Xian
    I tried your procedure but is not enough!!
    I send you my code(that's also yours!!), please help me!!
    Another question:this program is able to send text strings to other client connected, is possible to send these strings (just in a time) to all the client connected at the moment using the same socket??
    Thank You!!

    Christian

IMN logo majestic logo threadwatch logo seochat tools logo