summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/base/win/window_impl.cc21
-rw-r--r--views/widget/widget_win.cc17
2 files changed, 35 insertions, 3 deletions
diff --git a/ui/base/win/window_impl.cc b/ui/base/win/window_impl.cc
index 0f48b89..1d2c55b 100644
--- a/ui/base/win/window_impl.cc
+++ b/ui/base/win/window_impl.cc
@@ -144,10 +144,27 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) {
height = bounds.height();
}
- hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), NULL,
+ std::wstring name(GetWindowClassName());
+ hwnd_ = CreateWindowEx(window_ex_style_, name.c_str(), NULL,
window_style_, x, y, width, height,
parent, NULL, NULL, this);
- CHECK(hwnd_);
+ if (!hwnd_) {
+ LPWSTR error_string = NULL;
+ DWORD last_error = GetLastError();
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ 0, // Use the internal message table.
+ last_error,
+ 0, // Use default language.
+ reinterpret_cast<LPWSTR>(&error_string),
+ 0, // Buffer size.
+ 0); // Arguments (unused).
+ CHECK(false) << "Create failed error=" << last_error <<
+ " message=" << error_string << " name=" << name << " style=" <<
+ window_style_ << " ex_style=" << window_ex_style_;
+ if (error_string)
+ LocalFree(error_string);
+ }
// The window procedure should have set the data for us.
CHECK_EQ(this, ui::GetWindowUserData(hwnd_));
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 8596ef2..05ba37d 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -6,7 +6,9 @@
#include <dwmapi.h>
+#include "base/string_number_conversions.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drag_source.h"
@@ -607,8 +609,21 @@ void WidgetWin::OnCommand(UINT notification_code, int command_id, HWND window) {
}
LRESULT WidgetWin::OnCreate(CREATESTRUCT* create_struct) {
+ // Debugging code to help track 77651.
CHECK(hwnd());
- CHECK(ui::WindowImpl::IsWindowImpl(hwnd()));
+ if (!ui::WindowImpl::IsWindowImpl(hwnd())) {
+ std::wstring class_name;
+ wchar_t tmp[128];
+ if (!::GetClassName(hwnd(), tmp, 128)) {
+ class_name = L"unable to get class name error=" +
+ UTF8ToWide(base::IntToString(GetLastError()));
+ } else {
+ class_name = std::wstring(tmp);
+ }
+
+ CHECK(false) << " Not a window impl, hwnd=" << hwnd() <<
+ " class_name=" << class_name << " is_window=" << ::IsWindow(hwnd());
+ }
SetNativeWindowProperty(kNativeWidgetKey, this);
CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd()));