views:

73

answers:

1

Hi everyone hope you're all well. I have a question about memo box behaviour in Delphi, I have an application with two forms, both are dialogs and they both have memo boxes in them and they both have an OK button on them, however one dialog behaves differently from the other - if I am in the memo area and i type something and then press enter, the form closes but in the other form it goes to the next line in the memo (this is how I want it to behave). I don't know how to fix the other form so that pressing enter inside the memo does not close it but makes it go to the next line. I even copied the memo component from the 'good' to the 'bad' form and it still does that, also compared the form properties but they are the same! Any idea why this is happening? I really appreciate your help!

+2  A: 

Two possibilities:

1) The Memo needs to have the WantReturn in order for the memo itself to process the RETURN key.

2) Check any KeyPress/KeyDown/KeyUp handler on the form that doesn't work to see if they process a RETURN key. If the form has KeyPreview=TRUE then the form's keyboard handler will be executed BEFORE the memo's and if the form's keyhandler processes RETURN then the memo will never see it.

HeartWare
Thank you for the reply :) I have checked the WantReturns and they're already set to true, I've removed all key handlers and also checked that the KeyPreview is false...but it still doesn't work! aagh..and the most annoying thing is that it works perfectly in the other form! Have no idea what it could be...there is a 'OK' button on the form but its Defualt property is set to false and its tab order is like 3 so I don't think this could be catching the return key...not so sure
Cassandra87
You'll have to simplify the form on which it doesn't work. There must be one of the other components on the form that interferes. Start by making a full backup of your source files and the try to remove ALL other components other than the Memo. Then run the program/form again and see if it works. It it doesn't, then try to make this simple form the only form of the application and try again. If it still doesn't work, then try to make this simple application available somewhere for download so that other people can take a look at it.
HeartWare