OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_VIEWS_WIDGET_HWND_SUBCLASS_H_ |
| 6 #define UI_VIEWS_WIDGET_HWND_SUBCLASS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <windows.h> |
| 10 |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "ui/base/view_prop.h" |
| 13 #include "ui/gfx/native_widget_types.h" |
| 14 #include "ui/views/views_export.h" |
| 15 |
| 16 namespace views { |
| 17 |
| 18 // An object that instance-subclasses a window. If the window has already been |
| 19 // instance-subclassed, that subclassing is lost. |
| 20 class VIEWS_EXPORT HWNDSubclass { |
| 21 public: |
| 22 explicit HWNDSubclass(HWND target); |
| 23 ~HWNDSubclass(); |
| 24 |
| 25 LRESULT OnWndProc(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param); |
| 26 |
| 27 protected: |
| 28 // A derived class overrides this method to perform filtering of the messages |
| 29 // before the |original_wnd_proc_| sees them. Return true to consume the |
| 30 // message and prevent |original_wnd_proc_| from seeing them at all, false to |
| 31 // allow it to process them. |
| 32 virtual bool FilterMessage(HWND hwnd, |
| 33 UINT message, |
| 34 WPARAM w_param, |
| 35 LPARAM l_param, |
| 36 LRESULT* l_result); |
| 37 |
| 38 private: |
| 39 FRIEND_TEST_ALL_PREFIXES(HWNDSubclassTest, Installation); |
| 40 FRIEND_TEST_ALL_PREFIXES(HWNDSubclassTest, Filtering); |
| 41 |
| 42 static WNDPROC GetClassWndProc(HWND target); |
| 43 static WNDPROC GetCurrentWndProc(HWND target); |
| 44 |
| 45 HWND target_; |
| 46 WNDPROC original_wnd_proc_; |
| 47 ui::ViewProp prop_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(HWNDSubclass); |
| 50 }; |
| 51 |
| 52 } // namespace views |
| 53 |
| 54 #endif // UI_VIEWS_WIDGET_HWND_SUBCLASS_H_ |
OLD | NEW |