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