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

Side by Side Diff: ui/views/controls/menu/native_menu_win.cc

Issue 10315012: Added base::win::InitializeWindowClass() wrapper to make sure that window classes are properly asso… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback and rebased. Created 8 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/win/window_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/menu/native_menu_win.h" 5 #include "ui/views/controls/menu/native_menu_win.h"
6 6
7 #include <Windowsx.h> 7 #include <Windowsx.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 HWND hwnd() const { return hwnd_; } 89 HWND hwnd() const { return hwnd_; }
90 90
91 private: 91 private:
92 static const wchar_t* kWindowClassName; 92 static const wchar_t* kWindowClassName;
93 93
94 void RegisterClass() { 94 void RegisterClass() {
95 static bool registered = false; 95 static bool registered = false;
96 if (registered) 96 if (registered)
97 return; 97 return;
98 98
99 WNDCLASSEX wcex = {0}; 99 WNDCLASSEX window_class;
100 wcex.cbSize = sizeof(WNDCLASSEX); 100 base::win::InitializeWindowClass(
101 wcex.style = CS_DBLCLKS; 101 kWindowClassName,
102 wcex.lpfnWndProc = base::win::WrappedWindowProc<&MenuHostWindowProc>; 102 &base::win::WrappedWindowProc<MenuHostWindowProc>,
103 wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); 103 CS_DBLCLKS,
104 wcex.lpszClassName = kWindowClassName; 104 0,
105 ATOM clazz = RegisterClassEx(&wcex); 105 0,
106 DCHECK(clazz); 106 NULL,
107 reinterpret_cast<HBRUSH>(COLOR_WINDOW+1),
108 NULL,
109 NULL,
110 NULL,
111 &window_class);
112 ATOM clazz = RegisterClassEx(&window_class);
113 CHECK(clazz);
107 registered = true; 114 registered = true;
108 } 115 }
109 116
110 // Converts the WPARAM value passed to WM_MENUSELECT into an index 117 // Converts the WPARAM value passed to WM_MENUSELECT into an index
111 // corresponding to the menu item that was selected. 118 // corresponding to the menu item that was selected.
112 int GetMenuItemIndexFromWPARAM(HMENU menu, WPARAM w_param) const { 119 int GetMenuItemIndexFromWPARAM(HMENU menu, WPARAM w_param) const {
113 int count = GetMenuItemCount(menu); 120 int count = GetMenuItemCount(menu);
114 // For normal command menu items, Windows passes a command id as the LOWORD 121 // For normal command menu items, Windows passes a command id as the LOWORD
115 // of WPARAM for WM_MENUSELECT. We need to walk forward through the menu 122 // of WPARAM for WM_MENUSELECT. We need to walk forward through the menu
116 // items to find an item with a matching ID. Ugh! 123 // items to find an item with a matching ID. Ugh!
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 748
742 //////////////////////////////////////////////////////////////////////////////// 749 ////////////////////////////////////////////////////////////////////////////////
743 // MenuWrapper, public: 750 // MenuWrapper, public:
744 751
745 // static 752 // static
746 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) { 753 MenuWrapper* MenuWrapper::CreateWrapper(ui::MenuModel* model) {
747 return new NativeMenuWin(model, NULL); 754 return new NativeMenuWin(model, NULL);
748 } 755 }
749 756
750 } // namespace views 757 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/win/window_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698