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

Side by Side Diff: tools/memory_watcher/hotkey.h

Issue 196081: Use base::WindowImpl instead of CWindowImpl to remove a dependency on ATL.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_MEMORY_WATCHER_HOTKEY_H_ 5 #ifndef TOOLS_MEMORY_WATCHER_HOTKEY_H_
6 #define TOOLS_MEMORY_WATCHER_HOTKEY_H_ 6 #define TOOLS_MEMORY_WATCHER_HOTKEY_H_
7 7
8 #include <atlbase.h> 8 #include "base/gfx/rect.h"
9 #include <atlwin.h> 9 #include "base/window_impl.h"
10 10
11 // HotKey handler. 11 // HotKey handler.
12 // Programs wishing to register a hotkey can use this. 12 // Programs wishing to register a hotkey can use this.
13 class HotKeyHandler : public CWindowImpl<HotKeyHandler> { 13 class HotKeyHandler : public base::WindowImpl {
14 public: 14 public:
15 HotKeyHandler(UINT modifiers, UINT vk) 15 HotKeyHandler(UINT modifiers, UINT vk)
16 : m_modifiers(modifiers), 16 : modifiers_(modifiers),
17 m_vkey(vk) { 17 vkey_(vk) {
18 Start(); 18 Start();
19 } 19 }
20 ~HotKeyHandler() { Stop(); } 20 ~HotKeyHandler() { Stop(); }
21 21
22 BEGIN_MSG_MAP(HotKeyHandler) 22 BEGIN_MSG_MAP_EX(HotKeyHandler)
23 MESSAGE_HANDLER(WM_HOTKEY, OnHotKey) 23 MESSAGE_HANDLER(WM_HOTKEY, OnHotKey)
24 END_MSG_MAP() 24 END_MSG_MAP()
25 25
26 private: 26 private:
27 static const int hotkey_id = 0x0000baba; 27 static const int hotkey_id = 0x0000baba;
28 28
29 bool Start() { 29 bool Start() {
30 if (NULL == Create(NULL, NULL, NULL, WS_POPUP)) 30 set_window_style(WS_POPUP);
31 return false; 31 Init(NULL, gfx::Rect());
32 return RegisterHotKey(m_hWnd, hotkey_id, m_modifiers, m_vkey) == TRUE; 32 return RegisterHotKey(hwnd(), hotkey_id, modifiers_, vkey_) == TRUE;
33 } 33 }
34 34
35 void Stop() { 35 void Stop() {
36 UnregisterHotKey(m_hWnd, hotkey_id); 36 UnregisterHotKey(hwnd(), hotkey_id);
37 DestroyWindow(); 37 DestroyWindow(hwnd());
38 } 38 }
39 39
40 // Handle the registered Hotkey being pressed. 40 // Handle the registered Hotkey being pressed.
41 virtual LRESULT OnHotKey(UINT /*uMsg*/, WPARAM /*wParam*/, 41 virtual LRESULT OnHotKey(UINT /*uMsg*/, WPARAM /*wParam*/,
42 LPARAM /*lParam*/, BOOL& bHandled) = 0; 42 LPARAM /*lParam*/, BOOL& bHandled) = 0;
43 43
44 UINT m_modifiers; 44 UINT modifiers_;
45 UINT m_vkey; 45 UINT vkey_;
46 }; 46 };
47 47
48 #endif // TOOLS_MEMORY_WATCHER_HOTKEY_H_ 48 #endif // TOOLS_MEMORY_WATCHER_HOTKEY_H_
OLDNEW
« no previous file with comments | « no previous file | tools/memory_watcher/memory_watcher.gyp » ('j') | tools/memory_watcher/memory_watcher.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698