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_BASE_WIN_HWND_SUBCLASS_H_ |
| 6 #define UI_BASE_WIN_HWND_SUBCLASS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <windows.h> |
| 10 |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/base/ui_export.h" |
| 14 #include "ui/base/view_prop.h" |
| 15 |
| 16 namespace ui { |
| 17 |
| 18 // Classes implementing this interface get the opportunity to handle and consume |
| 19 // messages before they are sent to their target HWND. |
| 20 class UI_EXPORT HWNDMessageFilter { |
| 21 public: |
| 22 virtual ~HWNDMessageFilter() {} |
| 23 |
| 24 // A derived class overrides this method to perform filtering of the messages |
| 25 // before the |original_wnd_proc_| sees them. Return true to consume the |
| 26 // message and prevent |original_wnd_proc_| from seeing them at all, false to |
| 27 // allow it to process them. |
| 28 virtual bool FilterMessage(HWND hwnd, |
| 29 UINT message, |
| 30 WPARAM w_param, |
| 31 LPARAM l_param, |
| 32 LRESULT* l_result) = 0; |
| 33 }; |
| 34 |
| 35 // An object that instance-subclasses a window. If the window has already been |
| 36 // instance-subclassed, that subclassing is lost. |
| 37 class UI_EXPORT HWNDSubclass { |
| 38 public: |
| 39 explicit HWNDSubclass(HWND target); |
| 40 ~HWNDSubclass(); |
| 41 |
| 42 // HWNDSubclass takes ownership of the filter. |
| 43 void SetFilter(HWNDMessageFilter* filter); |
| 44 |
| 45 LRESULT OnWndProc(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param); |
| 46 |
| 47 private: |
| 48 HWND target_; |
| 49 scoped_ptr<HWNDMessageFilter> filter_; |
| 50 WNDPROC original_wnd_proc_; |
| 51 ui::ViewProp prop_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(HWNDSubclass); |
| 54 }; |
| 55 |
| 56 } // namespace ui |
| 57 |
| 58 #endif // UI_BASE_WIN_HWND_SUBCLASS_H_ |
OLD | NEW |