Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/win/hwnd_subclass.h" | 5 #include "ui/base/win/hwnd_subclass.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/base/win/hwnd_util.h" | 8 #include "ui/base/win/hwnd_util.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 namespace ui { | 33 namespace ui { |
| 34 | 34 |
| 35 HWNDSubclass::HWNDSubclass(HWND target) | 35 HWNDSubclass::HWNDSubclass(HWND target) |
| 36 : target_(target), | 36 : target_(target), |
| 37 original_wnd_proc_(GetCurrentWndProc(target)), | 37 original_wnd_proc_(GetCurrentWndProc(target)), |
| 38 ALLOW_THIS_IN_INITIALIZER_LIST(prop_(target, kHWNDSubclassKey, this)) { | 38 ALLOW_THIS_IN_INITIALIZER_LIST(prop_(target, kHWNDSubclassKey, this)) { |
| 39 ui::SetWindowProc(target_, &WndProc); | 39 ui::SetWindowProc(target_, &WndProc); |
| 40 } | 40 } |
| 41 | 41 |
| 42 HWNDSubclass::~HWNDSubclass() { | 42 HWNDSubclass::~HWNDSubclass() { |
| 43 ui::SetWindowProc(target_, original_wnd_proc_); | |
|
Ben Goodger (Google)
2012/05/22 23:05:48
this is actually intentionally not done. the issue
jianli
2012/05/22 23:34:04
Done.
| |
| 43 } | 44 } |
| 44 | 45 |
| 45 void HWNDSubclass::SetFilter(HWNDMessageFilter* filter) { | 46 void HWNDSubclass::SetFilter(HWNDMessageFilter* filter) { |
| 46 filter_.reset(filter); | 47 filter_.reset(filter); |
| 47 } | 48 } |
| 48 | 49 |
| 49 LRESULT HWNDSubclass::OnWndProc(HWND hwnd, | 50 LRESULT HWNDSubclass::OnWndProc(HWND hwnd, |
| 50 UINT message, | 51 UINT message, |
| 51 WPARAM w_param, | 52 WPARAM w_param, |
| 52 LPARAM l_param) { | 53 LPARAM l_param) { |
| 53 if (filter_.get()) { | 54 if (filter_.get()) { |
| 54 LRESULT l_result = 0; | 55 LRESULT l_result = 0; |
| 55 if (filter_->FilterMessage(hwnd, message, w_param, l_param, &l_result)) | 56 if (filter_->FilterMessage(hwnd, message, w_param, l_param, &l_result)) |
| 56 return l_result; | 57 return l_result; |
| 57 } | 58 } |
| 58 | 59 |
| 59 // In most cases, |original_wnd_proc_| will take care of calling | 60 // In most cases, |original_wnd_proc_| will take care of calling |
| 60 // DefWindowProc. | 61 // DefWindowProc. |
| 61 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param); | 62 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param); |
| 62 } | 63 } |
| 63 | 64 |
| 64 } // namespace ui | 65 } // namespace ui |
| OLD | NEW |