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

Unified 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 10 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/win/hwnd_util.h ('k') | app/win/scoped_prop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/win/hwnd_util.cc
===================================================================
--- app/win/hwnd_util.cc (revision 0)
+++ app/win/hwnd_util.cc (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "app/win/hwnd_util.h"
+
+#include "base/string_util.h"
+
+namespace app {
+namespace win {
+
+string16 GetClassName(HWND window) {
+ // GetClassNameW will return a truncated result (properly null terminated) if
+ // the given buffer is not large enough. So, it is not possible to determine
+ // that we got the entire class name if the result is exactly equal to the
+ // size of the buffer minus one.
+ DWORD buffer_size = MAX_PATH;
+ while (true) {
+ std::wstring output;
+ DWORD size_ret =
+ GetClassNameW(window, WriteInto(&output, buffer_size), buffer_size);
+ if (size_ret == 0)
+ break;
+ if (size_ret < (buffer_size - 1)) {
+ output.resize(size_ret);
+ return output;
+ }
+ buffer_size *= 2;
+ }
+ return std::wstring(); // error
+}
+
+#pragma warning(push)
+#pragma warning(disable:4312 4244)
+
+WNDPROC SetWindowProc(HWND hwnd, WNDPROC proc) {
+ // The reason we don't return the SetwindowLongPtr() value is that it returns
+ // the orignal window procedure and not the current one. I don't know if it is
+ // a bug or an intended feature.
+ WNDPROC oldwindow_proc =
+ reinterpret_cast<WNDPROC>(GetWindowLongPtr(hwnd, GWLP_WNDPROC));
+ SetWindowLongPtr(hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(proc));
+ return oldwindow_proc;
+}
+
+void* SetWindowUserData(HWND hwnd, void* user_data) {
+ return
+ reinterpret_cast<void*>(SetWindowLongPtr(hwnd, GWLP_USERDATA,
+ reinterpret_cast<LONG_PTR>(user_data)));
+}
+
+void* GetWindowUserData(HWND hwnd) {
+ return reinterpret_cast<void*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
+}
+
+#pragma warning(pop)
+
+} // namespace win
+} // namespace app
« 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