Discussion:
disable input in TMemo
(too old to reply)
Zhan Weiming
2008-07-28 07:54:04 UTC
Permalink
Hi there,

In my application, I don't want to user to add new line in the Tmemo
control.

Below are the codes,

void __fastcall TForm1::MemoKeyPress(TObject *Sender, char &Key)
{
if(Key == VK_RETURN)
Key = ' ';
}

the key <return> is replaced with ' '. Actually, I want to make the effect
like users have not input anything at all. Does Key = '\0' work?

Thanks,
Zhan
chenzero
2008-07-28 10:53:46 UTC
Permalink
Hi Weiming,
Post by Zhan Weiming
Hi there,
In my application, I don't want to user to add new line in the Tmemo
control.
Below are the codes,
void __fastcall TForm1::MemoKeyPress(TObject *Sender, char &Key)
{
if(Key == VK_RETURN)
Key = ' ';
}
the key <return> is replaced with ' '. Actually, I want to make the effect
like users have not input anything at all. Does Key = '\0' work?
yes, it works.
another alternative is to set the ReadOnly property of TMemo.
Post by Zhan Weiming
Thanks,
Zhan
Zhan Weiming
2008-07-29 02:57:28 UTC
Permalink
Post by chenzero
another alternative is to set the ReadOnly property of TMemo.
Thanks for your reply. I think ReadOnly doesn't work because I allow user
input characters but the CR.

I found I just need to set the property 'WantReturns' of TMemo to false.
chenzero
2008-07-31 02:27:15 UTC
Permalink
misunderstood something in question, :)
Post by Zhan Weiming
Post by chenzero
another alternative is to set the ReadOnly property of TMemo.
Thanks for your reply. I think ReadOnly doesn't work because I allow user
input characters but the CR.
I found I just need to set the property 'WantReturns' of TMemo to false.
Loading...