|
Try this. This should capture the key enter on your form.
Set "KeyPreview" to true..
void __fastcall TForm1::FormKeyDown(TObject *Sender, char &Key)
{
if(Key == VK_RETURN) //for enter key
IdTCPClient1->Connect();
else
//to do;
}
For Edit1
void __fastcall TForm1::Edit1OnKeyPress(TObject *Sender, char &Key)
{
//check the char for what you want , othrewise set to Key=0
if (!IsNumeric(Key ))
Key = 0;
}
킹코브라 님이 쓰신 글 :
: 채팅 동영상 보면서 채팅프로그램을 만들었는데요..;;
:
: 몇개 보완할려고 합니다;;
:
: //---------------------------------------------------------------------------
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "Unit1.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
: : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
: IdTCPClient1->Connect();
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Button2Click(TObject *Sender)
: {
: IdTCPClient1->WriteLn(Edit1->Text);
: Edit1->Text ="";
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Timer1Timer(TObject *Sender)
: {
: AnsiString stTemp;
: if(IdTCPClient1->Connected() == true){
: stTemp = IdTCPClient1->ReadLn("\n",5);
: if(stTemp.Length() > 0) Memo1->Lines->Add(stTemp);
: }
: }
: //---------------------------------------------------------------------------
:
: '전송' 부분을 일일이 마우스로 클릭하지않고 엔터로 쳐서 채팅창에 출력시키고
: 채팅창에 임의의 글자를 입력하지 않게 하는것
:
: 이 두가지를 해결해 주셨으면 감사하겠습니다.
|