Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: ui/base/win/hwnd_subclass.h

Issue 10256008: Adds a class that makes it easy to subclass a HWND and filter messages sent to it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/win/hwnd_subclass.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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_
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_unittest.cc ('k') | ui/base/win/hwnd_subclass.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698