1. 0

Sends text to the CorrectText dialog box to allow the user to edit text using the Japanese Data Input Window. (Japanese version only.)

INT CorrectWritingEx( HWND hwnd, LPSTR lpText, UINT cbText, LPCWX lpcwx )



Handle of the owner of the CorrectText dialog box or writing tool used to edit the text. This can be NULL.


Far pointer to a buffer containing text to correct. This is copied into the Data Input Window's edit control. If lpText is NULL, a WM_GETTEXT message is sent to the text source window, specified by the hwndText member of lpcwx, or if lpcwx or its hwndText member is NULL, to hwnd. On successful exit, a WM_SETTEXT message will be sent to that window with modified text.


Size of the lpText buffer. If the source of the text is an edit control constrained by EM_LIMITTEXT, cbText should reflect that size. If lpText is NULL, the cbText value will be used to limit text if it is greater than zero; otherwise, no limit is used and the returned text may be of arbitrary size.


Address of a CWX structure, or NULL. The structure is used to specify optional correction parameters; for a description of its members, see CWX. If this value is NULL, the following default assumptions are made:

  • The text window is the same as the owner window hwnd.

  • A default recognition context is used.

  • The edit control style is a combination of ES_LEFT and ES_MULTILINE.

  • All text is selected; the caption is "Edit Text".

  • Most recently use values for context flags, keyboard, keyboard states, position, and size are used.

Return Value

If there is a programming or memory error, the negative value CWXR_ERROR is returned. Otherwise, one of the following nonnegative values is returned:

User pressed the OK button.
User pressed the Cancel button, or closed the dialog, or pressed the OK button but did not make any changes to the text.


An application must be sure to initialize the CWX structure properly if it is used. In particular, the cbSize member must be set to sizeof(CWX), and the remaining fields (at least up to dwSel) are typically set to zero.


The following example shows how to initialize and call CorrectWritingEx when a button is pressed in a dialog:

CWX cwx = {sizeof(CWX), 0, NULL, NULL, {0}, 0L, 0L};

cwx.hwndText = GetDlgItem(hdlg, IDD_ETSL); // dialog edit

cwx.dwEditStyle = GetWindowLong(cwx.hwndText, GWL_STYLE)


cwx.dwSel = SendMessage(cwx.hwndText, EM_GETSEL, 0, 0);

_fstrcpy((LPSTR)cwx.szCaption, (LPSTR)"Enter your password:");

// we specify kbd and context, but use MRU placement


// don't update most-recently used settings for this one-shot:

cwx.wApplyFlags |= CWXA_NOUPDATEMRU;

cwx.ixkb = CWXK_QWERTY;


cwx.dwFlags = CWX_NOTOOLTIPS | CWX_TOPMOST; // no distractions

if (CorrectWritingEx(hdlg, NULL, 0, &cwx) != CWXR_MODIFIED)


// validate pwd in the text window etc...

See Also


Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples