OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 <windows.h> | 5 #include <windows.h> |
6 #include <CommCtrl.h> | 6 #include <CommCtrl.h> |
7 #include <commdlg.h> | 7 #include <commdlg.h> |
8 #include <time.h> | 8 #include <time.h> |
9 #include <windowsx.h> | 9 #include <windowsx.h> |
10 #include <atlbase.h> | 10 #include <atlbase.h> |
11 #include <atlsecurity.h> | 11 #include <atlsecurity.h> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 600, // width | 89 600, // width |
90 400, // height | 90 400, // height |
91 NULL, // parent | 91 NULL, // parent |
92 NULL, // NULL = use class menu | 92 NULL, // NULL = use class menu |
93 instance, | 93 instance, |
94 0); // lpParam | 94 0); // lpParam |
95 | 95 |
96 if (NULL == window) | 96 if (NULL == window) |
97 return ::GetLastError(); | 97 return ::GetLastError(); |
98 | 98 |
99 ::SetWindowLong(window, | 99 ::SetWindowLongPtr(window, |
100 GWL_USERDATA, | 100 GWLP_USERDATA, |
101 static_cast<LONG>(reinterpret_cast<LONG_PTR>(this))); | 101 reinterpret_cast<LONG_PTR>(this)); |
102 | 102 |
103 ::SetWindowText(window, L"Sandbox Proof of Concept"); | 103 ::SetWindowText(window, L"Sandbox Proof of Concept"); |
104 | 104 |
105 ::ShowWindow(window, show_command); | 105 ::ShowWindow(window, show_command); |
106 | 106 |
107 MSG message; | 107 MSG message; |
108 // Now lets start the message pump retrieving messages for any window that | 108 // Now lets start the message pump retrieving messages for any window that |
109 // belongs to the current thread | 109 // belongs to the current thread |
110 while (::GetMessage(&message, NULL, 0, 0)) { | 110 while (::GetMessage(&message, NULL, 0, 0)) { |
111 ::TranslateMessage(&message); | 111 ::TranslateMessage(&message); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 226 } |
227 | 227 |
228 return static_cast<INT_PTR>(FALSE); | 228 return static_cast<INT_PTR>(FALSE); |
229 } | 229 } |
230 | 230 |
231 MainUIWindow* MainUIWindow::FromWindow(HWND main_window) { | 231 MainUIWindow* MainUIWindow::FromWindow(HWND main_window) { |
232 // We store a 'this' pointer using SetWindowLong in CreateMainWindowAndLoop | 232 // We store a 'this' pointer using SetWindowLong in CreateMainWindowAndLoop |
233 // so that we can retrieve it with this function later. This prevents us | 233 // so that we can retrieve it with this function later. This prevents us |
234 // from having to define all the message handling functions (that we refer to | 234 // from having to define all the message handling functions (that we refer to |
235 // in the window proc) as static | 235 // in the window proc) as static |
236 ::GetWindowLong(main_window, GWL_USERDATA); | 236 ::GetWindowLongPtr(main_window, GWLP_USERDATA); |
237 return reinterpret_cast<MainUIWindow*>( | 237 return reinterpret_cast<MainUIWindow*>( |
238 static_cast<LONG_PTR>(::GetWindowLong(main_window, GWL_USERDATA))); | 238 ::GetWindowLongPtr(main_window, GWLP_USERDATA)); |
239 } | 239 } |
240 | 240 |
241 BOOL MainUIWindow::OnCreate(HWND parent_window, LPCREATESTRUCT) { | 241 BOOL MainUIWindow::OnCreate(HWND parent_window, LPCREATESTRUCT) { |
242 // Create the listview that will the main app UI | 242 // Create the listview that will the main app UI |
243 list_view_ = ::CreateWindow(WC_LISTVIEW, // Class name | 243 list_view_ = ::CreateWindow(WC_LISTVIEW, // Class name |
244 L"", // Window name | 244 L"", // Window name |
245 WS_CHILD | WS_VISIBLE | LVS_REPORT | | 245 WS_CHILD | WS_VISIBLE | LVS_REPORT | |
246 LVS_NOCOLUMNHEADER | WS_BORDER, | 246 LVS_NOCOLUMNHEADER | WS_BORDER, |
247 0, // x | 247 0, // x |
248 0, // y | 248 0, // y |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 item.iItem = ListView_GetItemCount(list_view_); | 659 item.iItem = ListView_GetItemCount(list_view_); |
660 item.iSubItem = 0; | 660 item.iSubItem = 0; |
661 item.mask = LVIF_TEXT | LVIF_PARAM; | 661 item.mask = LVIF_TEXT | LVIF_PARAM; |
662 item.pszText = message_time; | 662 item.pszText = message_time; |
663 item.lParam = 0; | 663 item.lParam = 0; |
664 | 664 |
665 ListView_InsertItem(list_view_, &item); | 665 ListView_InsertItem(list_view_, &item); |
666 | 666 |
667 delete[] message_time; | 667 delete[] message_time; |
668 } | 668 } |
OLD | NEW |