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

Side by Side Diff: app/win/hwnd_util.cc

Issue 6019007: Remove win_util::FormatMessage and FormatLastWin32Error. These were only used... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 12 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
« no previous file with comments | « app/win/hwnd_util.h ('k') | app/win/scoped_prop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include "app/win/hwnd_util.h"
6
7 #include "base/string_util.h"
8
9 namespace app {
10 namespace win {
11
12 string16 GetClassName(HWND window) {
13 // GetClassNameW will return a truncated result (properly null terminated) if
14 // the given buffer is not large enough. So, it is not possible to determine
15 // that we got the entire class name if the result is exactly equal to the
16 // size of the buffer minus one.
17 DWORD buffer_size = MAX_PATH;
18 while (true) {
19 std::wstring output;
20 DWORD size_ret =
21 GetClassNameW(window, WriteInto(&output, buffer_size), buffer_size);
22 if (size_ret == 0)
23 break;
24 if (size_ret < (buffer_size - 1)) {
25 output.resize(size_ret);
26 return output;
27 }
28 buffer_size *= 2;
29 }
30 return std::wstring(); // error
31 }
32
33 #pragma warning(push)
34 #pragma warning(disable:4312 4244)
35
36 WNDPROC SetWindowProc(HWND hwnd, WNDPROC proc) {
37 // The reason we don't return the SetwindowLongPtr() value is that it returns
38 // the orignal window procedure and not the current one. I don't know if it is
39 // a bug or an intended feature.
40 WNDPROC oldwindow_proc =
41 reinterpret_cast<WNDPROC>(GetWindowLongPtr(hwnd, GWLP_WNDPROC));
42 SetWindowLongPtr(hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(proc));
43 return oldwindow_proc;
44 }
45
46 void* SetWindowUserData(HWND hwnd, void* user_data) {
47 return
48 reinterpret_cast<void*>(SetWindowLongPtr(hwnd, GWLP_USERDATA,
49 reinterpret_cast<LONG_PTR>(user_data)));
50 }
51
52 void* GetWindowUserData(HWND hwnd) {
53 return reinterpret_cast<void*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
54 }
55
56 #pragma warning(pop)
57
58 } // namespace win
59 } // namespace app
OLDNEW
« no previous file with comments | « app/win/hwnd_util.h ('k') | app/win/scoped_prop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698