1 // Copyright (c) 2009 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.
5 #ifndef TOOLS_MEMORY_WATCHER_HOTKEY_H_
6 #define TOOLS_MEMORY_WATCHER_HOTKEY_H_
8 #include "ui/gfx/rect.h"
9 #include "ui/gfx/win/msg_util.h"
10 #include "ui/gfx/win/window_impl.h"
13 // Programs wishing to register a hotkey can use this.
14 class HotKeyHandler
: public gfx::WindowImpl
{
16 HotKeyHandler(UINT modifiers
, UINT vk
)
17 : modifiers_(modifiers
),
21 ~HotKeyHandler() { Stop(); }
23 CR_BEGIN_MSG_MAP_EX(HotKeyHandler
)
24 CR_MSG_WM_HOTKEY(OnHotKey
)
28 static const int hotkey_id
= 0x0000baba;
31 set_window_style(WS_POPUP
);
32 Init(NULL
, gfx::Rect());
33 return RegisterHotKey(hwnd(), hotkey_id
, modifiers_
, vkey_
) == TRUE
;
37 UnregisterHotKey(hwnd(), hotkey_id
);
38 DestroyWindow(hwnd());
41 // Handle the registered Hotkey being pressed.
42 virtual void OnHotKey(UINT
/*uMsg*/,
44 LPARAM
/*lParam*/) = 0;
50 #endif // TOOLS_MEMORY_WATCHER_HOTKEY_H_