Results 1 to 4 of 4

Thread: Edit boxes and the return button

  1. #1

    Edit boxes and the return button

    Its not quite game related, but I have a quick chat program where I have an edit box to enter text. When the return key is pressed, the text is processed and the contents of the text box cleared. However the TEdit box seems to have a peculiar feature that if the return key is pressed, the Windows error sound is given. Is there a way around this? Setting the value of key to 0 in the keydown event doesn’t seem to help. A TMemo might be a solution, but that seems to create an extra line of text after pressing return that I can’t get rid of.

    Any help appreciated,

    Matt.

  2. #2

    Edit boxes and the return button

    In OnKeyPress-Event put this:

    if Key = #13 then begin
    SendMessage(GetParentForm(Self).Handle, WM_NEXTDLGCTL, 0, 0);

    This lets the sound "disappear".

    Greetings,
    Dirk
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

  3. #3

    Edit boxes and the return button

    You can also just set Key to #0 as follows:

    Code:
    procedure TForm1.EditKeyPress&#40;Sender&#58;TObject; var Key &#58; Char&#41;;
    begin
      if Key = #13 then
        begin
          // Your processing here
          Key &#58;= #0;
        end;
    end;

  4. #4

    Edit boxes and the return button

    By jove, thats it. I was close, but no cigar. Thankyou very much indeed.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •