TE Edit Control Win32 / Win64 Help
Product page

Message Communication

Your application can communicate with the TER editor using the following three methods:

Application Interface Functions

Process messages from the editor

Send messages to the editor

The chapter on Application Interface Functions describes the application interface functions. This chapter describes the remaining two methods of communication.

Process Messages from the Editor

The TER editor sends certain messages to your application window. To receive these messages, you must have assigned a valid window handle to the hParentWnd variable within the parameter structure (see Getting Started).

TER_MODIFIEDThis message is sent to your application window when the editor data is modified the first time. The wParam contains the handle of the TER window. The lParam variable is not used. Your application window can grab this message and take any necessary action.
TER_CLOSEThis message is sent to your application window before a TER window is closed. The wParam contains the handle of the TER window. The lParam variable is not used. Upon receiving this message, your application can retrieve the modified text buffer by using the GetTerBuffer function.
TER_DRAGThis message is sent before text drag/drop is begun from an external application, or from within the editor.
TER_BERORE_DROPThis message is sent immediately before the text is dropped from an external application, or from within the editor.
TER_DROPThis message is sent when text is dropped from an external application, or from within the editor.
TER_NOT_SAVEDYour application received this message when the user exits the editor without saving the modifications. This message is always followed by the 'TER_CLOSE' message.
TER_MERGEPlease refer to the 'Mail/Merge Support' chapter for the description of this message.
TER_UPDATE_TOOLBARThis message notifies your application to update any external toolbar the application might be using.
TER_UPDATE_STATUSBARThis message notifies your application to update any external status bar the application might be using.
TER_ACTION:

This message is sent after an user initiated action is completed. This message uses the following parameters:

wParam (or ActionType): This parameter can be one of the following:

ACTION_COMMAND:This action indicates any of the menu or the accelerator key generated commands. The actual command id is given by the lParam (or ActionId) argument. For a list of command ids, please refer to the 'command' property in the Visual Basic Interface chapter.
ACTION_VSCROLL:This action message is sent when the vertical scroll bar is clicked. The 'lParam' argument for this message identifies the actual scrollbar operation and is given by the SB_xxxxx SDK constants.
ACTION_HSCROLL:This action message is sent when the horizontal scroll bar is clicked. The 'lParam' argument for this message identifies the actual scrollbar operation and is given by the SB_xxxxx SDK constants.
ACTION_CHAR:This action message is sent when the editor processes a WM_CHAR message. The 'lParam' argument for this message indicates the virtual key code for the key.
ACTION_CHECKBOX

All message posted by Windows to the checkbox input field is sent to your application using ACTION_CHECKBOX. The high 16 bits of the lParam parameter provides the check-box control id, and the low 16 bits of the lParam provides the windows message id (such as WM_CHAR, WM_LBUTTONDOWN, etc).

The control-id returned by this message can be used with the check-box input field APIs to retrieve or set new information for the check-box.

lParam (or ActionId): This value is specific to the action type as described above.

TER_PREPROCESS:

This message is sent before a message is processed by the editor. This message uses the following parameters:

wParam (or ActionType): This parameter can be one of the following:

ACTION_COMMAND:See TER_ACTION message for description.
ACTION_VSCROLL:See TER_ACTION message for description.
ACTION_HSCROLLSee TER_ACTION message for description.
ACTION_CHAR:See TER_ACTION message for description.
ACTION_LBUTTONDOWNLeft mouse button down. The ActionId contains the x and y mouse position in the pixel units. The x position is given by the low 16 bits and the y position is given by the high 16 bits.
ACTION_RBUTTONDOWN:Right mouse button down. The ActionId parameter holds the mouse position as described for the ACTION_LBUTTONDOWN message.
ACTION_LBUTTONUP:Left mouse button up. The ActionId parameter holds the mouse position as described for the ACTION_LBUTTONDOWN message.
ACTION_RBUTTONUP:Right mouse button up. The ActionId parameter holds the mouse position as described for the ACTION_LBUTTONDOWN message.
ACTION_LBUTTONDBLCLICK:Left mouse double click. The ActionId parameter holds the mouse position as described for the ACTION_LBUTTONDOWN message.
ACTION_RBUTTONDBLCLICK:Right mouse double click. The ActionId parameter holds the mouse position as described for the ACTION_LBUTTONDOWN message.
ACTION_MOUSEMOVE:Mouse move. The ActionId contains the x and y mouse position in the pixel units. The x position is given by the low 16 bits and the y position is given by the high 16 bits.
ACTION_SIZE:Window being resized.
ACTION_SETFOCUS:Ter window receiving focus.
ACTION_KILLFOCUS:Ter window loosing focus.
ACTION_QUERYENDSESSIONThis message is sent before asking the user to end the editing session.

lParam (or ActionId): This value is specific to the action type as described above.

See Also: TerIgnoreCommand

TER_PAGE_SIZE_CHANGING:

This message is sent before TE adjusts the page size.

The wParam parameter contains the handle of the TE control window. The lParam parameter contains the pointer to the suggested new page size.

This event is fired only when the TFLAG5_VARIABLE_PAGE_SIZE flag is set. When this flag is set, TE calculates the new page size to contain the entire content of the control. Then the control fires this event to allow your application to override or modified the suggested page size. The page size is provided by the 'NewPageSize' parameter in the twips unit (lParam contains the pointer to new page size variable).

You can set the 'NewPageSize' parameter to 0 to disable the current page adjustment. You can also set it to another value to make the page bigger than the suggested size. However, you can not set this parameter to a lower value because TE needs to display the entire content on one page.

Send Messages to the Editor

Your application can initiate an editor action by sending the appropriate message. This method is especially useful when the editor menu is disabled, or the TER editor window is used as a child window (WS_CHILD style).

Your application module that will be communicating with the editor should include the TER_CMD.H file. This file contains the message constants.

The messages are sent using the WM_COMMAND message. The TerWndProc function in the TER.C file processes these messages. You can refer to this function also for a brief description of each message.

Example:

#include "TER_CMD.H"
SendMessage(hTextWnd,WM_COMMAND,ID_SAVE,0L);

This message instructs the TER window (hTerWnd) to save (ID_SAVE) the current file. The ID_SAVE constant is defined in the TER_CMD.H file.