OLD | NEW |
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 #include "base/win_util.h" | 5 #include "base/win_util.h" |
6 | 6 |
7 #include <sddl.h> | 7 #include <sddl.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/registry.h" | 10 #include "base/registry.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 250 } |
251 | 251 |
252 void* GetWindowUserData(HWND hwnd) { | 252 void* GetWindowUserData(HWND hwnd) { |
253 return reinterpret_cast<void*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); | 253 return reinterpret_cast<void*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); |
254 } | 254 } |
255 | 255 |
256 // Maps to the WNDPROC for a window that was active before the subclass was | 256 // Maps to the WNDPROC for a window that was active before the subclass was |
257 // installed. | 257 // installed. |
258 static const wchar_t* const kHandlerKey = L"__ORIGINAL_MESSAGE_HANDLER__"; | 258 static const wchar_t* const kHandlerKey = L"__ORIGINAL_MESSAGE_HANDLER__"; |
259 | 259 |
| 260 bool IsSubclassed(HWND window, WNDPROC subclass_proc) { |
| 261 WNDPROC original_handler = |
| 262 reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC)); |
| 263 return original_handler == subclass_proc; |
| 264 } |
| 265 |
260 bool Subclass(HWND window, WNDPROC subclass_proc) { | 266 bool Subclass(HWND window, WNDPROC subclass_proc) { |
261 WNDPROC original_handler = | 267 WNDPROC original_handler = |
262 reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC)); | 268 reinterpret_cast<WNDPROC>(GetWindowLongPtr(window, GWLP_WNDPROC)); |
263 if (original_handler != subclass_proc) { | 269 if (original_handler != subclass_proc) { |
264 win_util::SetWindowProc(window, subclass_proc); | 270 win_util::SetWindowProc(window, subclass_proc); |
265 SetProp(window, kHandlerKey, original_handler); | 271 SetProp(window, kHandlerKey, original_handler); |
266 return true; | 272 return true; |
267 } | 273 } |
268 return false; | 274 return false; |
269 } | 275 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 377 |
372 #ifndef COPY_FILE_COPY_SYMLINK | 378 #ifndef COPY_FILE_COPY_SYMLINK |
373 #error You must install the Windows 2008 or Vista Software Development Kit and \ | 379 #error You must install the Windows 2008 or Vista Software Development Kit and \ |
374 set it as your default include path to build this library. You can grab it by \ | 380 set it as your default include path to build this library. You can grab it by \ |
375 searching for "download windows sdk 2008" in your favorite web search engine. \ | 381 searching for "download windows sdk 2008" in your favorite web search engine. \ |
376 Also make sure you register the SDK with Visual Studio, by selecting \ | 382 Also make sure you register the SDK with Visual Studio, by selecting \ |
377 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ | 383 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ |
378 menu (see Start - All Programs - Microsoft Windows SDK - \ | 384 menu (see Start - All Programs - Microsoft Windows SDK - \ |
379 Visual Studio Registration). | 385 Visual Studio Registration). |
380 #endif | 386 #endif |
OLD | NEW |