ReactOS 0.4.16-dev-853-g88d9285
dialogs.cpp File Reference
#include "precomp.h"
Include dependency graph for dialogs.cpp:

Go to the source code of this file.

Classes

struct  RUNFILEDLGPARAMS
 
struct  LOGOFF_DLG_CONTEXT
 
struct  PICK_ICON_CONTEXT
 

Macros

#define CX_ICON   GetSystemMetrics(SM_CXICON)
 
#define CY_ICON   GetSystemMetrics(SM_CYICON)
 
#define CX_ITEM   (CX_ICON + 4)
 
#define CY_ITEM   (CY_ICON + 12)
 
#define IS_PRODUCT_VERSION_WORKSTATION   0x300
 
#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED   0x0
 
#define FONT_POINT_SIZE   13
 
#define DARK_GREY_COLOR   RGB(244, 244, 244)
 
#define LIGHT_GREY_COLOR   RGB(38, 38, 38)
 
#define CX_BITMAP   33
 
#define CY_BITMAP   33
 
#define NUMBER_OF_BUTTONS   2
 
#define BUTTON_SWITCH_USER   0
 
#define BUTTON_SWITCH_USER_PRESSED   (CY_BITMAP + BUTTON_SWITCH_USER)
 
#define BUTTON_SWITCH_USER_FOCUSED   (CY_BITMAP + BUTTON_SWITCH_USER_PRESSED)
 
#define BUTTON_LOG_OFF   (CY_BITMAP + BUTTON_SWITCH_USER_FOCUSED)
 
#define BUTTON_LOG_OFF_PRESSED   (CY_BITMAP + BUTTON_LOG_OFF)
 
#define BUTTON_LOG_OFF_FOCUSED   (CY_BITMAP + BUTTON_LOG_OFF_PRESSED)
 
#define BUTTON_SWITCH_USER_DISABLED   (CY_BITMAP + BUTTON_LOG_OFF_FOCUSED)
 
#define LOG_OFF_BUTTON_HOT   0
 
#define SWITCH_USER_BUTTON_HOT   1
 

Typedefs

typedef struct LOGOFF_DLG_CONTEXTPLOGOFF_DLG_CONTEXT
 
typedef BOOL(WINAPILPFNOFN) (OPENFILENAMEW *)
 
typedef struct PICK_ICON_CONTEXTPPICK_ICON_CONTEXT
 
typedef HRESULT(WINAPItShellDimScreen) (IUnknown **Unknown, HWND *hWindow)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static INT_PTR CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM)
 
static void FillList (HWND, LPWSTR, UINT, BOOL)
 
