ESCaping from DataWindows

Copyright (C) 1998, Paul Piko

TEXTBLOCK
/*
Techniques to enable ESCAPE key to close datawindows:

1. Include the dispatch method for __FormDialogWindow in your application/library __FormDialogWindow is one of the windows that makes up a datawindow

2. Create a subclass of datawindow (e.g. MyDataWindow), and include a new dispatch method for it (as below)

3. When you create a datawindow in the Window Editor, use the "Inherit from" property to use your new class

4. MultiLineEdits need special handling. Create a subclass of MultiLineEdit (e.g. MyMultiLineEdit) and include the new dispatch method (as below). When you create a window with a multilineedit on it, go to the multilinedit's properties and change the "Inherit from" to the new subclass, e.g. MyMultiLineEdit

5. RichEdits also need special handling. Because there is currently no dispatch method defined for RichEdit we can get away with just defining one as below.

*/
METHOD Dispatch(oE) CLASS __FormDialogWindow
// This is one of the windows that makes
// up a DataWindow

IF oE:message == WM_COMMAND .and. oE:wParam == IDCANCEL

PostMessage(SELF:owner:owner:handle(),WM_CHAR,VK_ESCAPE,0)
RETURN 1L
ENDIF

RETURN SUPER:dispatch(oE)

CLASS MyDataWindow INHERIT DataWindow

METHOD Dispatch(oE) CLASS MyDataWindow
IF oE:message == WM_CHAR .and. oE:wParam == VK_ESCAPE
SELF:endWindow()
RETURN 1L
ENDIF

RETURN SUPER:dispatch(oE)

CLASS MyMultiLineEdit INHERIT MultiLineEdit

METHOD Dispatch(oE) CLASS MyMultiLineEdit
IF oE:message == WM_KEYDOWN .and. oE:wParam == VK_ESCAPE
SendMessage(SELF:owner:handle(),WM_CHAR,VK_ESCAPE,0)
ENDIF
RETURN SUPER:dispatch(oE)

METHOD Dispatch(oE) CLASS RichEdit
IF oE:message == WM_KEYDOWN .and. oE:wParam == VK_ESCAPE
SendMessage(SELF:owner:handle(),WM_CHAR,VK_ESCAPE,0)
ENDIF
RETURN SUPER:dispatch(oE)