Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 // Originally from libjingle. Minor alterations to compile it in Chrome. | 5 // Originally from libjingle. Minor alterations to compile it in Chrome. |
| 6 | 6 |
| 7 #include "talk/base/win32window.h" | |
| 8 #include "base/logging.h" | |
|
brg
2009/09/23 18:14:26
You are missing a blank line betwixt this modules
ncarter (slow)
2009/09/23 20:28:36
Done.
| |
| 7 #include "talk/base/common.h" | 9 #include "talk/base/common.h" |
| 8 #include "talk/base/logging.h" | |
| 9 #include "talk/base/win32window.h" | |
| 10 | 10 |
| 11 namespace talk_base { | 11 namespace talk_base { |
| 12 | 12 |
| 13 /////////////////////////////////////////////////////////////////////////////// | 13 /////////////////////////////////////////////////////////////////////////////// |
| 14 // Win32Window | 14 // Win32Window |
| 15 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
| 16 | 16 |
| 17 static const wchar_t kWindowBaseClassName[] = L"WindowBaseClass"; | 17 static const wchar_t kWindowBaseClassName[] = L"WindowBaseClass"; |
| 18 HINSTANCE instance_ = GetModuleHandle(NULL); | 18 HINSTANCE instance_ = GetModuleHandle(NULL); |
| 19 ATOM window_class_ = 0; | 19 ATOM window_class_ = 0; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 35 if (!window_class_) { | 35 if (!window_class_) { |
| 36 // Class not registered, register it. | 36 // Class not registered, register it. |
| 37 WNDCLASSEX wcex; | 37 WNDCLASSEX wcex; |
| 38 memset(&wcex, 0, sizeof(wcex)); | 38 memset(&wcex, 0, sizeof(wcex)); |
| 39 wcex.cbSize = sizeof(wcex); | 39 wcex.cbSize = sizeof(wcex); |
| 40 wcex.hInstance = instance_; | 40 wcex.hInstance = instance_; |
| 41 wcex.lpfnWndProc = &Win32Window::WndProc; | 41 wcex.lpfnWndProc = &Win32Window::WndProc; |
| 42 wcex.lpszClassName = kWindowBaseClassName; | 42 wcex.lpszClassName = kWindowBaseClassName; |
| 43 window_class_ = ::RegisterClassEx(&wcex); | 43 window_class_ = ::RegisterClassEx(&wcex); |
| 44 if (!window_class_) { | 44 if (!window_class_) { |
| 45 LOG_GLE(LS_ERROR) << "RegisterClassEx failed"; | 45 LOG(ERROR) << "RegisterClassEx failed: " << GetLastError(); |
| 46 return false; | 46 return false; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 wnd_ = ::CreateWindowEx(exstyle, kWindowBaseClassName, title, style, | 49 wnd_ = ::CreateWindowEx(exstyle, kWindowBaseClassName, title, style, |
| 50 x, y, cx, cy, parent, NULL, instance_, this); | 50 x, y, cx, cy, parent, NULL, instance_, this); |
| 51 return (NULL != wnd_); | 51 return (NULL != wnd_); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void Win32Window::Destroy() { | 54 void Win32Window::Destroy() { |
| 55 VERIFY(::DestroyWindow(wnd_) != FALSE); | 55 VERIFY(::DestroyWindow(wnd_) != FALSE); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 that = static_cast<Win32Window*>(cs->lpCreateParams); | 90 that = static_cast<Win32Window*>(cs->lpCreateParams); |
| 91 that->wnd_ = hwnd; | 91 that->wnd_ = hwnd; |
| 92 ::SetWindowLongPtr(hwnd, GWL_USERDATA, reinterpret_cast<LONG_PTR>(that)); | 92 ::SetWindowLongPtr(hwnd, GWL_USERDATA, reinterpret_cast<LONG_PTR>(that)); |
| 93 } | 93 } |
| 94 if (that) { | 94 if (that) { |
| 95 LRESULT result; | 95 LRESULT result; |
| 96 bool handled = that->OnMessage(uMsg, wParam, lParam, result); | 96 bool handled = that->OnMessage(uMsg, wParam, lParam, result); |
| 97 if (WM_DESTROY == uMsg) { | 97 if (WM_DESTROY == uMsg) { |
| 98 for (HWND child = ::GetWindow(hwnd, GW_CHILD); child; | 98 for (HWND child = ::GetWindow(hwnd, GW_CHILD); child; |
| 99 child = ::GetWindow(child, GW_HWNDNEXT)) { | 99 child = ::GetWindow(child, GW_HWNDNEXT)) { |
| 100 LOG(LS_INFO) << "Child window: " << static_cast<void*>(child); | 100 LOG(INFO) << "Child window: " << static_cast<void*>(child); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 if (WM_NCDESTROY == uMsg) { | 103 if (WM_NCDESTROY == uMsg) { |
| 104 ::SetWindowLongPtr(hwnd, GWL_USERDATA, NULL); | 104 ::SetWindowLongPtr(hwnd, GWL_USERDATA, NULL); |
| 105 that->wnd_ = NULL; | 105 that->wnd_ = NULL; |
| 106 that->OnDestroyed(); | 106 that->OnDestroyed(); |
| 107 } | 107 } |
| 108 if (handled) { | 108 if (handled) { |
| 109 return result; | 109 return result; |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 return ::DefWindowProc(hwnd, uMsg, wParam, lParam); | 112 return ::DefWindowProc(hwnd, uMsg, wParam, lParam); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace talk_base | 115 } // namespace talk_base |
| OLD | NEW |