BOOL CALLBACK EnumPickIconResourceProc (HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
 
static void DestroyIconList (HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
 
static BOOL DoLoadIcons (HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
 
static void NoIconsInFile (HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
 
INT_PTR CALLBACK PickIconProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI PickIconDlg (HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
 
void WINAPI RunFileDlg (HWND hWndOwner, HICON hIcon, LPCWSTR lpstrDirectory, LPCWSTR lpstrTitle, LPCWSTR lpstrDescription, UINT uFlags)
 
static LPWSTR RunDlg_GetParentDir (LPCWSTR cmdline)
 
static void EnableOkButtonFromEditContents (HWND hwnd)
 
static BOOL ConfirmDialog (HWND hWndOwner, UINT PromptId, UINT TitleId)
 
BOOL CallShellDimScreen (IUnknown **pUnknown, HWND *hWindow)
 
static BOOL EnablePrivilege (LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
 
int WINAPI RestartDialogEx (HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
 
BOOL DrawIconOnOwnerDrawnButtons (DRAWITEMSTRUCT *pdis, PLOGOFF_DLG_CONTEXT pContext)
 
INT_PTR CALLBACK OwnerDrawButtonSubclass (HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID CreateToolTipForButtons (int controlID, int detailID, HWND hDlg, int titleID)
 
VOID EndFriendlyDialog (HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
 
static BOOL IsFriendlyUIActive (VOID)
 
static VOID FancyLogoffOnInit (HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
 
INT_PTR CALLBACK LogOffDialogProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
EXTERN_C int WINAPI LogoffWindowsDialog (HWND hWndOwner)
 
int WINAPI RestartDialog (HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
 
VOID ExitWindowsDialog_backup (HWND hWndOwner)
 
void WINAPI ExitWindowsDialog (HWND hWndOwner)
 

Macro Definition Documentation

◆ BUTTON_LOG_OFF

#define BUTTON_LOG_OFF   (CY_BITMAP + BUTTON_SWITCH_USER_FOCUSED)

Definition at line 1109 of file dialogs.cpp.

◆ BUTTON_LOG_OFF_FOCUSED

#define BUTTON_LOG_OFF_FOCUSED   (CY_BITMAP + BUTTON_LOG_OFF_PRESSED)

Definition at line 1111 of file dialogs.cpp.

◆ BUTTON_LOG_OFF_PRESSED

#define BUTTON_LOG_OFF_PRESSED   (CY_BITMAP + BUTTON_LOG_OFF)

Definition at line 1110 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER

#define BUTTON_SWITCH_USER   0

Definition at line 1106 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER_DISABLED

#define BUTTON_SWITCH_USER_DISABLED   (CY_BITMAP + BUTTON_LOG_OFF_FOCUSED)

Definition at line 1112 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER_FOCUSED

#define BUTTON_SWITCH_USER_FOCUSED   (CY_BITMAP + BUTTON_SWITCH_USER_PRESSED)

Definition at line 1108 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER_PRESSED

#define BUTTON_SWITCH_USER_PRESSED   (CY_BITMAP + BUTTON_SWITCH_USER)

Definition at line 1107 of file dialogs.cpp.

◆ CX_BITMAP

#define CX_BITMAP   33

Definition at line 1100 of file dialogs.cpp.

◆ CX_ICON

Definition at line 178 of file dialogs.cpp.

◆ CX_ITEM

#define CX_ITEM   (CX_ICON + 4)

Definition at line 182 of file dialogs.cpp.

◆ CY_BITMAP

#define CY_BITMAP   33

Definition at line 1101 of file dialogs.cpp.

◆ CY_ICON

Definition at line 179 of file dialogs.cpp.

◆ CY_ITEM

#define CY_ITEM   (CY_ICON + 12)

Definition at line 183 of file dialogs.cpp.

◆ DARK_GREY_COLOR

#define DARK_GREY_COLOR   RGB(244, 244, 244)

Definition at line 1096 of file dialogs.cpp.

◆ FONT_POINT_SIZE

#define FONT_POINT_SIZE   13

Definition at line 1094 of file dialogs.cpp.

◆ FRIENDLY_LOGOFF_IS_NOT_ENFORCED

#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED   0x0

Definition at line 1092 of file dialogs.cpp.

◆ IS_PRODUCT_VERSION_WORKSTATION

#define IS_PRODUCT_VERSION_WORKSTATION   0x300

Definition at line 1091 of file dialogs.cpp.

◆ LIGHT_GREY_COLOR

#define LIGHT_GREY_COLOR   RGB(38, 38, 38)

Definition at line 1097 of file dialogs.cpp.

◆ LOG_OFF_BUTTON_HOT

#define LOG_OFF_BUTTON_HOT   0

Definition at line 1115 of file dialogs.cpp.

◆ NUMBER_OF_BUTTONS

#define NUMBER_OF_BUTTONS   2

Definition at line 1103 of file dialogs.cpp.

◆ SWITCH_USER_BUTTON_HOT

#define SWITCH_USER_BUTTON_HOT   1

Definition at line 1116 of file dialogs.cpp.

Typedef Documentation

◆ LPFNOFN

typedef BOOL(WINAPI * LPFNOFN) (OPENFILENAMEW *)

Definition at line 46 of file dialogs.cpp.

◆ PLOGOFF_DLG_CONTEXT

◆ PPICK_ICON_CONTEXT

◆ tShellDimScreen

typedef HRESULT(WINAPI * tShellDimScreen) (IUnknown **Unknown, HWND *hWindow)

Definition at line 1016 of file dialogs.cpp.

Function Documentation

◆ CallShellDimScreen()

BOOL CallShellDimScreen ( IUnknown **  pUnknown,
HWND hWindow 
)

Definition at line 1019 of file dialogs.cpp.

1020{
1022 static BOOL Initialized = FALSE;
1023 if (!Initialized)
1024 {
1025 HMODULE mod = LoadLibraryW(L"msgina.dll");
1027 Initialized = TRUE;
1028 }
1029
1030 HRESULT hr = E_FAIL;
1031 if (ShellDimScreen)
1032 hr = ShellDimScreen(pUnknown, hWindow);
1033 return SUCCEEDED(hr);
1034}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
tShellDimScreen ShellDimScreen
#define E_FAIL
Definition: ddrawi.h:102
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
HRESULT(WINAPI * tShellDimScreen)(IUnknown **Unknown, HWND *hWindow)
Definition: dialogs.cpp:1016
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SUCCEEDED(hr)
Definition: intsafe.h:50
@ Initialized
Definition: ketypes.h:388
#define L(x)
Definition: ntvdm.h:50
HRESULT hr
Definition: shlfolder.c:183
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by ExitWindowsDialog(), LogoffWindowsDialog(), and RestartDialogEx().

◆ ConfirmDialog()

static BOOL ConfirmDialog ( HWND  hWndOwner,
UINT  PromptId,
UINT  TitleId 
)
static

Definition at line 1006 of file dialogs.cpp.

1007{
1008 WCHAR Prompt[256];
1009 WCHAR Title[256];
1010
1011 LoadStringW(shell32_hInstance, PromptId, Prompt, _countof(Prompt));
1013 return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO | MB_ICONQUESTION) == IDYES;
1014}
#define shell32_hInstance
UINT TitleId
Definition: desktop.c:52
static const WCHAR Title[]
Definition: oid.c:1259
#define _countof(array)
Definition: sndvol32.h:70
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MB_YESNO
Definition: winuser.h:820
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONQUESTION
Definition: winuser.h:792
#define IDYES
Definition: winuser.h:838
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ExitWindowsDialog_backup(), and RestartDialogEx().

◆ CreateToolTipForButtons()

VOID CreateToolTipForButtons ( int  controlID,
int  detailID,
HWND  hDlg,
int  titleID 
)

Definition at line 1277 of file dialogs.cpp.

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;
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}
#define NULL
Definition: types.h:112
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WS_POPUP
Definition: pedump.c:616
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
#define TTI_NONE
Definition: commctrl.h:1779
#define TTM_SETTITLEW
Definition: commctrl.h:1833
#define TTF_IDISHWND
Definition: commctrl.h:1764
#define TTF_SUBCLASS
Definition: commctrl.h:1767
#define TTM_ADDTOOLW
Definition: commctrl.h:1792
#define TTS_ALWAYSTIP
Definition: commctrl.h:1757
#define TTM_SETMAXTIPWIDTH
Definition: commctrl.h:1824
#define TTS_BALLOON
Definition: commctrl.h:1761
UINT_PTR uId
Definition: commctrl.h:1743
LPWSTR lpszText
Definition: commctrl.h:1746
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
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)
#define CW_USEDEFAULT
Definition: winuser.h:225
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by FancyLogoffOnInit().

◆ DestroyIconList()

static void DestroyIconList ( HWND  hDlgCtrl,
PPICK_ICON_CONTEXT  pIconContext 
)
static

Definition at line 87 of file dialogs.cpp.

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}
#define index(s, c)
Definition: various.h:29
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
#define LB_ERR
Definition: winuser.h:2435
#define LB_GETCOUNT
Definition: winuser.h:2041
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2139

Referenced by DoLoadIcons(), and PickIconProc().

◆ DoLoadIcons()

static BOOL DoLoadIcons ( HWND  hwndDlg,
PPICK_ICON_CONTEXT  pIconContext,
LPCWSTR  pszFile 
)
static

Definition at line 104 of file dialogs.cpp.

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 SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
155 SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
156
157 if (pIconContext->nIcons == 0)
158 {
159 delete[] pIconContext->phIcons;
160 pIconContext->phIcons = NULL;
161 }
162
163 return (pIconContext->nIcons > 0);
164}
HMODULE hLibrary
Definition: odbccp32.c:12
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
BOOL WINAPI EnumResourceNamesW(HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG_PTR lparam)
Definition: res.c:358
BOOL CALLBACK EnumPickIconResourceProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
Definition: dialogs.cpp:68
static void DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:87
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:855
static HICON
Definition: imagelist.c:80
#define RT_GROUP_ICON
Definition: pedump.c:375
#define IDC_EDIT_PATH
Definition: shresdef.h:394
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
HMODULE hLibrary
Definition: dialog.c:549
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:368
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define LB_ADDSTRING
Definition: winuser.h:2034
#define LB_RESETCONTENT
Definition: winuser.h:2058
#define LB_SETCURSEL
Definition: winuser.h:2066

Referenced by NoIconsInFile(), and PickIconProc().

◆ DrawIconOnOwnerDrawnButtons()

BOOL DrawIconOnOwnerDrawnButtons ( DRAWITEMSTRUCT pdis,
PLOGOFF_DLG_CONTEXT  pContext 
)

Definition at line 1118 of file dialogs.cpp.

1119{
1120 BOOL bRet = FALSE;
1121 HDC hdcMem = NULL;
1122 HBITMAP hbmOld = NULL;
1123 int y = 0;
1124 RECT rect;
1125
1126 hdcMem = CreateCompatibleDC(pdis->hDC);
1127 hbmOld = (HBITMAP)SelectObject(hdcMem, pContext->hImageStrip);
1128 rect = pdis->rcItem;
1129
1130 /* Check the button ID for revelant bitmap to be used */
1131 switch (pdis->CtlID)
1132 {
1133 case IDC_LOG_OFF_BUTTON:
1134 {
1135 switch (pdis->itemAction)
1136 {
1137 case ODA_DRAWENTIRE:
1138 case ODA_FOCUS:
1139 case ODA_SELECT:
1140 {
1141 y = BUTTON_LOG_OFF;
1142 if (pdis->itemState & ODS_SELECTED)
1143 {
1145 }
1146 else if (pContext->bIsButtonHot[LOG_OFF_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1147 {
1149 }
1150 break;
1151 }
1152 }
1153 break;
1154 }
1155
1157 {
1158 switch (pdis->itemAction)
1159 {
1160 case ODA_DRAWENTIRE:
1161 case ODA_FOCUS:
1162 case ODA_SELECT:
1163 {
1165 if (pdis->itemState & ODS_SELECTED)
1166 {
1168 }
1169 else if (pContext->bIsButtonHot[SWITCH_USER_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1170 {
1172 }
1173
1174 /*
1175 * Since switch user functionality isn't implemented yet therefore the button has been disabled
1176 * temporarily hence show the disabled state
1177 */
1178 else if (pdis->itemState & ODS_DISABLED)
1179 {
1181 }
1182 break;
1183 }
1184 }
1185 break;
1186 }
1187 }
1188
1189 /* Draw it on the required button */
1190 bRet = BitBlt(pdis->hDC,
1191 (rect.right - rect.left - CX_BITMAP) / 2,
1192 (rect.bottom - rect.top - CY_BITMAP) / 2,
1194
1195 SelectObject(hdcMem, hbmOld);
1197
1198 return bRet;
1199}
#define BUTTON_SWITCH_USER_DISABLED
Definition: dialogs.cpp:1112
#define CX_BITMAP
Definition: dialogs.cpp:1100
#define LOG_OFF_BUTTON_HOT
Definition: dialogs.cpp:1115
#define BUTTON_SWITCH_USER
Definition: dialogs.cpp:1106
#define BUTTON_LOG_OFF_FOCUSED
Definition: dialogs.cpp:1111
#define BUTTON_LOG_OFF
Definition: dialogs.cpp:1109
#define CY_BITMAP
Definition: dialogs.cpp:1101
#define SWITCH_USER_BUTTON_HOT
Definition: dialogs.cpp:1116
#define BUTTON_SWITCH_USER_PRESSED
Definition: dialogs.cpp:1107
#define BUTTON_LOG_OFF_PRESSED
Definition: dialogs.cpp:1110
#define BUTTON_SWITCH_USER_FOCUSED
Definition: dialogs.cpp:1108
static VOID 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:57
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define IDC_LOG_OFF_BUTTON
Definition: shresdef.h:514
#define IDC_SWITCH_USER_BUTTON
Definition: shresdef.h:515
& rect
Definition: startmenu.cpp:1413
BOOL bIsButtonHot[2]
Definition: dialogs.cpp:39
HBITMAP hImageStrip
Definition: dialogs.cpp:40
HDC hdcMem
Definition: welcome.c:104
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
#define ODS_DISABLED
Definition: winuser.h:2550
#define ODS_SELECTED
Definition: winuser.h:2548
#define ODA_DRAWENTIRE
Definition: winuser.h:2545
#define ODA_FOCUS
Definition: winuser.h:2547
#define ODA_SELECT
Definition: winuser.h:2546
#define ODS_FOCUS
Definition: winuser.h:2552

Referenced by LogOffDialogProc().

◆ EnableOkButtonFromEditContents()

static void EnableOkButtonFromEditContents ( HWND  hwnd)
static

Definition at line 478 of file dialogs.cpp.

479{
480 BOOL Enable = FALSE;
481 INT Length, n;
484 if (Length > 0)
485 {
486 PWCHAR psz = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR));
487 if (psz)
488 {
489 GetWindowTextW(Edit, psz, Length + 1);
490 for (n = 0; n < Length && !Enable; ++n)
491 Enable = psz[n] != ' ';
492 HeapFree(GetProcessHeap(), 0, psz);
493 }
494 else
495 Enable = TRUE;
496 }
498}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLdouble n
Definition: glext.h:7729
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
#define IDC_RUNDLG_EDITPATH
Definition: shresdef.h:370
int32_t INT
Definition: typedefs.h:58
uint16_t * PWCHAR
Definition: typedefs.h:56
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1394
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define IDOK
Definition: winuser.h:833
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
int WINAPI GetWindowTextLengthW(_In_ HWND)

Referenced by RunDlgProc().

◆ EnablePrivilege()

static BOOL EnablePrivilege ( LPCWSTR  lpszPrivilegeName,
BOOL  bEnablePrivilege 
)
static

Definition at line 1039 of file dialogs.cpp.

1040{
1041 BOOL Success;
1042 HANDLE hToken;
1044
1047 &hToken);
1048 if (!Success) return Success;
1049
1051 lpszPrivilegeName,
1052 &tp.Privileges[0].Luid);
1053 if (!Success) goto Quit;
1054
1055 tp.PrivilegeCount = 1;
1056 tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
1057
1058 Success = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
1059
1060Quit:
1061 CloseHandle(hToken);
1062 return Success;
1063}
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
@ Success
Definition: eventcreate.c:712
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by ExitWindowsDialog(), ExitWindowsDialog_backup(), and RestartDialogEx().

◆ EndFriendlyDialog()

VOID EndFriendlyDialog ( HWND  hwnd,
PLOGOFF_DLG_CONTEXT  pContext 
)

Definition at line 1306 of file dialogs.cpp.

1307{
1308 DeleteObject(pContext->hBrush);
1309 DeleteObject(pContext->hImageStrip);
1310 DeleteObject(pContext->hfFont);
1311
1312 /* Remove the subclass from the buttons */
1313 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1314 {
1317 (LONG_PTR)pContext->OldButtonProc);
1318 }
1319}
#define NUMBER_OF_BUTTONS
Definition: dialogs.cpp:1103
pKey DeleteObject()
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
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
WNDPROC OldButtonProc
Definition: dialogs.cpp:43
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SetWindowLongPtrW
Definition: winuser.h:5358

Referenced by LogOffDialogProc().

◆ EnumPickIconResourceProc()

BOOL CALLBACK EnumPickIconResourceProc ( HMODULE  hModule,
LPCWSTR  lpszType,
LPWSTR  lpszName,
LONG_PTR  lParam 
)

Definition at line 68 of file dialogs.cpp.

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}
LPARAM lParam
Definition: combotst.c:139
struct PICK_ICON_CONTEXT * PPICK_ICON_CONTEXT
#define LOWORD(l)
Definition: pedump.c:82
#define IS_INTRESOURCE(i)
Definition: winuser.h:580

Referenced by DoLoadIcons().

◆ ExitWindowsDialog()

void WINAPI ExitWindowsDialog ( HWND  hWndOwner)

Definition at line 1595 of file dialogs.cpp.

1596{
1597 typedef DWORD (WINAPI *ShellShFunc)(HWND hParent, WCHAR *Username, BOOL bHideLogoff);
1598 HINSTANCE msginaDll = LoadLibraryW(L"msgina.dll");
1599
1600 TRACE("(%p)\n", hWndOwner);
1601
1602 CComPtr<IUnknown> fadeHandler;
1603 HWND parent;
1604 if (!CallShellDimScreen(&fadeHandler, &parent))
1605 parent = hWndOwner;
1606
1607 /* If the DLL cannot be found for any reason, then it simply uses a
1608 dialog box to ask if the user wants to shut down the computer. */
1609 if (!msginaDll)
1610 {
1611 TRACE("Unable to load msgina.dll.\n");
1613 return;
1614 }
1615
1616 ShellShFunc pShellShutdownDialog = (ShellShFunc)GetProcAddress(msginaDll, "ShellShutdownDialog");
1617
1618 if (pShellShutdownDialog)
1619 {
1620 /* Actually call the function */
1621 DWORD returnValue = pShellShutdownDialog(parent, NULL, FALSE);
1622
1623 switch (returnValue)
1624 {
1625 case 0x01: /* Log off user */
1626 {
1628 break;
1629 }
1630 case 0x02: /* Shut down */
1631 {
1632 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1634 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1635 break;
1636 }
1637 case 0x03: /* Install Updates/Shutdown (?) */
1638 {
1639 break;
1640 }
1641 case 0x04: /* Reboot */
1642 {
1643 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1645 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1646 break;
1647 }
1648 case 0x10: /* Sleep */
1649 {
1650 if (IsPwrSuspendAllowed())
1651 {
1652 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1654 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1655 }
1656 break;
1657 }
1658 case 0x40: /* Hibernate */
1659 {
1661 {
1662 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1664 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1665 }
1666 break;
1667 }
1668 /* If the option is any other value */
1669 default:
1670 break;
1671 }
1672 }
1673 else
1674 {
1675 /* If the function cannot be found, then revert to using the backup solution */
1676 TRACE("Unable to find the 'ShellShutdownDialog' function");
1678 }
1679
1680 FreeLibrary(msginaDll);
1681}
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: dialogs.cpp:1039
VOID ExitWindowsDialog_backup(HWND hWndOwner)
Definition: dialogs.cpp:1572
BOOL CallShellDimScreen(IUnknown **pUnknown, HWND *hWindow)
Definition: dialogs.cpp:1019
r parent
Definition: btrfs.c:3010
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
BOOLEAN WINAPI IsPwrHibernateAllowed(VOID)
Definition: powrprof.c:450
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:792
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
#define TRACE(s)
Definition: solgame.cpp:4
#define WINAPI
Definition: msvc.h:6
#define EWX_SHUTDOWN
Definition: winuser.h:639
#define EWX_LOGOFF
Definition: winuser.h:636
#define EWX_REBOOT
Definition: winuser.h:638
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)

Referenced by CTrayWindow::DoExitWindows(), ShowExitWindowsDialog(), and CShellDispatch::ShutdownWindows().

◆ ExitWindowsDialog_backup()

VOID ExitWindowsDialog_backup ( HWND  hWndOwner)

Definition at line 1572 of file dialogs.cpp.

1573{
1574 TRACE("(%p)\n", hWndOwner);
1575
1577 {
1578 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1580 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1581 }
1582}
static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
Definition: dialogs.cpp:1006
#define IDS_SHUTDOWN_TITLE
Definition: shresdef.h:82
#define IDS_SHUTDOWN_PROMPT
Definition: shresdef.h:83

Referenced by ExitWindowsDialog().

◆ FancyLogoffOnInit()

static VOID FancyLogoffOnInit ( HWND  hwnd,
PLOGOFF_DLG_CONTEXT  pContext 
)
static

Definition at line 1395 of file dialogs.cpp.

1396{
1397 HDC hdc = NULL;
1398 LONG lfHeight = NULL;
1399
1400 hdc = GetDC(NULL);
1402 ReleaseDC(NULL, hdc);
1403 pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
1405
1407
1409
1410 /* Gather old button func */
1412
1413 /* Set bIsButtonHot to false, create tooltips for each buttons and subclass the buttons */
1414 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1415 {
1416 pContext->bIsButtonHot[i] = FALSE;
1422 hwnd,
1424 }
1425}
#define IDB_IMAGE_STRIP
Definition: resource.h:79
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
Definition: dialogs.cpp:1277
#define DARK_GREY_COLOR
Definition: dialogs.cpp:1096
INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1201
#define FONT_POINT_SIZE
Definition: dialogs.cpp:1094
HDC hdc
Definition: main.c:9
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
long LONG
Definition: pedump.c:60
#define IDS_LOG_OFF_TITLE
Definition: shresdef.h:360
#define IDC_LOG_OFF_TEXT_STATIC
Definition: shresdef.h:518
#define IDS_LOG_OFF_DESC
Definition: shresdef.h:358
UINT_PTR WPARAM
Definition: windef.h:207
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
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)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define FW_MEDIUM
Definition: wingdi.h:375
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define GetWindowLongPtrW
Definition: winuser.h:4832
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETFONT
Definition: winuser.h:1653
HDC WINAPI GetDC(_In_opt_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2249

Referenced by LogOffDialogProc().

◆ FillList()

static void FillList ( HWND  hCb,
LPWSTR  pszLatest,
UINT  cchStr,
BOOL  fShowDefault 
)
static

Definition at line 775 of file dialogs.cpp.

776{
777 HKEY hkey;
778 WCHAR *pszList = NULL, *pszCmd = NULL, *pszTmp = NULL, cMatch = 0, cMax = 0x60;
779 WCHAR szIndex[2] = L"-";
780 UINT cchLatest;
781 DWORD dwType, icList = 0, icCmd = 0;
782 LRESULT lRet;
783 UINT Nix;
784
785 /*
786 * Retrieve the string length of pszLatest and check whether its buffer size
787 * (cchStr in number of characters) is large enough to add the terminating "\\1"
788 * (and the NULL character).
789 */
790 if (pszLatest)
791 {
792 cchLatest = wcslen(pszLatest);
793 if (cchStr < cchLatest + 2 + 1)
794 {
795 TRACE("pszLatest buffer is not large enough (%d) to hold the MRU terminator.\n", cchStr);
796 return;
797 }
798 }
799 else
800 {
801 cchStr = 0;
802 }
803
804 SendMessageW(hCb, CB_RESETCONTENT, 0, 0);
805
807 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
809 if (lRet != ERROR_SUCCESS)
810 {
811 TRACE("Unable to open or create the RunMRU key, error %d\n", GetLastError());
812 return;
813 }
814
815 lRet = RegQueryValueExW(hkey, L"MRUList", NULL, &dwType, NULL, &icList);
816 if (lRet == ERROR_SUCCESS && dwType == REG_SZ && icList > sizeof(WCHAR))
817 {
818 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
819 if (!pszList)
820 {
821 TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
822 goto Continue;
823 }
824 pszList[0] = L'\0';
825
826 lRet = RegQueryValueExW(hkey, L"MRUList", NULL, NULL, (LPBYTE)pszList, &icList);
827 if (lRet != ERROR_SUCCESS)
828 {
829 TRACE("Unable to grab MRUList, error %d\n", GetLastError());
830 pszList[0] = L'\0';
831 }
832 }
833 else
834 {
835Continue:
836 icList = sizeof(WCHAR);
837 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icList);
838 if (!pszList)
839 {
840 TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
841 RegCloseKey(hkey);
842 return;
843 }
844 pszList[0] = L'\0';
845 }
846
847 /* Convert the number of bytes from MRUList into number of characters (== number of indices) */
848 icList /= sizeof(WCHAR);
849
850 for (Nix = 0; Nix < icList - 1; Nix++)
851 {
852 if (pszList[Nix] > cMax)
853 cMax = pszList[Nix];
854
855 szIndex[0] = pszList[Nix];
856
857 lRet = RegQueryValueExW(hkey, szIndex, NULL, &dwType, NULL, &icCmd);
858 if (lRet != ERROR_SUCCESS || dwType != REG_SZ)
859 {
860 TRACE("Unable to grab size of index, error %d\n", GetLastError());
861 continue;
862 }
863
864 if (pszCmd)
865 {
866 pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd);
867 if (!pszTmp)
868 {
869 TRACE("HeapReAlloc failed to reallocate %d bytes\n", icCmd);
870 continue;
871 }
872 pszCmd = pszTmp;
873 }
874 else
875 {
876 pszCmd = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, icCmd);
877 if (!pszCmd)
878 {
879 TRACE("HeapAlloc failed to allocate %d bytes\n", icCmd);
880 continue;
881 }
882 }
883
884 lRet = RegQueryValueExW(hkey, szIndex, NULL, NULL, (LPBYTE)pszCmd, &icCmd);
885 if (lRet != ERROR_SUCCESS)
886 {
887 TRACE("Unable to grab index, error %d\n", GetLastError());
888 continue;
889 }
890
891 /*
892 * Generally the command string will end up with "\\1".
893 * Find the last backslash in the string and NULL-terminate.
894 * Windows does not seem to check for what comes next, so that
895 * a command of the form:
896 * c:\\my_dir\\myfile.exe
897 * will be cut just after "my_dir", whereas a command of the form:
898 * c:\\my_dir\\myfile.exe\\1
899 * will be cut just after "myfile.exe".
900 */
901 pszTmp = wcsrchr(pszCmd, L'\\');
902 if (pszTmp)
903 *pszTmp = L'\0';
904
905 /*
906 * In the following we try to add pszLatest to the MRU list.
907 * We suppose that our caller has already correctly allocated
908 * the string with enough space for us to append a "\\1".
909 *
910 * FIXME: TODO! (At the moment we don't append it!)
911 */
912
913 if (pszLatest)
914 {
915 if (_wcsicmp(pszCmd, pszLatest) == 0)
916 {
917 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd);
918 SetWindowTextW(hCb, pszCmd);
919 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
920
921 cMatch = pszList[Nix];
922 memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
923 pszList[0] = cMatch;
924 continue;
925 }
926 }
927
928 if (icList - 1 != 26 || icList - 2 != Nix || cMatch || pszLatest == NULL)
929 {
930 SendMessageW(hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd);
931 if (!Nix && fShowDefault)
932 {
933 SetWindowTextW(hCb, pszCmd);
934 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
935 }
936 }
937 else
938 {
939 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
940 SetWindowTextW(hCb, pszLatest);
941 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
942
943 cMatch = pszList[Nix];
944 memmove(&pszList[1], pszList, Nix * sizeof(WCHAR));
945 pszList[0] = cMatch;
946 szIndex[0] = cMatch;
947
948 wcscpy(&pszLatest[cchLatest], L"\\1");
949 RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
950 pszLatest[cchLatest] = L'\0';
951 }
952 }
953
954 if (!cMatch && pszLatest != NULL)
955 {
956 SendMessageW(hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest);
957 SetWindowTextW(hCb, pszLatest);
958 SendMessageW(hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
959
960 cMatch = ++cMax;
961
962 if (pszList)
963 {
964 pszTmp = (WCHAR*)HeapReAlloc(GetProcessHeap(), 0, pszList, (++icList) * sizeof(WCHAR));
965 if (!pszTmp)
966 {
967 TRACE("HeapReAlloc failed to reallocate enough bytes\n");
968 goto Cleanup;
969 }
970 pszList = pszTmp;
971 }
972 else
973 {
974 pszList = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (++icList) * sizeof(WCHAR));
975 if (!pszList)
976 {
977 TRACE("HeapAlloc failed to allocate enough bytes\n");
978 goto Cleanup;
979 }
980 }
981
982 memmove(&pszList[1], pszList, (icList - 1) * sizeof(WCHAR));
983 pszList[0] = cMatch;
984 szIndex[0] = cMatch;
985
986 wcscpy(&pszLatest[cchLatest], L"\\1");
987 RegSetValueExW(hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, (cchLatest + 2 + 1) * sizeof(WCHAR));
988 pszLatest[cchLatest] = L'\0';
989 }
990
991Cleanup:
992 RegSetValueExW(hkey, L"MRUList", 0, REG_SZ, (LPBYTE)pszList, (wcslen(pszList) + 1) * sizeof(WCHAR));
993
994 HeapFree(GetProcessHeap(), 0, pszCmd);
995 HeapFree(GetProcessHeap(), 0, pszList);
996
997 RegCloseKey(hkey);
998}
#define RegCloseKey(hKey)
Definition: registry.h:49
wcscpy
#define ERROR_SUCCESS
Definition: deptool.c:10
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:1096
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:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define wcsrchr
Definition: compat.h:16
#define HeapReAlloc
Definition: compat.h:734
static const WCHAR Cleanup[]
Definition: register.c:80
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
unsigned int UINT
Definition: ndis.h:50
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LRESULT
Definition: windef.h:209
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
#define CB_RESETCONTENT
Definition: winuser.h:1962
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define CB_ADDSTRING
Definition: winuser.h:1939
#define CB_SETEDITSEL
Definition: winuser.h:1966
#define CB_INSERTSTRING
Definition: winuser.h:1960

Referenced by RunDlgProc().

◆ IsFriendlyUIActive()

static BOOL IsFriendlyUIActive ( VOID  )
static

Definition at line 1321 of file dialogs.cpp.

1322{
1323 DWORD dwType = 0, dwValue = 0, dwSize = 0;
1324 HKEY hKey = NULL;
1325 LONG lRet = 0;
1326
1328 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
1329 0,
1331 &hKey);
1332 if (lRet != ERROR_SUCCESS)
1333 return FALSE;
1334
1335 /* First check an optional ReactOS specific override, that Windows does not check.
1336 We use this to allow users pairing 'Server'-configuration with FriendlyLogoff.
1337 Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
1338 dwValue = 0;
1339 dwSize = sizeof(dwValue);
1340 lRet = RegQueryValueExW(hKey,
1341 L"EnforceFriendlyLogoff",
1342 NULL,
1343 &dwType,
1344 (LPBYTE)&dwValue,
1345 &dwSize);
1346
1347 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue != FRIENDLY_LOGOFF_IS_NOT_ENFORCED)
1348 {
1350 return TRUE;
1351 }
1352
1353 /* Check product version number */
1354 dwValue = 0;
1355 dwSize = sizeof(dwValue);
1356 lRet = RegQueryValueExW(hKey,
1357 L"CSDVersion",
1358 NULL,
1359 &dwType,
1360 (LPBYTE)&dwValue,
1361 &dwSize);
1363
1364 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != IS_PRODUCT_VERSION_WORKSTATION)
1365 {
1366 /* Allow Friendly UI only on Workstation */
1367 return FALSE;
1368 }
1369
1370 /* Check LogonType value */
1372 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
1373 0,
1375 &hKey);
1376 if (lRet != ERROR_SUCCESS)
1377 return FALSE;
1378
1379 dwValue = 0;
1380 dwSize = sizeof(dwValue);
1381 lRet = RegQueryValueExW(hKey,
1382 L"LogonType",
1383 NULL,
1384 &dwType,
1385 (LPBYTE)&dwValue,
1386 &dwSize);
1388
1389 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
1390 return FALSE;
1391
1392 return (dwValue != 0);
1393}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define IS_PRODUCT_VERSION_WORKSTATION
Definition: dialogs.cpp:1091
#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED
Definition: dialogs.cpp:1092
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_DWORD
Definition: sdbapi.c:596
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by LogoffWindowsDialog().

◆ LogOffDialogProc()

INT_PTR CALLBACK LogOffDialogProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1432 of file dialogs.cpp.

1433{
1435 PLOGOFF_DLG_CONTEXT pContext;
1437
1438 switch (uMsg)
1439 {
1440 case WM_INITDIALOG:
1441 {
1442 pContext = (PLOGOFF_DLG_CONTEXT)lParam;
1444
1445 if (pContext->bFriendlyUI)
1446 FancyLogoffOnInit(hwnd, pContext);
1447 return TRUE;
1448 }
1449
1450 case WM_CLOSE:
1452 break;
1453
1454 /*
1455 * If the user deactivates the log off dialog (it loses its focus
1456 * while the dialog is not being closed), then destroy the dialog
1457 * box.
1458 */
1459 case WM_ACTIVATE:
1460 {
1461 if (LOWORD(wParam) == WA_INACTIVE)
1462 {
1464 }
1465 return FALSE;
1466 }
1467
1468 case WM_COMMAND:
1469 switch (LOWORD(wParam))
1470 {
1471 case IDC_LOG_OFF_BUTTON:
1472 case IDOK:
1474 break;
1475
1476 case IDCANCEL:
1478 break;
1479 }
1480 break;
1481
1482 case WM_DESTROY:
1483 if (pContext->bFriendlyUI)
1484 EndFriendlyDialog(hwnd, pContext);
1485 return TRUE;
1486
1487 case WM_CTLCOLORSTATIC:
1488 {
1489 /* Either make background transparent or fill it with color for required static controls */
1490 HDC hdcStatic = (HDC)wParam;
1492
1493 switch (StaticID)
1494 {
1496 SetTextColor(hdcStatic, DARK_GREY_COLOR);
1497 SetBkMode(hdcStatic, TRANSPARENT);
1499
1500 case IDC_LOG_OFF_STATIC:
1502 SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1503 SetBkMode(hdcStatic, TRANSPARENT);
1504 return (LONG_PTR)pContext->hBrush;
1505 }
1506 return FALSE;
1507 }
1508 break;
1509
1510 case WM_DRAWITEM:
1511 {
1512 /* Draw bitmaps on required buttons */
1513 switch (pdis->CtlID)
1514 {
1515 case IDC_LOG_OFF_BUTTON:
1517 return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1518 }
1519 }
1520 break;
1521
1522 default:
1523 break;
1524 }
1525 return FALSE;
1526}
WPARAM wParam
Definition: combotst.c:138
BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1118
struct LOGOFF_DLG_CONTEXT * PLOGOFF_DLG_CONTEXT
VOID EndFriendlyDialog(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1306
static VOID FancyLogoffOnInit(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1395
#define LIGHT_GREY_COLOR
Definition: dialogs.cpp:1097
#define IDC_LOG_OFF_STATIC
Definition: shresdef.h:516
#define IDC_SWITCH_USER_STATIC
Definition: shresdef.h:517
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRANSPARENT
Definition: wingdi.h:950
#define HOLLOW_BRUSH
Definition: wingdi.h:899
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1775
#define WM_CLOSE
Definition: winuser.h:1624
#define IDCANCEL
Definition: winuser.h:834
#define GWL_ID
Definition: winuser.h:862
#define WM_COMMAND
Definition: winuser.h:1743
#define WA_INACTIVE
Definition: winuser.h:2625
#define WM_INITDIALOG
Definition: winuser.h:1742
#define WM_DRAWITEM
Definition: winuser.h:1648
#define WM_ACTIVATE
Definition: winuser.h:1615
#define WM_DESTROY
Definition: winuser.h:1612
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by LogoffWindowsDialog().

◆ LogoffWindowsDialog()

EXTERN_C int WINAPI LogoffWindowsDialog ( HWND  hWndOwner)

Definition at line 1532 of file dialogs.cpp.

1533{
1534 CComPtr<IUnknown> fadeHandler;
1535 HWND parent = NULL;
1536 DWORD LogoffDialogID = IDD_LOG_OFF;
1538
1539 if (!CallShellDimScreen(&fadeHandler, &parent))
1540 parent = hWndOwner;
1541
1542 Context.bFriendlyUI = IsFriendlyUIActive();
1543 if (Context.bFriendlyUI)
1544 {
1545 LogoffDialogID = IDD_LOG_OFF_FANCY;
1546 }
1547
1549 MAKEINTRESOURCEW(LogoffDialogID),
1550 parent,
1552 (LPARAM)&Context);
1553 return 0;
1554}
static BOOL IsFriendlyUIActive(VOID)
Definition: dialogs.cpp:1321
INT_PTR CALLBACK LogOffDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1432
#define IDD_LOG_OFF
Definition: shresdef.h:548
#define IDD_LOG_OFF_FANCY
Definition: shresdef.h:554
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by CTrayWindow::HandleCommand(), and StartMenuHandler::ShowLogoffDialog().

◆ NoIconsInFile()

static void NoIconsInFile ( HWND  hwndDlg,
PPICK_ICON_CONTEXT  pIconContext 
)
static

Definition at line 166 of file dialogs.cpp.

167{
168 // Show an error message
170 strText.Format(IDS_NO_ICONS, pIconContext->szPath);
171 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING);
172
173 // Load the default icons
174 DoLoadIcons(hwndDlg, pIconContext, g_pszShell32);
175}
static BOOL DoLoadIcons(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext, LPCWSTR pszFile)
Definition: dialogs.cpp:104
LPCWSTR g_pszShell32
CAtlStringW CStringW
Definition: atlstr.h:130
#define IDS_NO_ICONS
Definition: shresdef.h:344
#define IDS_PICK_ICON_TITLE
Definition: shresdef.h:395
#define MB_ICONWARNING
Definition: winuser.h:789

