We are adding an ASCII editor to our application, and we are using TRichEdit in Delphi XE7. We need to display the Row and Column in the status bar, but have not found any code that works with the Key down function. The code below is the current code we are using. The code below works perfect with the mouse down, but the key down is not consistent.
Row := SendMessage(asciieditor.Handle, EM_LINEFROMCHAR, asciieditor.SelStart, 0);
Col := asciieditor.SelStart - SendMessage(asciieditor.Handle, EM_LINEINDEX, Row, 0);
SelStartis not where you are expecting. Try delaying the calculation until after theOnKeyDownevent has exited. Or useOnKeyUpinstead. Though, for something like this task, I would probably create aTActionand assign anOnUpdateevent to it to keep the status bar updated. ActionOnUpdateevents are fired whenever the app goes idle after message processing. Or, just use theTApplication(Events).OnIdleevent.OnMouseDownevent).