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

Unified Diff: ui/views/widget/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, 8 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/hwnd_subclass.h
===================================================================
--- ui/views/widget/hwnd_subclass.h (revision 0)
+++ ui/views/widget/hwnd_subclass.h (revision 0)
@@ -0,0 +1,54 @@
+// 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_VIEWS_WIDGET_HWND_SUBCLASS_H_
+#define UI_VIEWS_WIDGET_HWND_SUBCLASS_H_
+#pragma once
+
+#include <windows.h>
+
+#include "base/gtest_prod_util.h"
+#include "ui/base/view_prop.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/views/views_export.h"
+
+namespace views {
+
+// An object that instance-subclasses a window. If the window has already been
+// instance-subclassed, that subclassing is lost.
+class VIEWS_EXPORT HWNDSubclass {
+ public:
+ explicit HWNDSubclass(HWND target);
+ ~HWNDSubclass();
+
+ LRESULT OnWndProc(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param);
+
+ protected:
+ // 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);
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(HWNDSubclassTest, Installation);
+ FRIEND_TEST_ALL_PREFIXES(HWNDSubclassTest, Filtering);
+
+ static WNDPROC GetClassWndProc(HWND target);
+ static WNDPROC GetCurrentWndProc(HWND target);
+
+ HWND target_;
+ WNDPROC original_wnd_proc_;
+ ui::ViewProp prop_;
+
+ DISALLOW_COPY_AND_ASSIGN(HWNDSubclass);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_WIDGET_HWND_SUBCLASS_H_
Property changes on: ui\views\widget\hwnd_subclass.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698