Referenced by PickIconProc().

◆ OwnerDrawButtonSubclass()

INT_PTR CALLBACK OwnerDrawButtonSubclass ( HWND  hButton,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1201 of file dialogs.cpp.

1202{
1203 PLOGOFF_DLG_CONTEXT pContext;
1205
1206 int buttonID = GetDlgCtrlID(hButton);
1207
1208 switch (uMsg)
1209 {
1210 case WM_MOUSEMOVE:
1211 {
1212 HWND hwndTarget = NULL;
1214
1215 if (GetCapture() != hButton)
1216 {
1217 SetCapture(hButton);
1218
1219 switch (buttonID)
1220 {
1221 case IDC_LOG_OFF_BUTTON:
1222 {
1224 break;
1225 }
1227 {
1229 break;
1230 }
1231 }
1233 }
1234
1235 ClientToScreen(hButton, &pt);
1236 hwndTarget = WindowFromPoint(pt);
1237
1238 if (hwndTarget != hButton)
1239 {
1241
1242 switch (buttonID)
1243 {
1244 case IDC_LOG_OFF_BUTTON:
1245 {
1247 break;
1248 }
1250 {
1252 break;
1253 }
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 {
1271 break;
1272 }
1273 }
1274 return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
1275}
#define pt(x, y)
Definition: drawing.c:79
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define DM_SETDEFID
Definition: winuser.h:2102
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define WM_SETFOCUS
Definition: winuser.h:1616
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_MOUSEMOVE
Definition: winuser.h:1778
HWND WINAPI GetCapture(void)
Definition: message.c:2881
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2191
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HWND WINAPI GetParent(_In_ HWND)
HWND WINAPI WindowFromPoint(_In_ POINT)
int WINAPI GetDlgCtrlID(_In_ HWND)
#define IDC_HAND
Definition: winuser.h:698
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_KILLFOCUS
Definition: winuser.h:1617

Referenced by FancyLogoffOnInit().

◆ PickIconDlg()

BOOL WINAPI PickIconDlg ( HWND  hWndOwner,
LPWSTR  lpstrFile,
UINT  nMaxFile,
INT lpdwIconIndex 
)

Definition at line 351 of file dialogs.cpp.

356{
357 CCoInit ComInit; // For SHAutoComplete (CORE-20030)
358 int res;
359 WCHAR szExpandedPath[MAX_PATH];
360
361 // Initialize the dialog
362 PICK_ICON_CONTEXT IconContext = { NULL };
363 IconContext.Index = *lpdwIconIndex;
364 StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), lpstrFile);
365 ExpandEnvironmentStringsW(lpstrFile, szExpandedPath, _countof(szExpandedPath));
366
367 if (!szExpandedPath[0] ||
369 {
370 if (szExpandedPath[0])
371 {
372 // No such file
374 strText.Format(IDS_FILE_NOT_FOUND, lpstrFile);
375 MessageBoxW(hWndOwner, strText, strTitle, MB_ICONWARNING);
376 }
377
378 // Set the default value
379 StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), g_pszShell32);
380 }
381
382 // Show the dialog
384 if (res)
385 {
386 // Store the selected icon
387 StringCchCopyW(lpstrFile, nMaxFile, IconContext.szPath);
388 *lpdwIconIndex = IconContext.Index;
389 }
390
391 return res;
392}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
INT_PTR CALLBACK PickIconProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:185
GLuint res
Definition: glext.h:9613
#define IDD_PICK_ICON
Definition: shresdef.h:391
#define IDS_FILE_NOT_FOUND
Definition: shresdef.h:345
COM Initialisation.
Definition: shellclasses.h:179
WCHAR szPath[MAX_PATH]
Definition: dialogs.cpp:62
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by DesktopPageProc(), EditTypeDlg_OnChangeIcon(), CShellLink::OnCommand(), and CFileDefExt::OnFolderCustChangeIcon().

◆ PickIconProc()

INT_PTR CALLBACK PickIconProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 185 of file dialogs.cpp.

190{
192 LPDRAWITEMSTRUCT lpdis;
193 HICON hIcon;
194 INT index, count;
195 WCHAR szText[MAX_PATH], szFilter[100];
198
199 switch(uMsg)
200 {
201 case WM_INITDIALOG:
202 {
203 pIconContext = (PPICK_ICON_CONTEXT)lParam;
204 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
205 pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
206
208
209 // Load the icons
210 if (!DoLoadIcons(hwndDlg, pIconContext, pIconContext->szPath))
211 NoIconsInFile(hwndDlg, pIconContext);
212
213 // Set the selection
214 count = SendMessageW(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
215 if (count != LB_ERR)
216 {
217 if (pIconContext->Index < 0)
218 {
219 // A negative value will be interpreted as a negated resource ID.
220 LPARAM lParam = -pIconContext->Index;
221 pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRINGEXACT, -1, lParam);
222 }
223
224 if (pIconContext->Index < 0 || count <= pIconContext->Index)
225 pIconContext->Index = 0;
226
227 SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0);
228 SendMessageW(pIconContext->hDlgCtrl, LB_SETTOPINDEX, pIconContext->Index, 0);
229 }
230
232 return TRUE;
233 }
234
235 case WM_DESTROY:
236 {
237 DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
238 delete[] pIconContext->phIcons;
239
240 if (pIconContext->hLibrary)
241 FreeLibrary(pIconContext->hLibrary);
242 break;
243 }
244
245 case WM_COMMAND:
246 switch(LOWORD(wParam))
247 {
248 case IDOK:
249 {
250 /* Check whether the path edit control has been modified; if so load the icons instead of validating */
251 GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, szText, _countof(szText));
252 if (lstrcmpiW(szText, pIconContext->szPath))
253 {
254 if (!DoLoadIcons(hwndDlg, pIconContext, szText))
255 NoIconsInFile(hwndDlg, pIconContext);
256 break;
257 }
258
259 /* The path edit control has not been modified, return the selection */
260 pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
261 GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath, _countof(pIconContext->szPath));
262 EndDialog(hwndDlg, 1);
263 break;
264 }
265
266 case IDCANCEL:
267 EndDialog(hwndDlg, 0);
268 break;
269
271 switch (HIWORD(wParam))
272 {
273 case LBN_SELCHANGE:
275 break;
276
277 case LBN_DBLCLK:
278 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
279 break;
280 }
281 break;
282
283 case IDC_BUTTON_PATH:
284 {
285 // Choose the module path
286 CStringW strTitle;
287 szText[0] = 0;
288 szFilter[0] = 0;
289 ZeroMemory(&ofn, sizeof(ofn));
290 ofn.lStructSize = sizeof(ofn);
291 ofn.hwndOwner = hwndDlg;
292 ofn.lpstrFile = szText;
293 ofn.nMaxFile = _countof(szText);
294 strTitle.LoadString(IDS_PICK_ICON_TITLE);
295 ofn.lpstrTitle = strTitle;
298 if (!GetOpenFileNameW(&ofn))
299 break;
300
301 // Load the icons
302 if (!DoLoadIcons(hwndDlg, pIconContext, szText))
303 NoIconsInFile(hwndDlg, pIconContext);
304 break;
305 }
306
307 default:
308 break;
309 }
310 break;
311
312 case WM_MEASUREITEM:
314 lpmis->itemHeight = CY_ITEM;
315 return TRUE;
316
317 case WM_DRAWITEM:
318 {
319 lpdis = (LPDRAWITEMSTRUCT)lParam;
320 if (lpdis->itemID == (UINT)-1)
321 break;
322 switch (lpdis->itemAction) // FIXME: MSDN says that more than one of these can be set
323 {
324 // FIXME: ODA_FOCUS
325 case ODA_SELECT:
326 case ODA_DRAWENTIRE:
327 {
328 index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
329 hIcon = pIconContext->phIcons[lpdis->itemID];
330
331 if (lpdis->itemID == (UINT)index)
332 FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
333 else
334 FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
335
336 // Centering
337 INT x = lpdis->rcItem.left + (CX_ITEM - CX_ICON) / 2;
338 INT y = lpdis->rcItem.top + (CY_ITEM - CY_ICON) / 2;
339
340 DrawIconEx(lpdis->hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
341 break;
342 }
343 }
344 return TRUE;
345 }
346 }
347
348 return FALSE;
349}
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
#define CX_ITEM
Definition: dialogs.cpp:182
static void NoIconsInFile(HWND hwndDlg, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:166
#define CY_ITEM
Definition: dialogs.cpp:183
#define CX_ICON
Definition: dialogs.cpp:178
#define CY_ICON
Definition: dialogs.cpp:179
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LPTSTR szFilter
Definition: mplay32.c:30
HICON hIcon
Definition: msconfig.c:44
#define INT
Definition: polytest.cpp:20
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
#define SHACF_DEFAULT
Definition: shlwapi.h:1956
#define IDC_PICKICON_LIST
Definition: shresdef.h:392
#define IDC_BUTTON_PATH
Definition: shresdef.h:393
#define IDS_PICK_ICON_FILTER
Definition: shresdef.h:396
OPENFILENAME ofn
Definition: sndrec32.cpp:56
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define HIWORD(l)
Definition: typedefs.h:247
_In_ WDFCOLLECTION _In_ ULONG Index
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define ZeroMemory
Definition: winbase.h:1737
#define DI_NORMAL
Definition: wingdi.h:72
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2038
#define DWLP_USER
Definition: winuser.h:875
#define COLOR_WINDOW
Definition: winuser.h:921
struct tagMEASUREITEMSTRUCT * LPMEASUREITEMSTRUCT
#define LB_SETTOPINDEX
Definition: winuser.h:2073
#define LBN_DBLCLK
Definition: winuser.h:2074
#define COLOR_HIGHLIGHT
Definition: winuser.h:929
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2064
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:2114
#define SendMessage
Definition: winuser.h:5855
#define WM_MEASUREITEM
Definition: winuser.h:1649
#define LBN_SELCHANGE
Definition: winuser.h:2078
#define LB_GETCURSEL
Definition: winuser.h:2042

Referenced by PickIconDlg().

◆ RestartDialog()

int WINAPI RestartDialog ( HWND  hWndOwner,
LPCWSTR  lpstrReason,
DWORD  uFlags 
)

Definition at line 1560 of file dialogs.cpp.

1561{
1562 return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
1563}
UINT uFlags
Definition: api.c:59
int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
Definition: dialogs.cpp:1069

◆ RestartDialogEx()

int WINAPI RestartDialogEx ( HWND  hWndOwner,
LPCWSTR  lpwstrReason,
DWORD  uFlags,
DWORD  uReason 
)

Definition at line 1069 of file dialogs.cpp.

1070{
1071 TRACE("(%p)\n", hWndOwner);
1072
1073 CComPtr<IUnknown> fadeHandler;
1074 HWND parent;
1075
1076 if (!CallShellDimScreen(&fadeHandler, &parent))
1077 parent = hWndOwner;
1078
1079 /* FIXME: use lpwstrReason */
1081 {
1082 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1083 ExitWindowsEx(EWX_REBOOT, uReason);
1084 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1085 }
1086
1087 return 0;
1088}
#define IDS_RESTART_TITLE
Definition: shresdef.h:80
#define IDS_RESTART_PROMPT
Definition: shresdef.h:81

Referenced by RestartDialog().

◆ RunDlg_GetParentDir()

static LPWSTR RunDlg_GetParentDir ( LPCWSTR  cmdline)
static

Definition at line 422 of file dialogs.cpp.

423{
424 const WCHAR *src;
425 WCHAR *dest, *result, *result_end=NULL;
426
427 result = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5));
428
429 if (NULL == result)
430 {
431 TRACE("HeapAlloc couldn't allocate %d bytes\n", sizeof(WCHAR)*(strlenW(cmdline)+5));
432 return NULL;
433 }
434
435 src = cmdline;
436 dest = result;
437
438 if (*src == '"')
439 {
440 src++;
441 while (*src && *src != '"')
442 {
443 if (*src == '\\')
444 result_end = dest;
445 *dest++ = *src++;
446 }
447 }
448 else {
449 while (*src)
450 {
451 if (isspaceW(*src))
452 {
453 *dest = 0;
455 break;
456 strcatW(dest, L".exe");
458 break;
459 }
460 else if (*src == '\\')
461 result_end = dest;
462 *dest++ = *src++;
463 }
464 }
465
466 if (result_end)
467 {
468 *result_end = 0;
469 return result;
470 }
471 else
472 {
474 return NULL;
475 }
476}
GLenum src
Definition: glext.h:6340
GLuint64EXT * result
Definition: glext.h:11304
static char * dest
Definition: rtl.c:135
#define strlenW(s)
Definition: unicode.h:34
#define strcatW(d, s)
Definition: unicode.h:36
#define isspaceW(n)
Definition: unicode.h:58
TCHAR * cmdline
Definition: stretchblt.cpp:32

