[1/3] riched20: Implement handling of WM_KEYDOWN VK_RETURN in a dialog mode.

Dylan Smith dylan.ah.smith at gmail.com
Tue Sep 1 07:33:54 CDT 2009


On Tue, Sep 1, 2009 at 4:18 AM, Sergey Khodych <khodych at gmail.com> wrote:
> @@ -2145,6 +2145,31 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
>       ME_SendRequestResize(editor, FALSE);
>       return TRUE;
>     case VK_RETURN:
> +      if (editor->bDialogMode)
> +      {
> +        DWORD dwStyle;
> +
> +        if (ctrl_is_down)
> +          return TRUE;
> +
> +        dwStyle = GetWindowLongW(editor->hWnd, GWL_STYLE);
> +        if (!(dwStyle & ES_WANTRETURN))
> +        {
> +          DWORD dw;
> +          dw = SendMessageW(editor->hwndParent, DM_GETDEFID, 0, 0);
> +          if (HIWORD(dw) == DC_HASDEFID)
> +          {
> +              HWND hwDefCtrl = GetDlgItem(editor->hwndParent, LOWORD(dw));
> +              if (hwDefCtrl)
> +              {
> +                  SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, (LPARAM)TRUE);
> +                  PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
> +              }
> +          }
> +          return TRUE;
> +        }
> +      }
> +
>       if (editor->styleFlags & ES_MULTILINE)
>       {
>         ME_Cursor cursor = editor->pCursors[0];

1. editor->hWnd may be NULL for windowless richedit controls, but you
code doesn't seem to take that into consideration.
2. The style flags that you get from GetWindowLongW should probably
come from the cached values in editor->styleFlags.
3. Is there any need for storing the hwndParent in editor.  Couldn't
the value be obtained by using GetWindowLongW using GWL_HWNDPARENT
after making sure that editor->hWnd is non-NULL (i.e. windowed mode).



More information about the wine-devel mailing list