diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 20:18:54 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 20:18:54 +0000 |
commit | 0a6dc3a6ca8fd3e0d85a45fc99c646e4c68d1d6a (patch) | |
tree | 8f23cd8372918518ee812a007156497a07a41bb4 /views/controls/native_control_win.cc | |
parent | 5f6791666943fb22e36717050383414136e5e9fc (diff) | |
download | chromium_src-0a6dc3a6ca8fd3e0d85a45fc99c646e4c68d1d6a.zip chromium_src-0a6dc3a6ca8fd3e0d85a45fc99c646e4c68d1d6a.tar.gz chromium_src-0a6dc3a6ca8fd3e0d85a45fc99c646e4c68d1d6a.tar.bz2 |
Reverting 27113, it breaks the ChomeOS build.
TBR=ben
Review URL: http://codereview.chromium.org/231022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/native_control_win.cc')
-rw-r--r-- | views/controls/native_control_win.cc | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/views/controls/native_control_win.cc b/views/controls/native_control_win.cc index 037066c..9f4d2d6 100644 --- a/views/controls/native_control_win.cc +++ b/views/controls/native_control_win.cc @@ -24,9 +24,10 @@ NativeControlWin::NativeControlWin() { NativeControlWin::~NativeControlWin() { HWND hwnd = native_view(); if (hwnd) { - // Destroy the hwnd if it still exists. Otherwise we won't shut things down - // correctly, leading to leaking and crashing if another message comes in - // for the hwnd. + // Destroy the hwnd if it still exists. Otherwise we won't have shut things + // down correctly, leading to leaking and crashing if another message + // comes in for the hwnd. + Detach(); DestroyWindow(hwnd); } } @@ -73,7 +74,9 @@ void NativeControlWin::VisibilityChanged(View* starting_from, bool is_visible) { if (!is_visible) { // We destroy the child control HWND when we become invisible because of the // performance cost of maintaining many HWNDs. - DestroyWindow(native_view()); + HWND hwnd = native_view(); + Detach(); + DestroyWindow(hwnd); } else if (!native_view()) { if (GetWidget()) CreateNativeControl(); @@ -114,14 +117,14 @@ void NativeControlWin::NativeControlCreated(HWND native_control) { // Note that we never unset this property. We don't have to. SetProp(native_control, kNativeControlWinKey, this); - Attach(native_control); - // native_view() is now valid. - - // Subclass so we get WM_KEYDOWN message. + // Subclass so we get WM_KEYDOWN and WM_SETFOCUS messages. original_wndproc_ = win_util::SetWindowProc(native_control, &NativeControlWin::NativeControlWndProc); + Attach(native_control); + // native_view() is now valid. + // Update the newly created HWND with any resident enabled state. EnableWindow(native_view(), IsEnabled()); @@ -183,10 +186,16 @@ LRESULT NativeControlWin::NativeControlWndProc(HWND window, if (message == WM_KEYDOWN && native_control->OnKeyDown(static_cast<int>(w_param))) { return 0; + } else if (message == WM_SETFOCUS) { + // Let the focus manager know that the focus changed. + FocusManager* focus_manager = native_control->GetFocusManager(); + if (focus_manager) { + focus_manager->SetFocusedView(native_control->focus_view()); + } else { + NOTREACHED(); + } } else if (message == WM_DESTROY) { - WNDPROC old_wndproc = - win_util::SetWindowProc(window, native_control->original_wndproc_); - DCHECK(old_wndproc == &NativeControlWin::NativeControlWndProc); + win_util::SetWindowProc(window, native_control->original_wndproc_); } return CallWindowProc(native_control->original_wndproc_, window, message, |