OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 REMOTING_HOST_WIN_MESSAGE_WINDOW_H_ |
| 6 #define REMOTING_HOST_WIN_MESSAGE_WINDOW_H_ |
| 7 |
| 8 #include <windows.h> |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
| 14 #include "base/threading/non_thread_safe.h" |
| 15 |
| 16 namespace remoting { |
| 17 namespace win { |
| 18 |
| 19 // Implements a message-only window. |
| 20 class MessageWindow : base::NonThreadSafe { |
| 21 public: |
| 22 // Handles incoming window messages. |
| 23 class Delegate { |
| 24 public: |
| 25 virtual ~Delegate() {} |
| 26 |
| 27 virtual bool HandleMessage(UINT message, WPARAM wparam, LPARAM lparam, |
| 28 LRESULT* result) = 0; |
| 29 }; |
| 30 |
| 31 MessageWindow(); |
| 32 MessageWindow(const std::string& class_name, HINSTANCE instance); |
| 33 ~MessageWindow(); |
| 34 |
| 35 // Registers the window class and creates the window. The incoming messages |
| 36 // will be handled by |delegate|. |delegate| must outlive |this|. |
| 37 bool Create(Delegate* delegate); |
| 38 |
| 39 HWND hwnd() const { return window_; } |
| 40 |
| 41 private: |
| 42 // Invoked by the OS to process incoming window messages. |
| 43 static LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, |
| 44 LPARAM lparam); |
| 45 |
| 46 // Atom representing the registered window class. |
| 47 ATOM atom_; |
| 48 |
| 49 // MessageWindow class name. |
| 50 std::string class_name_; |
| 51 |
| 52 // Instance of the module containing the window procedure. |
| 53 HINSTANCE instance_; |
| 54 |
| 55 // Handle of the input window. |
| 56 HWND window_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(MessageWindow); |
| 59 }; |
| 60 |
| 61 } // namespace win |
| 62 } // namespace remoting |
| 63 |
| 64 #endif // REMOTING_HOST_WIN_MESSAGE_WINDOW_H_ |
OLD | NEW |