Referenced by RunDlgProc().

◆ RunDlgProc()

static INT_PTR CALLBACK RunDlgProc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 501 of file dialogs.cpp.

502{
504 HWND hwndCombo, hwndEdit;
505 COMBOBOXINFO ComboInfo;
506
507 switch (message)
508 {
509 case WM_INITDIALOG:
510 prfdp = (RUNFILEDLGPARAMS *)lParam;
512
513 if (prfdp->lpstrTitle)
515 if (prfdp->lpstrDescription)
517 if (prfdp->uFlags & RFF_NOBROWSE)
518 {
520 ShowWindow(browse, SW_HIDE);
521 EnableWindow(browse, FALSE);
522 }
523 if (prfdp->uFlags & RFF_NOLABEL)
525 if (prfdp->uFlags & RFF_NOSEPARATEMEM)
526 {
527 FIXME("RFF_NOSEPARATEMEM not supported\n");
528 }
529
530 /* Use the default Shell Run icon if no one is specified */
531 if (prfdp->hIcon == NULL)
533 /*
534 * NOTE: Starting Windows Vista, the "Run File" dialog gets a
535 * title icon that remains the same as the default one, even if
536 * the user specifies a custom icon.
537 * Since we currently imitate Windows 2003, therefore do not show
538 * any title icon.
539 */
540 // SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)prfdp->hIcon);
541 // SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon);
543
544 hwndCombo = GetDlgItem(hwnd, IDC_RUNDLG_EDITPATH);
545 FillList(hwndCombo, NULL, 0, (prfdp->uFlags & RFF_NODEFAULT) == 0);
547
548 ComboInfo.cbSize = sizeof(ComboInfo);
549 GetComboBoxInfo(hwndCombo, &ComboInfo);
550 hwndEdit = ComboInfo.hwndItem;
552
553 // SHAutoComplete needs co init
555
557
558 SetFocus(hwndCombo);
559 return TRUE;
560
561 case WM_DESTROY:
562 if (prfdp->bCoInited)
564 break;
565
566 case WM_COMMAND:
567 switch (LOWORD(wParam))
568 {
569 case IDOK:
570 {
571 LRESULT lRet;
573 INT ic;
574 WCHAR *psz, *pszExpanded, *parent = NULL;
575 DWORD cchExpand;
576 SHELLEXECUTEINFOW sei = { sizeof(sei) };
577 NMRUNFILEDLGW nmrfd;
578
579 ic = GetWindowTextLengthW(htxt);
580 if (ic == 0)
581 {
583 return TRUE;
584 }
585
586 /*
587 * Allocate a new MRU entry, we need to add two characters
588 * for the terminating "\\1" part, then the NULL character.
589 */
590 psz = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (ic + 2 + 1)*sizeof(WCHAR));
591 if (!psz)
592 {
594 return TRUE;
595 }
596
597 GetWindowTextW(htxt, psz, ic + 1);
598 sei.hwnd = hwnd;
599 sei.nShow = SW_SHOWNORMAL;
600 sei.lpFile = psz;
601 StrTrimW(psz, L" \t");
602
603 if (wcschr(psz, L'%') != NULL)
604 {
605 cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
606 pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
607 if (!pszExpanded)
608 {
609 HeapFree(GetProcessHeap(), 0, psz);
611 return TRUE;
612 }
613 ExpandEnvironmentStringsW(psz, pszExpanded, cchExpand);
614 StrTrimW(pszExpanded, L" \t");
615 }
616 else
617 {
618 pszExpanded = psz;
619 }
620
621 /*
622 * The precedence is the following: first the user-given
623 * current directory is used; if there is none, a current
624 * directory is computed if the RFF_CALCDIRECTORY is set,
625 * otherwise no current directory is defined.
626 */
627 LPCWSTR pszStartDir;
628 if (prfdp->lpstrDirectory)
629 {
630 sei.lpDirectory = prfdp->lpstrDirectory;
631 pszStartDir = prfdp->lpstrDirectory;
632 }
633 else if (prfdp->uFlags & RFF_CALCDIRECTORY)
634 {
636 pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
637 }
638 else
639 {
640 sei.lpDirectory = NULL;
641 pszStartDir = NULL;
642 }
643
644 /* Hide the dialog for now on, we will show it up in case of retry */
646
647 /*
648 * As shown by manual tests on Windows, modifying the contents
649 * of the notification structure will not modify what the
650 * Run-Dialog will use for the nShow parameter. However the
651 * lpFile and lpDirectory pointers are set to the buffers used
652 * by the Run-Dialog, as a consequence they can be modified by
653 * the notification receiver, as long as it respects the lengths
654 * of the buffers (to avoid buffer overflows).
655 */
656 nmrfd.hdr.code = RFN_VALIDATE;
657 nmrfd.hdr.hwndFrom = hwnd;
658 nmrfd.hdr.idFrom = 0;
659 nmrfd.lpFile = pszExpanded;
660 nmrfd.lpDirectory = pszStartDir;
661 nmrfd.nShow = SW_SHOWNORMAL;
662
663 lRet = SendMessageW(prfdp->hwndOwner, WM_NOTIFY, 0, (LPARAM)&nmrfd.hdr);
664
665 switch (lRet)
666 {
667 case RF_CANCEL:
669 break;
670
671 case RF_OK:
672 /* We use SECL_NO_UI because we don't want to see
673 * errors here, but we will try again below and
674 * there we will output our errors. */
675 if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
677 {
678 /* Call GetWindowText again in case the contents of the edit box have changed. */
679 GetWindowTextW(htxt, psz, ic + 1);
680 FillList(htxt, psz, ic + 2 + 1, FALSE);
682 break;
683 }
684 else if (ShellExecuteExW(&sei))
685 {
686 /* Call GetWindowText again in case the contents of the edit box have changed. */
687 GetWindowTextW(htxt, psz, ic + 1);
688 FillList(htxt, psz, ic + 2 + 1, FALSE);
690 break;
691 }
692
693 /* Fall-back */
694 case RF_RETRY:
695 default:
696 SendMessageW(htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
697 /* Show back the dialog */
699 break;
700 }
701
703 HeapFree(GetProcessHeap(), 0, psz);
704 if (psz != pszExpanded)
705 HeapFree(GetProcessHeap(), 0, pszExpanded);
706 return TRUE;
707 }
708
709 case IDCANCEL:
711 return TRUE;
712
714 {
715 HMODULE hComdlg = NULL;
716 LPFNOFN ofnProc = NULL;
717 WCHAR szFName[1024] = {0};
718 WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
720
723
724 ZeroMemory(&ofn, sizeof(ofn));
725 ofn.lStructSize = sizeof(ofn);
728 ofn.lpstrFile = szFName;
729 ofn.nMaxFile = _countof(szFName) - 1;
730 ofn.lpstrTitle = szCaption;
733
734 if (NULL == (hComdlg = LoadLibraryExW(L"comdlg32", NULL, 0)) ||
735 NULL == (ofnProc = (LPFNOFN)GetProcAddress(hComdlg, "GetOpenFileNameW")))
736 {
737 ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
739 return TRUE;
740 }
741
742 if (ofnProc(&ofn))
743 {
749 }
750
751 FreeLibrary(hComdlg);
752
753 return TRUE;
754 }
756 {
758 {
760 }
761 return TRUE;
762 }
763 }
764 return TRUE;
765 }
766 return FALSE;
767}
#define SECL_ALLOW_NONEXE
#define ShellExecCmdLine
#define SECL_NO_UI
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
HWND hwndEdit
Definition: combotst.c:65
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define wcschr
Definition: compat.h:17
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define IDC_RUNDLG_BROWSE
Definition: resource.h:7
static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
Definition: dialogs.cpp:422
static void FillList(HWND, LPWSTR, UINT, BOOL)
Definition: dialogs.cpp:775
BOOL(WINAPI * LPFNOFN)(OPENFILENAMEW *)
Definition: dialogs.cpp:46
static void EnableOkButtonFromEditContents(HWND hwnd)
Definition: dialogs.cpp:478
#define ShellMessageBoxW
Definition: precomp.h:62
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1883
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define ASSERT(a)
Definition: mode.c:44
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
#define WM_NOTIFY
Definition: richedit.h:61
#define RFF_NOBROWSE
Definition: run.h:33
#define RFF_NODEFAULT
Definition: run.h:34
#define RFF_CALCDIRECTORY
Definition: run.h:35
#define RFF_NOSEPARATEMEM
Definition: run.h:37
#define RFF_NOLABEL
Definition: run.h:36
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2452
#define SHACF_FILESYSTEM
Definition: shlwapi.h:1957
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:1962
#define SHACF_URLALL
Definition: shlwapi.h:1960
#define IDI_SHELL_RUN
Definition: shresdef.h:581
#define IDC_RUNDLG_LABEL
Definition: shresdef.h:371
#define IDS_RUNDLG_BROWSE_FILTER
Definition: shresdef.h:198
#define IDC_RUNDLG_ICON
Definition: shresdef.h:369
#define IDS_RUNDLG_BROWSE_CAPTION
Definition: shresdef.h:197
#define IDS_RUNDLG_BROWSE_ERROR
Definition: shresdef.h:196
#define IDC_RUNDLG_DESCRIPTION
Definition: shresdef.h:367
LPCWSTR lpstrDirectory
Definition: dialogs.cpp:29
LPCWSTR lpstrTitle
Definition: dialogs.cpp:30
LPCWSTR lpstrDescription
Definition: dialogs.cpp:31
LPCWSTR lpFile
Definition: undocshell.h:170
LPCWSTR lpDirectory
Definition: undocshell.h:171
LPCWSTR lpDirectory
Definition: shellapi.h:335
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3161
UINT code
Definition: winuser.h:3162
HWND hwndFrom
Definition: winuser.h:3160
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define RF_OK
Definition: undocshell.h:180
#define RFN_VALIDATE
Definition: undocshell.h:157
#define RF_RETRY
Definition: undocshell.h:182
#define RF_CANCEL
Definition: undocshell.h:181
#define SW_SHOWNORMAL
Definition: winuser.h:773
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SW_HIDE
Definition: winuser.h:771
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define STM_SETICON
Definition: winuser.h:2095
#define MB_ICONERROR
Definition: winuser.h:790
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
#define MB_OK
Definition: winuser.h:793
#define SW_SHOW
Definition: winuser.h:778
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2161
#define CBN_EDITCHANGE
Definition: winuser.h:1978
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by RunFileDlg().

◆ RunFileDlg()

void WINAPI RunFileDlg ( HWND  hWndOwner,
HICON  hIcon,
LPCWSTR  lpstrDirectory,
LPCWSTR  lpstrTitle,
LPCWSTR  lpstrDescription,
UINT  uFlags 
)

Definition at line 399 of file dialogs.cpp.

406{
407 TRACE("\n");
408
409 RUNFILEDLGPARAMS rfdp;
410 rfdp.hwndOwner = hWndOwner;
411 rfdp.hIcon = hIcon;
412 rfdp.lpstrDirectory = lpstrDirectory;
413 rfdp.lpstrTitle = lpstrTitle;
414 rfdp.lpstrDescription = lpstrDescription;
415 rfdp.uFlags = uFlags;
416
418}
static INT_PTR CALLBACK RunDlgProc(HWND, UINT, WPARAM, LPARAM)
Definition: dialogs.cpp:501
#define IDD_RUN
Definition: shresdef.h:366

Referenced by RunDialogThread::Run(), CTrayWindow::RunFileDlgThread(), and TaskManager_OnFileNew().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )