From cfe88d2853d7c27e6cb03b31437353b941eef0e1 Mon Sep 17 00:00:00 2001 From: "yoichio@chromium.org" Date: Mon, 3 Sep 2012 05:00:27 +0000 Subject: NativeTextfieldWin uses RichEdit 4.1 which supports TSF API. When TSF awareness is required, we should use Window Class which supports RichEdit 4.1. BUG=137627 Review URL: https://chromiumcodereview.appspot.com/10823253 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154657 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/views/controls/textfield/native_textfield_win.cc | 18 +++++++++++++++--- ui/views/controls/textfield/native_textfield_win.h | 8 +++++--- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'ui') diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc index 6baebf6..73cbf1e 100644 --- a/ui/views/controls/textfield/native_textfield_win.cc +++ b/ui/views/controls/textfield/native_textfield_win.cc @@ -84,7 +84,7 @@ NativeTextfieldWin::ScopedSuspendUndo::~ScopedSuspendUndo() { /////////////////////////////////////////////////////////////////////////////// // NativeTextfieldWin -bool NativeTextfieldWin::did_load_library_ = false; +HMODULE NativeTextfieldWin::loaded_libarary_module_ = false; NativeTextfieldWin::NativeTextfieldWin(Textfield* textfield) : textfield_(textfield), @@ -97,8 +97,11 @@ NativeTextfieldWin::NativeTextfieldWin(Textfield* textfield) ime_composition_length_(0), container_view_(new NativeViewHost), bg_color_(0) { - if (!did_load_library_) - did_load_library_ = !!LoadLibrary(L"riched20.dll"); + if (!loaded_libarary_module_) { + // msftedit.dll is RichEdit ver 4.1. + // This version is available from WinXP SP1 and has TSF support. + loaded_libarary_module_ = LoadLibrary(L"msftedit.dll"); + } DWORD style = kDefaultEditStyle | ES_AUTOHSCROLL; if (textfield_->style() & Textfield::STYLE_OBSCURED) @@ -565,6 +568,15 @@ void NativeTextfieldWin::OnCopy() { } } +LRESULT NativeTextfieldWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { + if (base::win::IsTsfAwareRequired()) { + // Enable TSF support of RichEdit. + SetEditStyle(SES_USECTF, SES_USECTF); + } + SetMsgHandled(FALSE); + return 0; +} + void NativeTextfieldWin::OnCut() { if (textfield_->read_only() || textfield_->IsObscured()) return; diff --git a/ui/views/controls/textfield/native_textfield_win.h b/ui/views/controls/textfield/native_textfield_win.h index acf15a9..513fa52 100644 --- a/ui/views/controls/textfield/native_textfield_win.h +++ b/ui/views/controls/textfield/native_textfield_win.h @@ -44,7 +44,7 @@ class NativeTextfieldWin public NativeTextfieldWrapper, public ui::SimpleMenuModel::Delegate { public: - DECLARE_WND_CLASS(L"ViewsTextfieldEdit"); + DECLARE_WND_SUPERCLASS(L"ViewsTextfieldEdit", MSFTEDIT_CLASS); explicit NativeTextfieldWin(Textfield* parent); ~NativeTextfieldWin(); @@ -119,6 +119,7 @@ class NativeTextfieldWin MSG_WM_CHAR(OnChar) MSG_WM_CONTEXTMENU(OnContextMenu) MSG_WM_COPY(OnCopy) + MSG_WM_CREATE(OnCreate) MSG_WM_CUT(OnCut) MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) MESSAGE_HANDLER_EX(WM_IME_CHAR, OnImeChar) @@ -183,6 +184,7 @@ class NativeTextfieldWin void OnChar(TCHAR key, UINT repeat_count, UINT flags); void OnContextMenu(HWND window, const POINT& point); void OnCopy(); + LRESULT OnCreate(const CREATESTRUCTW* create_struct); void OnCut(); LRESULT OnGetObject(UINT message, WPARAM wparam, LPARAM lparam); LRESULT OnImeChar(UINT message, WPARAM wparam, LPARAM lparam); @@ -250,6 +252,8 @@ class NativeTextfieldWin // Generates the contents of the context menu. void BuildContextMenu(); + static HMODULE loaded_libarary_module_; + // The Textfield this object is bound to. Textfield* textfield_; @@ -269,8 +273,6 @@ class NativeTextfieldWin // If true, the mouse is over the edit. bool contains_mouse_; - static bool did_load_library_; - // The contents of the context menu for the edit. scoped_ptr context_menu_contents_; scoped_ptr context_menu_runner_; -- cgit v1.1