| 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 "views/controls/native_control.h" | 5 #include "views/controls/native_control.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlapp.h> | 8 #include <atlapp.h> |
| 9 #include <atlcrack.h> | 9 #include <atlcrack.h> |
| 10 #include <atlframe.h> | 10 #include <atlframe.h> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void OnFinalMessage(HWND hwnd) { | 74 void OnFinalMessage(HWND hwnd) { |
| 75 if (parent_) | 75 if (parent_) |
| 76 parent_->NativeControlDestroyed(); | 76 parent_->NativeControlDestroyed(); |
| 77 delete this; | 77 delete this; |
| 78 } | 78 } |
| 79 private: | 79 private: |
| 80 | 80 |
| 81 LRESULT OnCreate(LPCREATESTRUCT create_struct) { | 81 LRESULT OnCreate(LPCREATESTRUCT create_struct) { |
| 82 control_ = parent_->CreateNativeControl(m_hWnd); | 82 control_ = parent_->CreateNativeControl(m_hWnd); |
| 83 | 83 |
| 84 FocusManager::InstallFocusSubclass(control_, parent_); | |
| 85 | |
| 86 // We subclass the control hwnd so we get the WM_KEYDOWN messages. | 84 // We subclass the control hwnd so we get the WM_KEYDOWN messages. |
| 87 WNDPROC original_handler = | 85 WNDPROC original_handler = |
| 88 win_util::SetWindowProc(control_, | 86 win_util::SetWindowProc(control_, |
| 89 &NativeControl::NativeControlWndProc); | 87 &NativeControl::NativeControlWndProc); |
| 90 SetProp(control_, kHandlerKey, original_handler); | 88 SetProp(control_, kHandlerKey, original_handler); |
| 91 SetProp(control_, kNativeControlKey , parent_); | 89 SetProp(control_, kNativeControlKey , parent_); |
| 92 | 90 |
| 93 ::ShowWindow(control_, SW_SHOW); | 91 ::ShowWindow(control_, SW_SHOW); |
| 94 return 1; | 92 return 1; |
| 95 } | 93 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 LPARAM l_param) { | 358 LPARAM l_param) { |
| 361 HANDLE original_handler = GetProp(window, kHandlerKey); | 359 HANDLE original_handler = GetProp(window, kHandlerKey); |
| 362 DCHECK(original_handler); | 360 DCHECK(original_handler); |
| 363 NativeControl* native_control = | 361 NativeControl* native_control = |
| 364 static_cast<NativeControl*>(GetProp(window, kNativeControlKey)); | 362 static_cast<NativeControl*>(GetProp(window, kNativeControlKey)); |
| 365 DCHECK(native_control); | 363 DCHECK(native_control); |
| 366 | 364 |
| 367 if (message == WM_KEYDOWN && native_control->NotifyOnKeyDown()) { | 365 if (message == WM_KEYDOWN && native_control->NotifyOnKeyDown()) { |
| 368 if (native_control->OnKeyDown(static_cast<int>(w_param))) | 366 if (native_control->OnKeyDown(static_cast<int>(w_param))) |
| 369 return 0; | 367 return 0; |
| 368 } else if (message == WM_SETFOCUS) { |
| 369 // Let the focus manager know that the focus changed. |
| 370 FocusManager* focus_manager = |
| 371 FocusManager::GetFocusManager(native_control->GetNativeControlHWND()); |
| 372 if (focus_manager) { |
| 373 focus_manager->SetFocusedView(native_control); |
| 374 } else { |
| 375 NOTREACHED(); |
| 376 } |
| 370 } else if (message == WM_DESTROY) { | 377 } else if (message == WM_DESTROY) { |
| 371 win_util::SetWindowProc(window, | 378 win_util::SetWindowProc(window, |
| 372 reinterpret_cast<WNDPROC>(original_handler)); | 379 reinterpret_cast<WNDPROC>(original_handler)); |
| 373 RemoveProp(window, kHandlerKey); | 380 RemoveProp(window, kHandlerKey); |
| 374 RemoveProp(window, kNativeControlKey); | 381 RemoveProp(window, kNativeControlKey); |
| 375 } | 382 } |
| 376 | 383 |
| 377 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, | 384 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, |
| 378 message, w_param, l_param); | 385 message, w_param, l_param); |
| 379 } | 386 } |
| 380 | 387 |
| 381 } // namespace views | 388 } // namespace views |
| OLD | NEW |