The form is closing when pressing Enter in Grid or Textbox

Started by Fred Tomke, December 06, 2009, 03:13:11 PM

Previous topic - Next topic

Fred Tomke

Question: How can I prevent the form from closing when the cursor is in Grid or Textbox control and I push Enter key?

Answer: You can use the OnCancelClose event to prevent the form from closing after pushing Enter key in Grid control or Textbox. The returning value of the event function has to be T if the form should not be closed. Note, that you have to make sure that there's at least one way to close the form. Calling dcl_form_close does not release OnCancelClose.

Code (autolisp) Select

(defun c:MyProject_MyForm_OnCancelClose (intIsESC)
  ;; intIsESC = 1 when ESC key was pressed, the closing button in the titlebar was clicked
  (/= intIsESC 1)
); c:MyProject_MyForm_OnCancelClose


In the attachment there is a more complex sample for grid and textbox.
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]