ReactOS  0.4.15-dev-2993-g14fbe80
dialogs.cpp
Go to the documentation of this file.
1 /*
2  * common shell dialogs
3  *
4  * Copyright 2000 Juergen Schmied
5  * Copyright 2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  * Copyright 2021 Arnav Bhatt <arnavbhatt288@gmail.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 #include "precomp.h"
24 
25 typedef struct
26 {
35 
36 typedef struct
37 {
39  BOOL bIsButtonHot[2];
41  HBRUSH hBrush;
45 
46 typedef BOOL (WINAPI * LPFNOFN) (OPENFILENAMEW *);
47 
50 static void FillList(HWND, LPWSTR, UINT, BOOL);
51 
52 
53 /*************************************************************************
54  * PickIconDlg [SHELL32.62]
55  *
56  */
57 
58 typedef struct
59 {
67 
69  LPCWSTR lpszType,
70  LPWSTR lpszName,
72 {
74  HWND hDlgCtrl = pIconContext->hDlgCtrl;
75 
76  if (IS_INTRESOURCE(lpszName))
77  lParam = LOWORD(lpszName);
78  else
79  lParam = -1;
80 
81  SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, lParam);
82 
83  return TRUE;
84 }
85 
86 static void
87 DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
88 {
89  int count;
90  int index;
91 
92  count = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
93  if (count == LB_ERR)
94  return;
95 
96  for(index = 0; index < count; index++)
97  {
98  DestroyIcon(pIconContext->phIcons[index]);
99  pIconContext->phIcons[index] = NULL;
100  }
101 }
102 
103 static BOOL
104 DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
105 {
106  WCHAR szExpandedPath[MAX_PATH];
107 
108  // Destroy previous icons
109  DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
110  SendMessageW(pIconContext->hDlgCtrl, LB_RESETCONTENT, 0, 0);
111  delete[] pIconContext->phIcons;
112 
113  // Store the path
114  StringCchCopyW(pIconContext->szPath, _countof(pIconContext->szPath), pszFile);
115  ExpandEnvironmentStringsW(pszFile, szExpandedPath, _countof(szExpandedPath));
116 
117  // Load the module if possible
119  if (pIconContext->hLibrary)
120  FreeLibrary(pIconContext->hLibrary);
121  pIconContext->hLibrary = hLibrary;
122 
123  if (pIconContext->hLibrary)
124  {
125  // Load the icons from the module
126  pIconContext->nIcons = ExtractIconExW(szExpandedPath, -1, NULL, NULL, 0);
127  pIconContext->phIcons = new HICON[pIconContext->nIcons];
128 
129  if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
130  {
132  }
133  else
134  {
135  pIconContext->nIcons = 0;
136  }
137  }
138  else
139  {
140  // .ico file
141  pIconContext->nIcons = 1;
142  pIconContext->phIcons = new HICON[1];
143 
144  if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
145  {
146  SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, 0);
147  }
148  else
149  {
150  pIconContext->nIcons = 0;
151  }
152  }
153 
154  // Set the text and reset the edit control's modification flag
155  SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
157 
158  if (pIconContext->nIcons == 0)
159  {
160  delete[] pIconContext->phIcons;
161  pIconContext->phIcons = NULL;
162  }
163 
164  return (pIconContext->nIcons > 0);
165 }
166 
167 static const LPCWSTR s_pszDefaultPath = L"%SystemRoot%\\system32\\shell32.dll";
168 
169 static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
170 {
171  // Show an error message
172  CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
173  strText.Format(IDS_NO_ICONS, pIconContext->szPath);
174  MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING);
175 
176  // Load the default icons
177  DoLoadIcons(hwndDlg, pIconContext, s_pszDefaultPath);
178 }
179 
180 // Icon size
181 #define CX_ICON GetSystemMetrics(SM_CXICON)
182 #define CY_ICON GetSystemMetrics(SM_CYICON)
183 
184 // Item size
185 #define CX_ITEM (CX_ICON + 4)
186 #define CY_ITEM (CY_ICON + 12)
187 
189  HWND hwndDlg,
190  UINT uMsg,
191  WPARAM wParam,
192  LPARAM lParam)
193 {
194  LPMEASUREITEMSTRUCT lpmis;
195  LPDRAWITEMSTRUCT lpdis;
196  HICON hIcon;
197  INT index, count;
198  WCHAR szText[MAX_PATH], szFilter[100];
199  CStringW strTitle;
201 
203 
204  switch(uMsg)
205  {
206  case WM_INITDIALOG:
207  {
208  pIconContext = (PPICK_ICON_CONTEXT)lParam;
209  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
210  pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
211 
212  SendMessageW(pIconContext->hDlgCtrl, LB_SETCOLUMNWIDTH, CX_ITEM, 0);
213 
214  // Load the icons
215  if (!DoLoadIcons(hwndDlg, pIconContext, pIconContext->szPath))
216  NoIconsInFile(hwndDlg, pIconContext);
217 
218  // Set the selection
219  count = SendMessageW(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
220  if (count != LB_ERR)
221  {
222  if (pIconContext->Index < 0)
223  {
224  // A negative value will be interpreted as a negated resource ID.
225  LPARAM lParam = -pIconContext->Index;
226  pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRINGEXACT, -1, lParam);
227  }
228 
229  if (pIconContext->Index < 0 || count <= pIconContext->Index)
230  pIconContext->Index = 0;
231 
232  SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0);
233  SendMessageW(pIconContext->hDlgCtrl, LB_SETTOPINDEX, pIconContext->Index, 0);
234  }
235 
237  return TRUE;
238  }
239 
240  case WM_DESTROY:
241  {
242  DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
243  delete[] pIconContext->phIcons;
244 
245  if (pIconContext->hLibrary)
246  FreeLibrary(pIconContext->hLibrary);
247  break;
248  }
249 
250  case WM_COMMAND:
251  switch(LOWORD(wParam))
252  {
253  case IDOK:
254  {
255  /* Check whether the path edit control has been modified; if so load the icons instead of validating */
256  if (SendDlgItemMessage(hwndDlg, IDC_EDIT_PATH, EM_GETMODIFY, 0, 0))
257  {
258  /* Reset the edit control's modification flag and retrieve the text */
261 
262  // Load the icons
263  if (!DoLoadIcons(hwndDlg, pIconContext, szText))
264  NoIconsInFile(hwndDlg, pIconContext);
265 
266  // Set the selection
267  SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
268  break;
269  }
270 
271  /* The path edit control has not been modified, return the selection */
272  pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
273  GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath, _countof(pIconContext->szPath));
274  EndDialog(hwndDlg, 1);
275  break;
276  }
277 
278  case IDCANCEL:
279  EndDialog(hwndDlg, 0);
280  break;
281 
282  case IDC_PICKICON_LIST:
283  switch (HIWORD(wParam))
284  {
285  case LBN_SELCHANGE:
287  break;
288 
289  case LBN_DBLCLK:
290  SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
291  break;
292  }
293  break;
294 
295  case IDC_BUTTON_PATH:
296  {
297  // Choose the module path
298  szText[0] = 0;
299  szFilter[0] = 0;
300  ZeroMemory(&ofn, sizeof(ofn));
301  ofn.lStructSize = sizeof(ofn);
302  ofn.hwndOwner = hwndDlg;
303  ofn.lpstrFile = szText;
305  strTitle.LoadString(IDS_PICK_ICON_TITLE);
306  ofn.lpstrTitle = strTitle;
309  if (!GetOpenFileNameW(&ofn))
310  break;
311 
312  // Load the icons
313  if (!DoLoadIcons(hwndDlg, pIconContext, szText))
314  NoIconsInFile(hwndDlg, pIconContext);
315 
316  // Set the selection
317  SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
318  break;
319  }
320 
321  default:
322  break;
323  }
324  break;
325 
326  case WM_MEASUREITEM:
327  lpmis = (LPMEASUREITEMSTRUCT)lParam;
328  lpmis->itemHeight = CY_ITEM;
329  return TRUE;
330 
331  case WM_DRAWITEM:
332  {
333  lpdis = (LPDRAWITEMSTRUCT)lParam;
334  if (lpdis->itemID == (UINT)-1)
335  break;
336  switch (lpdis->itemAction)
337  {
338  case ODA_SELECT:
339  case ODA_DRAWENTIRE:
340  {
341  index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
342  hIcon = pIconContext->phIcons[lpdis->itemID];
343 
344  if (lpdis->itemID == (UINT)index)
345  FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
346  else
347  FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
348 
349  // Centering
350  INT x = lpdis->rcItem.left + (CX_ITEM - CX_ICON) / 2;
351  INT y = lpdis->rcItem.top + (CY_ITEM - CY_ICON) / 2;
352 
353  DrawIconEx(lpdis->hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
354  break;
355  }
356  }
357  return TRUE;
358  }
359  }
360 
361  return FALSE;
362 }
363 
365  HWND hWndOwner,
366  LPWSTR lpstrFile,
367  UINT nMaxFile,
368  INT* lpdwIconIndex)
369 {
370  int res;
371  WCHAR szExpandedPath[MAX_PATH];
372 
373  // Initialize the dialog
374  PICK_ICON_CONTEXT IconContext = { NULL };
375  IconContext.Index = *lpdwIconIndex;
376  StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), lpstrFile);
377  ExpandEnvironmentStringsW(lpstrFile, szExpandedPath, _countof(szExpandedPath));
378 
379  if (!szExpandedPath[0] ||
380  GetFileAttributesW(szExpandedPath) == INVALID_FILE_ATTRIBUTES)
381  {
382  if (szExpandedPath[0])
383  {
384  // No such file
385  CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
386  strText.Format(IDS_FILE_NOT_FOUND, lpstrFile);
387  MessageBoxW(hWndOwner, strText, strTitle, MB_ICONWARNING);
388  }
389 
390  // Set the default value
391  StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), s_pszDefaultPath);
392  }
393 
394  // Show the dialog
396  if (res)
397  {
398  // Store the selected icon
399  StringCchCopyW(lpstrFile, nMaxFile, IconContext.szPath);
400  *lpdwIconIndex = IconContext.Index;
401  }
402 
403  return res;
404 }
405 
406 /*************************************************************************
407  * RunFileDlg [internal]
408  *
409  * The Unicode function that is available as ordinal 61 on Windows NT/2000/XP/...
410  */
412  HWND hWndOwner,
413  HICON hIcon,
414  LPCWSTR lpstrDirectory,
415  LPCWSTR lpstrTitle,
416  LPCWSTR lpstrDescription,
417  UINT uFlags)
418 {
419  TRACE("\n");
420 
421  RUNFILEDLGPARAMS rfdp;
422  rfdp.hwndOwner = hWndOwner;
423  rfdp.hIcon = hIcon;
424  rfdp.lpstrDirectory = lpstrDirectory;
425  rfdp.lpstrTitle = lpstrTitle;
426  rfdp.lpstrDescription = lpstrDescription;
427  rfdp.uFlags = uFlags;
428 
430 }
431 
432 
433 /* find the directory that contains the file being run */
435 {
436  const WCHAR *src;
437  WCHAR *dest, *result, *result_end=NULL;
438  static const WCHAR dotexeW[] = L".exe";
439 
440  result = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5));
441 
442  if (NULL == result)
443  {
444  TRACE("HeapAlloc couldn't allocate %d bytes\n", sizeof(WCHAR)*(strlenW(cmdline)+5));
445  return NULL;
446  }
447 
448  src = cmdline;
449  dest = result;
450 
451  if (*src == '"')
452  {
453  src++;
454  while (*src && *src != '"')
455  {
456  if (*src == '\\')
457  result_end = dest;
458  *dest++ = *src++;
459  }
460  }
461  else {
462  while (*src)
463  {
464  if (isspaceW(*src))
465  {
466  *dest = 0;
468  break;
469  strcatW(dest, dotexeW);
471  break;
472  }
473  else if (*src == '\\')
474  result_end = dest;
475  *dest++ = *src++;
476  }
477  }
478 
479  if (result_end)
480  {
481  *result_end = 0;
482  return result;
483  }
484  else
485  {
487  return NULL;
488  }
489 }
490 
492 {
493  BOOL Enable = FALSE;
494  INT Length, n;
497  if (Length > 0)
498  {
499  PWCHAR psz = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR));
500  if (psz)
501  {
502  GetWindowTextW(Edit, psz, Length + 1);
503  for (n = 0; n < Length && !Enable; ++n)
504  Enable = psz[n] != ' ';
505  HeapFree(GetProcessHeap(), 0, psz);
506  }
507  else
508  Enable = TRUE;
509  }
511 }
512 
513 /* Dialog procedure for RunFileDlg */
515 {
517  HWND hwndCombo, hwndEdit;
518  COMBOBOXINFO ComboInfo;
519 
520  switch (message)
521  {
522  case WM_INITDIALOG:
523  prfdp = (RUNFILEDLGPARAMS *)lParam;
525 
526  if (prfdp->lpstrTitle)
527  SetWindowTextW(hwnd, prfdp->lpstrTitle);
528  if (prfdp->lpstrDescription)
529  SetWindowTextW(GetDlgItem(hwnd, IDC_RUNDLG_DESCRIPTION), prfdp->lpstrDescription);
530  if (prfdp->uFlags & RFF_NOBROWSE)
531  {
533  ShowWindow(browse, SW_HIDE);
534  EnableWindow(browse, FALSE);
535  }
536  if (prfdp->uFlags & RFF_NOLABEL)
538  if (prfdp->uFlags & RFF_NOSEPARATEMEM)
539  {
540  FIXME("RFF_NOSEPARATEMEM not supported\n");
541  }
542 
543  /* Use the default Shell Run icon if no one is specified */
544  if (prfdp->hIcon == NULL)
546  /*
547  * NOTE: Starting Windows Vista, the "Run File" dialog gets a
548  * title icon that remains the same as the default one, even if
549  * the user specifies a custom icon.
550  * Since we currently imitate Windows 2003, therefore do not show
551  * any title icon.
552  */
553  // SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)prfdp->hIcon);
554  // SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon);
556 
557  hwndCombo = GetDlgItem(hwnd, IDC_RUNDLG_EDITPATH);
558  FillList(hwndCombo, NULL, 0, (prfdp->uFlags & RFF_NODEFAULT) == 0);
560 
561  ComboInfo.cbSize = sizeof(ComboInfo);
562  GetComboBoxInfo(hwndCombo, &ComboInfo);
563  hwndEdit = ComboInfo.hwndItem;
565 
566  // SHAutoComplete needs co init
568 
570 
571  SetFocus(hwndCombo);
572  return TRUE;
573 
574  case WM_DESTROY:
575  if (prfdp->bCoInited)
576  CoUninitialize();
577  break;
578 
579  case WM_COMMAND:
580  switch (LOWORD(wParam))
581  {
582  case IDOK:
583  {
584  LRESULT lRet;
586  INT ic;
587  WCHAR *psz, *pszExpanded, *parent = NULL;
588  DWORD cchExpand;
589  SHELLEXECUTEINFOW sei;
590  NMRUNFILEDLGW nmrfd;
591 
592  ic = GetWindowTextLengthW(htxt);
593  if (ic == 0)
594  {
596  return TRUE;
597  }
598 
599  ZeroMemory(&sei, sizeof(sei));
600  sei.cbSize = sizeof(sei);
601 
602  /*
603  * Allocate a new MRU entry, we need to add two characters
604  * for the terminating "\\1" part, then the NULL character.
605  */
606  psz = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (ic + 2 + 1)*sizeof(WCHAR));
607  if (!psz)
608  {
610  return TRUE;
611  }
612 
613  GetWindowTextW(htxt, psz, ic + 1);
614  sei.hwnd = hwnd;
615  sei.nShow = SW_SHOWNORMAL;
616  sei.lpFile = psz;
617  StrTrimW(psz, L" \t");
618 
619  if (wcschr(psz, L'%') != NULL)
620  {
621  cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
622  pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
623  if (!pszExpanded)
624  {
625  HeapFree(GetProcessHeap(), 0, psz);
627  return TRUE;
628  }
629  ExpandEnvironmentStringsW(psz, pszExpanded, cchExpand);
630  StrTrimW(pszExpanded, L" \t");
631  }
632  else
633  {
634  pszExpanded = psz;
635  }
636 
637  /*
638  * The precedence is the following: first the user-given
639  * current directory is used; if there is none, a current
640  * directory is computed if the RFF_CALCDIRECTORY is set,
641  * otherwise no current directory is defined.
642  */
643  LPCWSTR pszStartDir;
644  if (prfdp->lpstrDirectory)
645  {
646  sei.lpDirectory = prfdp->lpstrDirectory;
647  pszStartDir = prfdp->lpstrDirectory;
648  }
649  else if (prfdp->uFlags & RFF_CALCDIRECTORY)
650  {
652  pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
653  }
654  else
655  {
656  sei.lpDirectory = NULL;
657  pszStartDir = NULL;
658  }
659 
660  /* Hide the dialog for now on, we will show it up in case of retry */
662 
663  /*
664  * As shown by manual tests on Windows, modifying the contents
665  * of the notification structure will not modify what the
666  * Run-Dialog will use for the nShow parameter. However the
667  * lpFile and lpDirectory pointers are set to the buffers used
668  * by the Run-Dialog, as a consequence they can be modified by
669  * the notification receiver, as long as it respects the lengths
670  * of the buffers (to avoid buffer overflows).
671  */
672  nmrfd.hdr.code = RFN_VALIDATE;
673  nmrfd.hdr.hwndFrom = hwnd;
674  nmrfd.hdr.idFrom = 0;
675  nmrfd.lpFile = pszExpanded;
676  nmrfd.lpDirectory = pszStartDir;
677  nmrfd.nShow = SW_SHOWNORMAL;
678 
679  lRet = SendMessageW(prfdp->hwndOwner, WM_NOTIFY, 0, (LPARAM)&nmrfd.hdr);
680 
681  switch (lRet)
682  {
683  case RF_CANCEL:
685  break;
686 
687  case RF_OK:
688  /* We use SECL_NO_UI because we don't want to see
689  * errors here, but we will try again below and
690  * there we will output our errors. */
691  if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
693  {
694  /* Call GetWindowText again in case the contents of the edit box have changed. */
695  GetWindowTextW(htxt, psz, ic + 1);
696  FillList(htxt, psz, ic + 2 + 1, FALSE);
697  EndDialog(hwnd, IDOK);
698  break;
699  }
700  else if (SUCCEEDED(ShellExecuteExW(&sei)))
701  {
702  /* Call GetWindowText again in case the contents of the edit box have changed. */
703  GetWindowTextW(htxt, psz, ic + 1);
704  FillList(htxt, psz, ic + 2 + 1, FALSE);
705  EndDialog(hwnd, IDOK);
706  break;
707  }
708 
709  /* Fall-back */
710  case RF_RETRY:
711  default:
712  SendMessageW(htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
713  /* Show back the dialog */
715  break;
716  }
717 
719  HeapFree(GetProcessHeap(), 0, psz);
720  if (psz != pszExpanded)
721  HeapFree(GetProcessHeap(), 0, pszExpanded);
722  return TRUE;
723  }
724 
725  case IDCANCEL:
727  return TRUE;
728 
729  case IDC_RUNDLG_BROWSE:
730  {
731  HMODULE hComdlg = NULL;
732  LPFNOFN ofnProc = NULL;
733  WCHAR szFName[1024] = {0};
734  WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
736 
739 
740  ZeroMemory(&ofn, sizeof(ofn));
741  ofn.lStructSize = sizeof(ofn);
742  ofn.hwndOwner = hwnd;
744  ofn.lpstrFile = szFName;
745  ofn.nMaxFile = _countof(szFName) - 1;
746  ofn.lpstrTitle = szCaption;
748  ofn.lpstrInitialDir = prfdp->lpstrDirectory;
749 
750  if (NULL == (hComdlg = LoadLibraryExW(L"comdlg32", NULL, 0)) ||
751  NULL == (ofnProc = (LPFNOFN)GetProcAddress(hComdlg, "GetOpenFileNameW")))
752  {
753  ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
755  return TRUE;
756  }
757 
758  if (ofnProc(&ofn))
759  {
765  }
766 
767  FreeLibrary(hComdlg);
768 
769  return TRUE;
770  }
771  case IDC_RUNDLG_EDITPATH:
772  {
773  if (HIWORD(wParam) == CBN_EDITCHANGE)
774  {
776  }
777  return TRUE;
778  }
779  }
780  return TRUE;
781  }
782  return FALSE;
783 }
784 
785 /*
786  * This function grabs the MRU list from the registry and fills the combo-list
787  * for the "Run" dialog above. fShowDefault is ignored if pszLatest != NULL.
788  */
789 // FIXME: Part of this code should be part of some MRUList API,
790 // that is scattered amongst shell32, comctl32 (?!) and comdlg32.
791 static void FillList(HWND hCb, LPWSTR pszLatest, UINT cchStr, BOOL fShowDefault)
792 {
793  HKEY hkey;
794  WCHAR *pszList = NULL, *pszCmd = NULL, *pszTmp = NULL, cMatch = 0, cMax = 0x60;
795  WCHAR szIndex[2] = L"-";
796  UINT cchLatest;
797  DWORD dwType, icList = 0, icCmd = 0;
798  LRESULT lRet;
799  UINT Nix;
800 
801  /*
802  * Retrieve the string length of pszLatest and check whether its buffer size
803  * (cchStr in number of characters) is large enough to add the terminating "\\1"
804  * (and the NULL character).
805  */
806  if (pszLatest)
807  {
808  cchLatest = wcslen(pszLatest);
809  if (cchStr < cchLatest + 2 + 1)
810  {
811  TRACE("pszLatest buffer is not large enough (%d) to hold the MRU terminator.\n", cchStr);
812  return;
813  }
814  }
815  else
816  {
817  cchStr = 0;
818  }
819 
820  SendMessageW(hCb, CB_RESETCONTENT, 0, 0);
821 
823  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
825  if (lRet != ERROR_SUCCESS)
826  {
827  TRACE("Unable to open or create the RunMRU key, error %d\n", GetLastError());
828  return;
829  }
830 
831  lRet = RegQueryValueExW(hkey, L"MRUList", NULL, &dwType, NULL, &icList);
832  if (lRet == ERROR_SUCCESS && dwType == REG_SZ && icList > sizeof(WCHAR))
833  {
834  pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
835  if (!pszList)
836  {
837  TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
838  goto Continue;
839  }
840  pszList[0] = L'\0';
841 
842  lRet = RegQueryValueExW(hkey, L"MRUList", NULL, NULL, (LPBYTE)pszList, &icList);
843  if (lRet != ERROR_SUCCESS)
844  {
845  TRACE("Unable to grab MRUList, error %d\n", GetLastError());
846  pszList[0] = L'\0';
847  }
848  }
849  else
850  {
851 Continue:
852  icList = sizeof(WCHAR);
853  pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
854  if (!pszList)
855  {
856  TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
857  RegCloseKey(hkey);
858  return;
859  }
860  pszList[0] = L'\0';
861  }
862 
863  /* Convert the number of bytes from MRUList into number of characters (== number of indices) */
864  icList /= sizeof(WCHAR);
865 
866  for (Nix = 0; Nix < icList - 1; Nix++)
867  {
868  if (pszList[Nix] > cMax)
869  cMax = pszList[Nix];
870 
871  szIndex[0] = pszList[Nix];
872 
873  lRet = RegQueryValueExW(hkey, szIndex, NULL, &dwType, NULL, &icCmd);
874  if (lRet != ERROR_SUCCESS || dwType != REG_SZ)
875  {
876  TRACE("Unable to grab size of index, error %d\n", GetLastError());
877  continue;
878  }
879 
880  if (pszCmd)
881  {
882  pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd);
883  if (!pszTmp)
884  {
885  TRACE("HeapReAlloc failed to reallocate %d bytes\n", icCmd);
886  continue;
887  }
888  pszCmd = pszTmp;
889  }
890  else
891  {
892  pszCmd = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icCmd);
893  if (!pszCmd)
894  {
895  TRACE("HeapAlloc failed to allocate %d bytes\n", icCmd);
896  continue;
897  }
898  }
899 
900  lRet = RegQueryValueExW(hkey, szIndex, NULL, NULL, (LPBYTE)pszCmd, &icCmd);
901  if (lRet != ERROR_SUCCESS)
902  {
903  TRACE("Unable to grab index, error %d\n", GetLastError());
904  continue;
905  }
906 
907  /*
908  * Generally the command string will end up with "\\1".
909  * Find the last backslash in the string and NULL-terminate.
910  * Windows does not seem to check for what comes next, so that
911  * a command of the form:
912  * c:\\my_dir\\myfile.exe
913  * will be cut just after "my_dir", whereas a command of the form:
914  * c:\\my_dir\\myfile.exe\\1
915  * will be cut just after "myfile.exe".
916  */
917  pszTmp = wcsrchr(pszCmd, L'\\');
918  if (pszTmp)
919  *pszTmp = L'\0';
920 
921  /*
922  * In the following we try to add pszLatest to the MRU list.
923  * We suppose that our caller has already correctly allocated
924  * the string with enough space for us to append a "\\1".
925  *
926  * FIXME: TODO! (At the moment we don't append it!)
927  */
928 
929  if (pszLatest)
930  {
931  if (wcsicmp(pszCmd, pszLatest) == 0)
932  {
933  SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd);
934  SetWindowTextW(hCb, pszCmd);
935  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
936 
937  cMatch = pszList[Nix];
938  memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
939  pszList[0] = cMatch;
940  continue;
941  }
942  }
943 
944  if (icList - 1 != 26 || icList - 2 != Nix || cMatch || pszLatest == NULL)
945  {
946  SendMessageW(hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd);
947  if (!Nix && fShowDefault)
948  {
949  SetWindowTextW(hCb, pszCmd);
950  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
951  }
952  }
953  else
954  {
955  SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
956  SetWindowTextW(hCb, pszLatest);
957  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
958 
959  cMatch = pszList[Nix];
960  memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
961  pszList[0] = cMatch;
962  szIndex[0] = cMatch;
963 
964  wcscpy(&pszLatest[cchLatest], L"\\1");
965  RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
966  pszLatest[cchLatest] = L'\0';
967  }
968  }
969 
970  if (!cMatch && pszLatest != NULL)
971  {
972  SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
973  SetWindowTextW(hCb, pszLatest);
974  SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
975 
976  cMatch = ++cMax;
977 
978  if (pszList)
979  {
980  pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszList, (++icList) * sizeof(WCHAR));
981  if (!pszTmp)
982  {
983  TRACE("HeapReAlloc failed to reallocate enough bytes\n");
984  goto Cleanup;
985  }
986  pszList = pszTmp;
987  }
988  else
989  {
990  pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (++icList) * sizeof(WCHAR));
991  if (!pszList)
992  {
993  TRACE("HeapAlloc failed to allocate enough bytes\n");
994  goto Cleanup;
995  }
996  }
997 
998  memmove(&pszList[1], pszList, (icList - 1) * sizeof(WCHAR));
999  pszList[0] = cMatch;
1000  szIndex[0] = cMatch;
1001 
1002  wcscpy(&pszLatest[cchLatest], L"\\1");
1003  RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
1004  pszLatest[cchLatest] = L'\0';
1005  }
1006 
1007 Cleanup:
1008  RegSetValueExW(hkey, L"MRUList", 0, REG_SZ, (LPBYTE)pszList, (wcslen(pszList) + 1) * sizeof(WCHAR));
1009 
1010  HeapFree(GetProcessHeap(), 0, pszCmd);
1011  HeapFree(GetProcessHeap(), 0, pszList);
1012 
1013  RegCloseKey(hkey);
1014 }
1015 
1016 
1017 /*************************************************************************
1018  * ConfirmDialog [internal]
1019  *
1020  * Put up a confirm box, return TRUE if the user confirmed
1021  */
1022 static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
1023 {
1024  WCHAR Prompt[256];
1025  WCHAR Title[256];
1026 
1027  LoadStringW(shell32_hInstance, PromptId, Prompt, _countof(Prompt));
1029  return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO | MB_ICONQUESTION) == IDYES;
1030 }
1031 
1033 
1034 BOOL
1036 {
1038  static BOOL Initialized = FALSE;
1039  if (!Initialized)
1040  {
1041  HMODULE mod = LoadLibraryW(L"msgina.dll");
1043  Initialized = TRUE;
1044  }
1045 
1046  HRESULT hr = E_FAIL;
1047  if (ShellDimScreen)
1048  hr = ShellDimScreen(pUnknown, hWindow);
1049  return SUCCEEDED(hr);
1050 }
1051 
1052 
1053 /* Used to get the shutdown privilege */
1054 static BOOL
1055 EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
1056 {
1057  BOOL Success;
1058  HANDLE hToken;
1060 
1063  &hToken);
1064  if (!Success) return Success;
1065 
1067  lpszPrivilegeName,
1068  &tp.Privileges[0].Luid);
1069  if (!Success) goto Quit;
1070 
1071  tp.PrivilegeCount = 1;
1072  tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
1073 
1074  Success = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
1075 
1076 Quit:
1077  CloseHandle(hToken);
1078  return Success;
1079 }
1080 
1081 /*************************************************************************
1082  * RestartDialogEx [SHELL32.730]
1083  */
1084 
1085 int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
1086 {
1087  TRACE("(%p)\n", hWndOwner);
1088 
1089  CComPtr<IUnknown> fadeHandler;
1090  HWND parent;
1091 
1092  if (!CallShellDimScreen(&fadeHandler, &parent))
1093  parent = hWndOwner;
1094 
1095  /* FIXME: use lpwstrReason */
1097  {
1098  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1099  ExitWindowsEx(EWX_REBOOT, uReason);
1100  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1101  }
1102 
1103  return 0;
1104 }
1105 
1106 /* Functions and macros used for fancy log off dialog box */
1107 #define IS_PRODUCT_VERSION_WORKSTATION 0x300
1108 #define FRIENDLY_LOGOFF_IS_NOT_ENFORCED 0x0
1109 
1110 #define FONT_POINT_SIZE 13
1111 
1112 #define DARK_GREY_COLOR RGB(244, 244, 244)
1113 #define LIGHT_GREY_COLOR RGB(38, 38, 38)
1114 
1115 /* Bitmap's size for buttons */
1116 #define CX_BITMAP 33
1117 #define CY_BITMAP 33
1118 
1119 #define NUMBER_OF_BUTTONS 2
1120 
1121 /* After determining the button as well as its state paint the image strip bitmap using these predefined positions */
1122 #define BUTTON_SWITCH_USER 0
1123 #define BUTTON_SWITCH_USER_PRESSED (CY_BITMAP + BUTTON_SWITCH_USER)
1124 #define BUTTON_SWITCH_USER_FOCUSED (CY_BITMAP + BUTTON_SWITCH_USER_PRESSED)
1125 #define BUTTON_LOG_OFF (CY_BITMAP + BUTTON_SWITCH_USER_FOCUSED)
1126 #define BUTTON_LOG_OFF_PRESSED (CY_BITMAP + BUTTON_LOG_OFF)
1127 #define BUTTON_LOG_OFF_FOCUSED (CY_BITMAP + BUTTON_LOG_OFF_PRESSED)
1128 #define BUTTON_SWITCH_USER_DISABLED (CY_BITMAP + BUTTON_LOG_OFF_FOCUSED) // Temporary
1129 
1131 {
1132  BOOL bRet = FALSE;
1133  HDC hdcMem = NULL;
1134  HBITMAP hbmOld = NULL;
1135  int y = 0;
1136  RECT rect;
1137 
1138  hdcMem = CreateCompatibleDC(pdis->hDC);
1139  hbmOld = (HBITMAP)SelectObject(hdcMem, pContext->hImageStrip);
1140  rect = pdis->rcItem;
1141 
1142  /* Check the button ID for revelant bitmap to be used */
1143  switch (pdis->CtlID)
1144  {
1145  case IDC_LOG_OFF_BUTTON:
1146  {
1147  switch (pdis->itemAction)
1148  {
1149  case ODA_DRAWENTIRE:
1150  case ODA_FOCUS:
1151  case ODA_SELECT:
1152  {
1153  y = BUTTON_LOG_OFF;
1154  if (pdis->itemState & ODS_SELECTED)
1155  {
1157  }
1158  else if (pContext->bIsButtonHot[0] || (pdis->itemState & ODS_FOCUS))
1159  {
1161  }
1162  break;
1163  }
1164  }
1165  break;
1166  }
1167 
1169  {
1170  switch (pdis->itemAction)
1171  {
1172  case ODA_DRAWENTIRE:
1173  case ODA_FOCUS:
1174  case ODA_SELECT:
1175  {
1177  if (pdis->itemState & ODS_SELECTED)
1178  {
1180  }
1181  else if (pContext->bIsButtonHot[1] || (pdis->itemState & ODS_FOCUS))
1182  {
1184  }
1185 
1186  /*
1187  * Since switch user functionality isn't implemented yet therefore the button has been disabled
1188  * temporarily hence show the disabled state
1189  */
1190  else if (pdis->itemState & ODS_DISABLED)
1191  {
1193  }
1194  break;
1195  }
1196  }
1197  break;
1198  }
1199  }
1200 
1201  /* Draw it on the required button */
1202  bRet = BitBlt(pdis->hDC,
1203  (rect.right - rect.left - CX_BITMAP) / 2,
1204  (rect.bottom - rect.top - CY_BITMAP) / 2,
1206 
1207  SelectObject(hdcMem, hbmOld);
1208  DeleteDC(hdcMem);
1209 
1210  return bRet;
1211 }
1212 
1214 {
1215  PLOGOFF_DLG_CONTEXT pContext;
1216  pContext = (PLOGOFF_DLG_CONTEXT)GetWindowLongPtrW(hButton, GWLP_USERDATA);
1217 
1218  int buttonID = GetDlgCtrlID(hButton);
1219 
1220  switch (uMsg)
1221  {
1222  case WM_MOUSEMOVE:
1223  {
1224  HWND hwndTarget = NULL;
1226 
1227  if (GetCapture() != hButton)
1228  {
1229  SetCapture(hButton);
1230  if (buttonID == IDC_LOG_OFF_BUTTON)
1231  {
1232  pContext->bIsButtonHot[0] = TRUE;
1233  }
1234  else if (buttonID == IDC_SWITCH_USER_BUTTON)
1235  {
1236  pContext->bIsButtonHot[1] = TRUE;
1237  }
1239  }
1240 
1241  ClientToScreen(hButton, &pt);
1242  hwndTarget = WindowFromPoint(pt);
1243 
1244  if (hwndTarget != hButton)
1245  {
1246  ReleaseCapture();
1247  if (buttonID == IDC_LOG_OFF_BUTTON)
1248  {
1249  pContext->bIsButtonHot[0] = FALSE;
1250  }
1251  else if (buttonID == IDC_SWITCH_USER_BUTTON)
1252  {
1253  pContext->bIsButtonHot[1] = FALSE;
1254  }
1255  }
1256  InvalidateRect(hButton, NULL, FALSE);
1257  break;
1258  }
1259 
1260  /* Whenever one of the buttons gets the keyboard focus, set it as default button */
1261  case WM_SETFOCUS:
1262  {
1263  SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
1264  break;
1265  }
1266 
1267  /* Otherwise, set IDCANCEL as default button */
1268  case WM_KILLFOCUS:
1269  {
1270  SendMessageW(GetParent(hButton), DM_SETDEFID, IDCANCEL, 0);
1271  break;
1272  }
1273  }
1274  return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
1275 }
1276 
1277 VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
1278 {
1279  HWND hwndTool = NULL, hwndTip = NULL;
1280  WCHAR szBuffer[256];
1281  TTTOOLINFOW tool;
1282 
1283  hwndTool = GetDlgItem(hDlg, controlID);
1284 
1285  tool.cbSize = sizeof(tool);
1286  tool.hwnd = hDlg;
1287  tool.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
1288  tool.uId = (UINT_PTR)hwndTool;
1289 
1290  /* Create the tooltip */
1291  hwndTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL,
1295  hDlg, NULL, shell32_hInstance, NULL);
1296 
1297  /* Associate the tooltip with the tool. */
1298  LoadStringW(shell32_hInstance, detailID, szBuffer, _countof(szBuffer));
1299  tool.lpszText = szBuffer;
1300  SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
1301  LoadStringW(shell32_hInstance, titleID, szBuffer, _countof(szBuffer));
1302  SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
1303  SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
1304 }
1305 
1307 {
1308  DWORD dwType = 0, dwValue = 0, dwSize = 0;
1309  HKEY hKey = NULL;
1310  LONG lRet = 0;
1311 
1313  L"SYSTEM\\CurrentControlSet\\Control\\Windows",
1314  0,
1316  &hKey);
1317  if (lRet != ERROR_SUCCESS)
1318  return FALSE;
1319 
1320  /* First check an optional ReactOS specific override, that Windows does not check.
1321  We use this to allow users pairing 'Server'-configuration with FriendlyLogoff.
1322  Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
1323  dwValue = 0;
1324  dwSize = sizeof(dwValue);
1325  lRet = RegQueryValueExW(hKey,
1326  L"EnforceFriendlyLogoff",
1327  NULL,
1328  &dwType,
1329  (LPBYTE)&dwValue,
1330  &dwSize);
1331 
1332  if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue != FRIENDLY_LOGOFF_IS_NOT_ENFORCED)
1333  {
1334  RegCloseKey(hKey);
1335  return TRUE;
1336  }
1337 
1338  /* Check product version number */
1339  dwValue = 0;
1340  dwSize = sizeof(dwValue);
1341  lRet = RegQueryValueExW(hKey,
1342  L"CSDVersion",
1343  NULL,
1344  &dwType,
1345  (LPBYTE)&dwValue,
1346  &dwSize);
1347  RegCloseKey(hKey);
1348 
1349  if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != IS_PRODUCT_VERSION_WORKSTATION)
1350  {
1351  /* Allow Friendly UI only on Workstation */
1352  return FALSE;
1353  }
1354 
1355  /* Check LogonType value */
1357  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
1358  0,
1360  &hKey);
1361  if (lRet != ERROR_SUCCESS)
1362  return FALSE;
1363 
1364  dwValue = 0;
1365  dwSize = sizeof(dwValue);
1366  lRet = RegQueryValueExW(hKey,
1367  L"LogonType",
1368  NULL,
1369  &dwType,
1370  (LPBYTE)&dwValue,
1371  &dwSize);
1372  RegCloseKey(hKey);
1373 
1374  if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
1375  return FALSE;
1376 
1377  return (dwValue != 0);
1378 }
1379 
1381 {
1382  HDC hdc = NULL;
1383  LONG lfHeight = NULL;
1384 
1385  hdc = GetDC(NULL);
1386  lfHeight = -MulDiv(FONT_POINT_SIZE, GetDeviceCaps(hdc, LOGPIXELSY), 72);
1387  ReleaseDC(NULL, hdc);
1388  pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
1390 
1392 
1394 
1397 
1398  /* Gather old button func */
1400 
1401  /* Make buttons to remember pContext and subclass the buttons as well as set bIsButtonHot boolean flags to false */
1402  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1403  {
1404  pContext->bIsButtonHot[i] = FALSE;
1407  }
1408 }
1409 
1410 /*************************************************************************
1411  * LogOffDialogProc
1412  *
1413  * NOTES: Used to make the Log Off dialog work
1414  */
1416 {
1418  PLOGOFF_DLG_CONTEXT pContext;
1420 
1421  switch (uMsg)
1422  {
1423  case WM_INITDIALOG:
1424  {
1425  pContext = (PLOGOFF_DLG_CONTEXT)lParam;
1427 
1428  if (pContext->bFriendlyUI)
1429  FancyLogoffOnInit(hwnd, pContext);
1430  return TRUE;
1431  }
1432 
1433  case WM_CLOSE:
1436  break;
1437 
1438  /*
1439  * If the user deactivates the log off dialog (it loses its focus
1440  * while the dialog is not being closed), then destroy the dialog
1441  * box.
1442  */
1443  case WM_ACTIVATE:
1444  {
1445  if (LOWORD(wParam) == WA_INACTIVE)
1446  {
1448  PostQuitMessage(0);
1449  }
1450  return FALSE;
1451  }
1452 
1453  case WM_COMMAND:
1454  switch (LOWORD(wParam))
1455  {
1456  case IDC_LOG_OFF_BUTTON:
1457  case IDOK:
1459  break;
1460 
1461  case IDCANCEL:
1464  break;
1465  }
1466  break;
1467 
1468  case WM_DESTROY:
1469  DeleteObject(pContext->hBrush);
1470  DeleteObject(pContext->hImageStrip);
1471  DeleteObject(pContext->hfFont);
1472 
1473  /* Remove the subclass from the buttons */
1474  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1475  {
1477  }
1478  return TRUE;
1479 
1480  case WM_CTLCOLORSTATIC:
1481  {
1482  /* Either make background transparent or fill it with color for required static controls */
1483  HDC hdcStatic = (HDC)wParam;
1484  UINT StaticID = (UINT)GetWindowLongPtrW((HWND)lParam, GWL_ID);
1485 
1486  switch (StaticID)
1487  {
1489  SetTextColor(hdcStatic, DARK_GREY_COLOR);
1490  SetBkMode(hdcStatic, TRANSPARENT);
1492 
1493  case IDC_LOG_OFF_STATIC:
1495  SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1496  SetBkMode(hdcStatic, TRANSPARENT);
1497  return (LONG_PTR)pContext->hBrush;
1498  }
1499  return FALSE;
1500  }
1501  break;
1502 
1503  case WM_DRAWITEM:
1504  {
1505  /* Draw bitmaps on required buttons */
1506  switch (pdis->CtlID)
1507  {
1508  case IDC_LOG_OFF_BUTTON:
1510  return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1511  }
1512  }
1513  break;
1514 
1515  default:
1516  break;
1517  }
1518  return FALSE;
1519 }
1520 
1521 /*************************************************************************
1522  * LogoffWindowsDialog [SHELL32.54]
1523  */
1524 
1526 {
1527  CComPtr<IUnknown> fadeHandler;
1528  BOOL bIsAltKeyPressed = FALSE;
1529  MSG Msg;
1530  HWND parent = NULL;
1531  HWND hWndChild = NULL;
1532  WCHAR szBuffer[30];
1533  DWORD LogoffDialogID = IDD_LOG_OFF;
1535 
1536  if (!CallShellDimScreen(&fadeHandler, &parent))
1537  parent = hWndOwner;
1538 
1539  Context.bFriendlyUI = IsFriendlyUIActive();
1540  if (Context.bFriendlyUI)
1541  {
1542  LogoffDialogID = IDD_LOG_OFF_FANCY;
1543  }
1544 
1547 
1548  /* Detect either Alt key has been pressed */
1549  while (GetMessageW(&Msg, NULL, 0, 0))
1550  {
1552  {
1555  }
1556 
1557  switch (Msg.message)
1558  {
1559  case WM_SYSKEYDOWN:
1560  {
1561  /* If the Alt key has been pressed once, add prefix to static controls */
1562  if (Msg.wParam == VK_MENU && !bIsAltKeyPressed && Context.bFriendlyUI)
1563  {
1564  for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1565  {
1566  GetDlgItemTextW(hWndChild, IDC_LOG_OFF_BUTTON + i, szBuffer, _countof(szBuffer));
1568  }
1569  bIsAltKeyPressed = TRUE;
1570  }
1571  }
1572  break;
1573  }
1574  }
1575  return 0;
1576 }
1577 
1578 /*************************************************************************
1579  * RestartDialog [SHELL32.59]
1580  */
1581 
1582 int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
1583 {
1584  return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
1585 }
1586 
1587 /*************************************************************************
1588  * ExitWindowsDialog_backup
1589  *
1590  * NOTES
1591  * Used as a backup solution to shutdown the OS in case msgina.dll
1592  * somehow cannot be found.
1593  */
1595 {
1596  TRACE("(%p)\n", hWndOwner);
1597 
1599  {
1600  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1602  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1603  }
1604 }
1605 
1606 /*************************************************************************
1607  * ExitWindowsDialog [SHELL32.60]
1608  *
1609  * NOTES
1610  * exported by ordinal
1611  */
1612 /*
1613  * TODO:
1614  * - Implement the ability to show either the Welcome Screen or the classic dialog boxes based upon the
1615  * registry value: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LogonType.
1616  */
1618 {
1619  typedef DWORD (WINAPI *ShellShFunc)(HWND hParent, WCHAR *Username, BOOL bHideLogoff);
1620  HINSTANCE msginaDll = LoadLibraryW(L"msgina.dll");
1621 
1622  TRACE("(%p)\n", hWndOwner);
1623 
1624  CComPtr<IUnknown> fadeHandler;
1625  HWND parent;
1626  if (!CallShellDimScreen(&fadeHandler, &parent))
1627  parent = hWndOwner;
1628 
1629  /* If the DLL cannot be found for any reason, then it simply uses a
1630  dialog box to ask if the user wants to shut down the computer. */
1631  if (!msginaDll)
1632  {
1633  TRACE("Unable to load msgina.dll.\n");
1635  return;
1636  }
1637 
1638  ShellShFunc pShellShutdownDialog = (ShellShFunc)GetProcAddress(msginaDll, "ShellShutdownDialog");
1639 
1640  if (pShellShutdownDialog)
1641  {
1642  /* Actually call the function */
1643  DWORD returnValue = pShellShutdownDialog(parent, NULL, FALSE);
1644 
1645  switch (returnValue)
1646  {
1647  case 0x01: /* Log off user */
1648  {
1650  break;
1651  }
1652  case 0x02: /* Shut down */
1653  {
1654  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1656  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1657  break;
1658  }
1659  case 0x03: /* Install Updates/Shutdown (?) */
1660  {
1661  break;
1662  }
1663  case 0x04: /* Reboot */
1664  {
1665  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1667  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1668  break;
1669  }
1670  case 0x10: /* Sleep */
1671  {
1672  if (IsPwrSuspendAllowed())
1673  {
1674  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1676  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1677  }
1678  break;
1679  }
1680  case 0x40: /* Hibernate */
1681  {
1682  if (IsPwrHibernateAllowed())
1683  {
1684  EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1686  EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1687  }
1688  break;
1689  }
1690  /* If the option is any other value */
1691  default:
1692  break;
1693  }
1694  }
1695  else
1696  {
1697  /* If the function cannot be found, then revert to using the backup solution */
1698  TRACE("Unable to find the 'ShellShutdownDialog' function");
1700  }
1701 
1702  FreeLibrary(msginaDll);
1703 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define IDC_LOG_OFF_STATIC
Definition: shresdef.h:481
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:681
#define SHACF_URLALL
Definition: shlwapi.h:1915
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define LB_SETCURSEL
Definition: winuser.h:2045
struct tagMEASUREITEMSTRUCT * LPMEASUREITEMSTRUCT
#define IDD_LOG_OFF_FANCY
Definition: shresdef.h:519
#define OFN_EXPLORER
Definition: commdlg.h:104
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define IDS_PICK_ICON_TITLE
Definition: shresdef.h:360
#define HRESULT
Definition: msvc.h:7
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define STM_SETICON
Definition: winuser.h:2074
#define IDC_RUNDLG_EDITPATH
Definition: shresdef.h:335
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
BOOL WINAPI TranslateMessage(_In_ const MSG *)
Definition: tftpd.h:59
#define RT_GROUP_ICON
Definition: pedump.c:375
static HICON
Definition: imagelist.c:84
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
static void FillList(HWND, LPWSTR, UINT, BOOL)
Definition: dialogs.cpp:791
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define IDOK
Definition: winuser.h:824
HFONT WINAPI CreateFontW(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR)
#define CloseHandle
Definition: compat.h:598
INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1213
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
#define CX_BITMAP
Definition: dialogs.cpp:1116
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define BUTTON_LOG_OFF_PRESSED
Definition: dialogs.cpp:1126
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2017
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2043
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define IDC_RUNDLG_ICON
Definition: shresdef.h:334
HRESULT hr
Definition: shlfolder.c:183
#define IDYES
Definition: winuser.h:829
GLuint64EXT * result
Definition: glext.h:11304
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
struct LOGOFF_DLG_CONTEXT * PLOGOFF_DLG_CONTEXT
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define LB_ADDSTRING
Definition: winuser.h:2013
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
HDC WINAPI GetDC(_In_opt_ HWND)
HWND hwndOwner
Definition: commdlg.h:330
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define SW_HIDE
Definition: winuser.h:762
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
#define GWL_ID
Definition: winuser.h:853
#define HKEY_CURRENT_USER
Definition: winreg.h:11
GLuint GLuint GLsizei count
Definition: gl.h:1545
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
#define SECL_NO_UI
static BOOL DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
Definition: dialogs.cpp:104
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1754
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define IDS_SHUTDOWN_PROMPT
Definition: shresdef.h:85
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
tShellDimScreen ShellDimScreen
#define INT
Definition: polytest.cpp:20
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:35
int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
Definition: dialogs.cpp:1085
GLdouble n
Definition: glext.h:7729
LONG top
Definition: windef.h:307
OPENFILENAME ofn
Definition: main.cpp:37
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define ODS_FOCUS
Definition: winuser.h:2524
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1664
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define DM_SETDEFID
Definition: winuser.h:2081
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LPCWSTR lpDirectory
Definition: undocshell.h:151
HWND WINAPI SetFocus(_In_opt_ HWND)
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
Definition: dialogs.cpp:1277
#define RF_OK
Definition: undocshell.h:160
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
static BOOL IsFriendlyUIActive(VOID)
Definition: dialogs.cpp:1306
HICON * phIcons
Definition: dialogs.cpp:65
#define SendDlgItemMessage
Definition: winuser.h:5817
#define TTS_BALLOON
Definition: commctrl.h:1761
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define VK_MENU
Definition: winuser.h:2179
#define GetWindowLongPtrW
Definition: winuser.h:4804
uint16_t * PWCHAR
Definition: typedefs.h:56
LONG left
Definition: windef.h:306
UINT uFlags
Definition: api.c:59
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDS_RUNDLG_BROWSE_ERROR
Definition: shresdef.h:193
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
int32_t INT_PTR
Definition: typedefs.h:64
#define EWX_REBOOT
Definition: winuser.h:633
#define IDS_LOG_OFF_TITLE
Definition: shresdef.h:325
#define IDS_RESTART_TITLE
Definition: shresdef.h:82
#define IDS_SWITCH_USER_TITLE
Definition: shresdef.h:326
#define ODA_FOCUS
Definition: winuser.h:2519
#define E_FAIL
Definition: ddrawi.h:102
#define BOOL
Definition: nt_native.h:43
#define RF_CANCEL
Definition: undocshell.h:161
BOOL WINAPI DestroyWindow(_In_ HWND)
#define LBN_SELCHANGE
Definition: winuser.h:2057
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define COLOR_WINDOW
Definition: winuser.h:908
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:58
#define SetWindowLongPtr
Definition: treelist.c:70
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
static void EnableOkButtonFromEditContents(HWND hwnd)
Definition: dialogs.cpp:491
#define EWX_LOGOFF
Definition: winuser.h:631
static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
Definition: dialogs.cpp:434
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
#define MB_ICONWARNING
Definition: winuser.h:780
DWORD nMaxFile
Definition: commdlg.h:337
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
UINT code
Definition: winuser.h:3134
#define IDC_LOG_OFF_BUTTON
Definition: shresdef.h:479
int WINAPI GetDlgCtrlID(_In_ HWND)
LPCWSTR lpstrDescription
Definition: dialogs.cpp:31
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
#define IDC_PICKICON_LIST
Definition: shresdef.h:357
HMODULE hLibrary
Definition: dialogs.cpp:60
#define LB_RESETCONTENT
Definition: winuser.h:2037
LPWSTR lpszText
Definition: commctrl.h:1746
#define IDC_RUNDLG_DESCRIPTION
Definition: shresdef.h:332
struct PICK_ICON_CONTEXT * PPICK_ICON_CONTEXT
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
#define EWX_SHUTDOWN
Definition: winuser.h:634
static const WCHAR szText[]
Definition: dialog.c:139
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define LB_ERR
Definition: winuser.h:2407
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define TTS_ALWAYSTIP
Definition: commctrl.h:1757
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:364
static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:169
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:872
UINT_PTR idFrom
Definition: winuser.h:3133
if SUCCEEDED(hr)
LPCWSTR lpDirectory
Definition: shellapi.h:332
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define IDS_RUNDLG_BROWSE_FILTER
Definition: shresdef.h:195
WNDPROC OldButtonProc
Definition: dialogs.cpp:43
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4677
HWND WINAPI GetCapture(void)
Definition: message.c:2880
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define FIXME(fmt,...)
Definition: debug.h:111
#define TTF_IDISHWND
Definition: commctrl.h:1764
static VOID FancyLogoffOnInit(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1380
#define TRANSPARENT
Definition: wingdi.h:949
#define CW_USEDEFAULT
Definition: winuser.h:225
#define GWLP_USERDATA
Definition: treelist.c:63
BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
Definition: dialogs.cpp:68
#define CB_ADDSTRING
Definition: winuser.h:1918
#define IDS_PICK_ICON_FILTER
Definition: shresdef.h:361
#define CB_INSERTSTRING
Definition: winuser.h:1939
#define IDC_RUNDLG_LABEL
Definition: shresdef.h:336
#define SHACF_FILESYSTEM
Definition: shlwapi.h:1912
#define LoadLibraryW(x)
Definition: compat.h:606
#define IDC_SWITCH_USER_BUTTON
Definition: shresdef.h:480
#define RFN_VALIDATE
Definition: undocshell.h:137
#define DARK_GREY_COLOR
Definition: dialogs.cpp:1112
#define MB_ICONQUESTION
Definition: winuser.h:783
#define IDC_SWITCH_USER_STATIC
Definition: shresdef.h:482
LONG_PTR LPARAM
Definition: windef.h:208
LPTSTR szFilter
Definition: mplay32.c:30
#define SECL_ALLOW_NONEXE
#define IDD_PICK_ICON
Definition: shresdef.h:356
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2263
#define CX_ITEM
Definition: dialogs.cpp:185
GLuint index
Definition: glext.h:6031
const char * LPCSTR
Definition: xmlstorage.h:183
#define BUTTON_SWITCH_USER_DISABLED
Definition: dialogs.cpp:1128
#define SW_SHOW
Definition: winuser.h:769
void WINAPI RunFileDlg(HWND hWndOwner, HICON hIcon, LPCWSTR lpstrDirectory, LPCWSTR lpstrTitle, LPCWSTR lpstrDescription, UINT uFlags)
Definition: dialogs.cpp:411
#define LB_GETCOUNT
Definition: winuser.h:2020
#define CB_RESETCONTENT
Definition: winuser.h:1941
#define CY_ICON
Definition: dialogs.cpp:182
#define WM_DESTROY
Definition: winuser.h:1591
static INT_PTR CALLBACK RunDlgProc(HWND, UINT, WPARAM, LPARAM)
Definition: dialogs.cpp:514
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
Definition: dialogs.cpp:1582
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define IDC_BUTTON_PATH
Definition: shresdef.h:358
#define ODA_DRAWENTIRE
Definition: winuser.h:2517
#define RFF_NOSEPARATEMEM
Definition: run.h:50
#define FW_MEDIUM
Definition: wingdi.h:374
#define IDC_HAND
Definition: winuser.h:693
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:607
#define ShellExecCmdLine
#define TTM_SETTITLEW
Definition: commctrl.h:1828
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
static const WCHAR Title[]
Definition: oid.c:1259
#define GetProcessHeap()
Definition: compat.h:595
#define CBN_EDITCHANGE
Definition: winuser.h:1957
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
Definition: dialogs.cpp:1022
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
#define IDS_SHUTDOWN_TITLE
Definition: shresdef.h:84
#define FONT_POINT_SIZE
Definition: dialogs.cpp:1110
#define LB_SETTOPINDEX
Definition: winuser.h:2052
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define ASSERT(a)
Definition: mode.c:44
r parent
Definition: btrfs.c:2944
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
void WINAPI ExitWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1617
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
#define ODS_DISABLED
Definition: winuser.h:2522
LONG HRESULT
Definition: typedefs.h:79
_In_ WDFCOLLECTION _In_ ULONG Index
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define _countof(array)
Definition: sndvol32.h:68
HBITMAP hImageStrip
Definition: dialogs.cpp:40
#define WM_CLOSE
Definition: winuser.h:1603
#define HOLLOW_BRUSH
Definition: wingdi.h:898
LPCWSTR lpFile
Definition: undocshell.h:150
#define TTI_NONE
Definition: commctrl.h:1779
UINT_PTR uId
Definition: commctrl.h:1743
#define MAX_PATH
Definition: compat.h:34
DWORD lStructSize
Definition: commdlg.h:329
#define EM_GETMODIFY
Definition: winuser.h:1976
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define WINAPI
Definition: msvc.h:6
#define LIGHT_GREY_COLOR
Definition: dialogs.cpp:1113
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1819
#define WM_MEASUREITEM
Definition: winuser.h:1628
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define RFF_NODEFAULT
Definition: run.h:47
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define IDC_EDIT_PATH
Definition: shresdef.h:359
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: dialogs.cpp:1055
#define LBN_DBLCLK
Definition: winuser.h:2053
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
static void DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:87
#define IDS_NO_ICONS
Definition: shresdef.h:309
WCHAR szPath[MAX_PATH]
Definition: dialogs.cpp:62
BOOL WINAPI EnumResourceNamesW(HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG_PTR lparam)
Definition: res.c:358
#define wcsicmp
Definition: compat.h:15
volatile int Continue
Definition: gdblib.c:102
#define IDD_RUN
Definition: shresdef.h:331
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define index(s, c)
Definition: various.h:29
static const WCHAR L[]
Definition: oid.c:1250
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
HDC hdc
Definition: main.c:9
struct _PICK_ICON_CONTEXT PICK_ICON_CONTEXT
INT_PTR CALLBACK LogOffDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1415
#define DWLP_USER
Definition: winuser.h:866
#define MB_ICONERROR
Definition: winuser.h:781
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define RFF_NOLABEL
Definition: run.h:49
HMODULE hLibrary
Definition: odbccp32.c:12
#define IDS_FILE_NOT_FOUND
Definition: shresdef.h:310
#define DI_NORMAL
Definition: wingdi.h:72
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define GetCurrentProcess()
Definition: compat.h:618
#define EM_SETMODIFY
Definition: winuser.h:1995
GLenum src
Definition: glext.h:6340
#define WM_COMMAND
Definition: winuser.h:1722
#define wcsrchr
Definition: compat.h:16
static const WCHAR Cleanup[]
Definition: register.c:80
#define IDS_RESTART_PROMPT
Definition: shresdef.h:83
HWND hwndFrom
Definition: winuser.h:3132
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define GWLP_WNDPROC
Definition: treelist.c:66
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define CX_ICON
Definition: dialogs.cpp:181
#define BUTTON_SWITCH_USER
Definition: dialogs.cpp:1122
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
#define ERR(fmt,...)
Definition: debug.h:110
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:339
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
HRESULT(WINAPI * tShellDimScreen)(IUnknown **Unknown, HWND *hWindow)
Definition: dialogs.cpp:1032
#define RFF_CALCDIRECTORY
Definition: run.h:48
HWND hwndEdit
Definition: combotst.c:65
BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1130
HWND WINAPI GetParent(_In_ HWND)
#define NUMBER_OF_BUTTONS
Definition: dialogs.cpp:1119
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define shell32_hInstance
#define IDS_SWITCH_USER_DESC
Definition: shresdef.h:324
#define WM_ACTIVATE
Definition: winuser.h:1594
#define BUTTON_LOG_OFF_FOCUSED
Definition: dialogs.cpp:1127
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
BOOL WINAPI DeleteDC(_In_ HDC)
struct @1599 Msg[]
LPSTR lpstrFile
Definition: commdlg.h:336
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define IS_PRODUCT_VERSION_WORKSTATION
Definition: dialogs.cpp:1107
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
HICON hIcon
Definition: msconfig.c:44
#define CB_SETEDITSEL
Definition: winuser.h:1945
FxAutoRegKey hKey
LPCWSTR szPath
Definition: env.c:37
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2132
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define TTM_ADDTOOLW
Definition: commctrl.h:1787
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapReAlloc
Definition: compat.h:593
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define ShellMessageBoxW
Definition: precomp.h:58
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define WS_POPUP
Definition: pedump.c:616
#define LB_GETCURSEL
Definition: winuser.h:2021
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define MB_OK
Definition: winuser.h:784
BOOL(WINAPI * LPFNOFN)(OPENFILENAMEW *)
Definition: dialogs.cpp:46
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
LPCWSTR lpstrTitle
Definition: dialogs.cpp:30
#define IDB_IMAGE_STRIP
Definition: resource.h:79
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HWND WINAPI WindowFromPoint(_In_ POINT)
static const LPCWSTR s_pszDefaultPath
Definition: dialogs.cpp:167
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
INT_PTR CALLBACK PickIconProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:188
#define BUTTON_LOG_OFF
Definition: dialogs.cpp:1125
#define WM_SETFONT
Definition: winuser.h:1632
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1869
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define WM_DRAWITEM
Definition: winuser.h:1627
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
LPCSTR lpstrTitle
Definition: commdlg.h:341
#define BUTTON_SWITCH_USER_PRESSED
Definition: dialogs.cpp:1123
struct tagContext Context
Definition: acpixf.h:1034
#define ODS_SELECTED
Definition: winuser.h:2520
#define SendMessage
Definition: winuser.h:5818
HMODULE hLibrary
Definition: dialog.c:549
GLuint res
Definition: glext.h:9613
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
#define SHACF_DEFAULT
Definition: shlwapi.h:1911
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_RUNDLG_BROWSE
Definition: resource.h:7
#define IDS_RUNDLG_BROWSE_CAPTION
Definition: shresdef.h:194
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define HIWORD(l)
Definition: typedefs.h:247
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define RFF_NOBROWSE
Definition: run.h:46
CAtlStringW CStringW
Definition: atlstr.h:130
LPCWSTR lpstrDirectory
Definition: dialogs.cpp:29
#define GetProcAddress(x, y)
Definition: compat.h:612
#define LOGPIXELSY
Definition: wingdi.h:718
#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED
Definition: dialogs.cpp:1108
static char * dest
Definition: rtl.c:135
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:1917
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define WA_INACTIVE
Definition: winuser.h:2597
EXTERN_C int WINAPI LogoffWindowsDialog(HWND hWndOwner)
Definition: dialogs.cpp:1525
static HBITMAP
Definition: button.c:44
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
VOID ExitWindowsDialog_backup(HWND hWndOwner)
Definition: dialogs.cpp:1594
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_SETFOCUS
Definition: winuser.h:1595
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define EXTERN_C
Definition: basetyps.h:12
#define IDD_LOG_OFF
Definition: shresdef.h:513
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HWND hWndChild[NUM_TABS]
Definition: main.h:75
#define OFN_ENABLESIZING
Definition: commdlg.h:101
BOOL CallShellDimScreen(IUnknown **pUnknown, HWND *hWindow)
Definition: dialogs.cpp:1035
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
#define REG_DWORD
Definition: sdbapi.c:596
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:880
#define CY_BITMAP
Definition: dialogs.cpp:1117
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define LOWORD(l)
Definition: pedump.c:82
#define TTF_SUBCLASS
Definition: commctrl.h:1767
#define HeapFree(x, y, z)
Definition: compat.h:594
BOOL WINAPI IsDialogMessageW(_In_ HWND, _In_ LPMSG)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SRCCOPY
Definition: wingdi.h:332
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define IDS_LOG_OFF_DESC
Definition: shresdef.h:323
#define CY_ITEM
Definition: dialogs.cpp:186
#define ODA_SELECT
Definition: winuser.h:2518
HDC hdcMem
Definition: welcome.c:104
static int mod
Definition: i386-dis.c:1281
#define WM_NOTIFY
Definition: richedit.h:61
#define BUTTON_SWITCH_USER_FOCUSED
Definition: dialogs.cpp:1124
#define IDI_SHELL_RUN
Definition: shresdef.h:546
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
BOOL bIsButtonHot[2]
Definition: dialogs.cpp:39
HMODULE hModule
Definition: animate.c:44
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
DWORD Flags
Definition: commdlg.h:342
#define IDC_LOG_OFF_TEXT_STATIC
Definition: shresdef.h:483
#define REG_SZ
Definition: layer.c:22
#define RF_RETRY
Definition: undocshell.h:162