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 "chrome/views/combo_box.h" | 5 #include "chrome/views/combo_box.h" |
6 | 6 |
7 #include "base/gfx/native_theme.h" | 7 #include "base/gfx/native_theme.h" |
8 #include "base/gfx/rect.h" | 8 #include "base/gfx/rect.h" |
9 #include "chrome/common/gfx/chrome_canvas.h" | 9 #include "chrome/common/gfx/chrome_canvas.h" |
10 #include "chrome/common/gfx/chrome_font.h" | 10 #include "chrome/common/gfx/chrome_font.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 gfx::Size ComboBox::GetPreferredSize() { | 34 gfx::Size ComboBox::GetPreferredSize() { |
35 HWND hwnd = GetNativeControlHWND(); | 35 HWND hwnd = GetNativeControlHWND(); |
36 if (!hwnd) | 36 if (!hwnd) |
37 return gfx::Size(); | 37 return gfx::Size(); |
38 | 38 |
39 COMBOBOXINFO cbi; | 39 COMBOBOXINFO cbi; |
40 memset(reinterpret_cast<unsigned char*>(&cbi), 0, sizeof(cbi)); | 40 memset(reinterpret_cast<unsigned char*>(&cbi), 0, sizeof(cbi)); |
41 cbi.cbSize = sizeof(cbi); | 41 cbi.cbSize = sizeof(cbi); |
42 ::SendMessage(hwnd, CB_GETCOMBOBOXINFO, 0, reinterpret_cast<LPARAM>(&cbi)); | 42 // Note: Don't use CB_GETCOMBOBOXINFO since that crashes on WOW64 systems |
| 43 // when you have a global message hook installed. |
| 44 GetComboBoxInfo(hwnd, &cbi); |
43 gfx::Rect rect_item(cbi.rcItem); | 45 gfx::Rect rect_item(cbi.rcItem); |
44 gfx::Rect rect_button(cbi.rcButton); | 46 gfx::Rect rect_button(cbi.rcButton); |
45 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize( | 47 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize( |
46 gfx::NativeTheme::MENULIST); | 48 gfx::NativeTheme::MENULIST); |
47 | 49 |
48 // The padding value of '3' is the xy offset from the corner of the control | 50 // The padding value of '3' is the xy offset from the corner of the control |
49 // to the corner of rcItem. It does not seem to be queryable from the theme. | 51 // to the corner of rcItem. It does not seem to be queryable from the theme. |
50 // It is consistent on all versions of Windows from 2K to Vista, and is | 52 // It is consistent on all versions of Windows from 2K to Vista, and is |
51 // invariant with respect to the combobox border size. We could conceivably | 53 // invariant with respect to the combobox border size. We could conceivably |
52 // get this number from rect_item.x, but it seems fragile to depend on positio
n | 54 // get this number from rect_item.x, but it seems fragile to depend on positio
n |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // CB_SELECTSTRING does). | 158 // CB_SELECTSTRING does). |
157 ::SendMessage(hwnd, CB_SETCURSEL, selected_item_, 0); | 159 ::SendMessage(hwnd, CB_SETCURSEL, selected_item_, 0); |
158 } | 160 } |
159 | 161 |
160 int ComboBox::GetSelectedItem() { | 162 int ComboBox::GetSelectedItem() { |
161 return selected_item_; | 163 return selected_item_; |
162 } | 164 } |
163 | 165 |
164 } // namespace views | 166 } // namespace views |
165 | 167 |
OLD | NEW |