ReactOS 0.4.16-dev-1948-gd260c1d
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 1112 of file dialogs.cpp.

◆ BUTTON_LOG_OFF_FOCUSED

#define BUTTON_LOG_OFF_FOCUSED   (CY_BITMAP + BUTTON_LOG_OFF_PRESSED)

Definition at line 1114 of file dialogs.cpp.

◆ BUTTON_LOG_OFF_PRESSED

#define BUTTON_LOG_OFF_PRESSED   (CY_BITMAP + BUTTON_LOG_OFF)

Definition at line 1113 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER

#define BUTTON_SWITCH_USER   0

Definition at line 1109 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER_DISABLED

#define BUTTON_SWITCH_USER_DISABLED   (CY_BITMAP + BUTTON_LOG_OFF_FOCUSED)

Definition at line 1115 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER_FOCUSED

#define BUTTON_SWITCH_USER_FOCUSED   (CY_BITMAP + BUTTON_SWITCH_USER_PRESSED)

Definition at line 1111 of file dialogs.cpp.

◆ BUTTON_SWITCH_USER_PRESSED

#define BUTTON_SWITCH_USER_PRESSED   (CY_BITMAP + BUTTON_SWITCH_USER)

Definition at line 1110 of file dialogs.cpp.

◆ CX_BITMAP

#define CX_BITMAP   33

Definition at line 1103 of file dialogs.cpp.

◆ CX_ICON

Definition at line 179 of file dialogs.cpp.

◆ CX_ITEM

#define CX_ITEM   (CX_ICON + 4)

Definition at line 183 of file dialogs.cpp.

◆ CY_BITMAP

#define CY_BITMAP   33

Definition at line 1104 of file dialogs.cpp.

◆ CY_ICON

Definition at line 180 of file dialogs.cpp.

◆ CY_ITEM

#define CY_ITEM   (CY_ICON + 12)

Definition at line 184 of file dialogs.cpp.

◆ DARK_GREY_COLOR

#define DARK_GREY_COLOR   RGB(244, 244, 244)

Definition at line 1099 of file dialogs.cpp.

◆ FONT_POINT_SIZE

#define FONT_POINT_SIZE   13

Definition at line 1097 of file dialogs.cpp.

◆ FRIENDLY_LOGOFF_IS_NOT_ENFORCED

#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED   0x0

Definition at line 1095 of file dialogs.cpp.

◆ IS_PRODUCT_VERSION_WORKSTATION

#define IS_PRODUCT_VERSION_WORKSTATION   0x300

Definition at line 1094 of file dialogs.cpp.

◆ LIGHT_GREY_COLOR

#define LIGHT_GREY_COLOR   RGB(38, 38, 38)

Definition at line 1100 of file dialogs.cpp.

◆ LOG_OFF_BUTTON_HOT

#define LOG_OFF_BUTTON_HOT   0

Definition at line 1118 of file dialogs.cpp.

◆ NUMBER_OF_BUTTONS

#define NUMBER_OF_BUTTONS   2

Definition at line 1106 of file dialogs.cpp.

◆ SWITCH_USER_BUTTON_HOT

#define SWITCH_USER_BUTTON_HOT   1

Definition at line 1119 of file dialogs.cpp.

Typedef Documentation

◆ LPFNOFN

typedef BOOL(WINAPI * LPFNOFN) (OPENFILENAMEW *)

Definition at line 47 of file dialogs.cpp.

◆ PLOGOFF_DLG_CONTEXT

◆ PPICK_ICON_CONTEXT

◆ tShellDimScreen

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

Definition at line 1019 of file dialogs.cpp.

Function Documentation

◆ CallShellDimScreen()

BOOL CallShellDimScreen ( IUnknown **  pUnknown,
HWND hWindow 
)

Definition at line 1022 of file dialogs.cpp.

1023{
1025 static BOOL Initialized = FALSE;
1026 if (!Initialized)
1027 {
1028 HMODULE mod = LoadLibraryW(L"msgina.dll");
1030 Initialized = TRUE;
1031 }
1032
1033 HRESULT hr = E_FAIL;
1034 if (ShellDimScreen)
1035 hr = ShellDimScreen(pUnknown, hWindow);
1036 return SUCCEEDED(hr);
1037}
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:1019
#define L(x)
Definition: resources.c:13
_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
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 1009 of file dialogs.cpp.

1010{
1011 WCHAR Prompt[256];
1012 WCHAR Title[256];
1013
1014 LoadStringW(shell32_hInstance, PromptId, Prompt, _countof(Prompt));
1016 return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO | MB_ICONQUESTION) == IDYES;
1017}
#define shell32_hInstance
UINT TitleId
Definition: desktop.c:52
static const WCHAR Title[]
Definition: oid.c:1259
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
#define _countof(array)
Definition: sndvol32.h:70
#define MB_YESNO
Definition: winuser.h:828
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONQUESTION
Definition: winuser.h:800
#define IDYES
Definition: winuser.h:846
__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 1280 of file dialogs.cpp.

1281{
1282 HWND hwndTool = NULL, hwndTip = NULL;
1283 WCHAR szBuffer[256];
1284 TTTOOLINFOW tool;
1285
1286 hwndTool = GetDlgItem(hDlg, controlID);
1287
1288 tool.cbSize = sizeof(tool);
1289 tool.hwnd = hDlg;
1291 tool.uId = (UINT_PTR)hwndTool;
1292
1293 /* Create the tooltip */
1294 hwndTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL,
1298 hDlg, NULL, shell32_hInstance, NULL);
1299
1300 /* Associate the tooltip with the tool. */
1301 LoadStringW(shell32_hInstance, detailID, szBuffer, _countof(szBuffer));
1302 tool.lpszText = szBuffer;
1303 SendMessageW(hwndTip, TTM_ADDTOOLW, 0, (LPARAM)&tool);
1304 LoadStringW(shell32_hInstance, titleID, szBuffer, _countof(szBuffer));
1305 SendMessageW(hwndTip, TTM_SETTITLEW, TTI_NONE, (LPARAM)szBuffer);
1306 SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH, 0, 250);
1307}
#define NULL
Definition: types.h:112
LONG_PTR LPARAM
Definition: minwindef.h:175
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
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 88 of file dialogs.cpp.

89{
90 int count;
91 int index;
92
93 count = SendMessageW(hDlgCtrl, LB_GETCOUNT, 0, 0);
94 if (count == LB_ERR)
95 return;
96
97 for(index = 0; index < count; index++)
98 {
99 DestroyIcon(pIconContext->phIcons[index]);
100 pIconContext->phIcons[index] = NULL;
101 }
102}
#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:2468
#define LB_GETCOUNT
Definition: winuser.h:2067
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2405

Referenced by DoLoadIcons(), and PickIconProc().

◆ DoLoadIcons()

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

Definition at line 105 of file dialogs.cpp.

106{
107 WCHAR szExpandedPath[MAX_PATH];
108
109 // Destroy previous icons
110 DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
111 SendMessageW(pIconContext->hDlgCtrl, LB_RESETCONTENT, 0, 0);
112 delete[] pIconContext->phIcons;
113
114 // Store the path
115 StringCchCopyW(pIconContext->szPath, _countof(pIconContext->szPath), pszFile);
116 ExpandEnvironmentStringsW(pszFile, szExpandedPath, _countof(szExpandedPath));
117
118 // Load the module if possible
120 if (pIconContext->hLibrary)
121 FreeLibrary(pIconContext->hLibrary);
122 pIconContext->hLibrary = hLibrary;
123
124 if (pIconContext->hLibrary)
125 {
126 // Load the icons from the module
127 pIconContext->nIcons = ExtractIconExW(szExpandedPath, -1, NULL, NULL, 0);
128 pIconContext->phIcons = new HICON[pIconContext->nIcons];
129
130 if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
131 {
133 }
134 else
135 {
136 pIconContext->nIcons = 0;
137 }
138 }
139 else
140 {
141 // .ico file
142 pIconContext->nIcons = 1;
143 pIconContext->phIcons = new HICON[1];
144
145 if (ExtractIconExW(szExpandedPath, 0, pIconContext->phIcons, NULL, pIconContext->nIcons))
146 {
147 SendMessageW(pIconContext->hDlgCtrl, LB_ADDSTRING, 0, 0);
148 }
149 else
150 {
151 pIconContext->nIcons = 0;
152 }
153 }
154
155 SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
156 SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
157
158 if (pIconContext->nIcons == 0)
159 {
160 delete[] pIconContext->phIcons;
161 pIconContext->phIcons = NULL;
162 }
163
164 return (pIconContext->nIcons > 0);
165}
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:69
static void DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
Definition: dialogs.cpp:88
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:432
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:338
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define LB_ADDSTRING
Definition: winuser.h:2060
#define LB_RESETCONTENT
Definition: winuser.h:2091
#define LB_SETCURSEL
Definition: winuser.h:2099

Referenced by NoIconsInFile(), and PickIconProc().

◆ DrawIconOnOwnerDrawnButtons()

BOOL DrawIconOnOwnerDrawnButtons ( DRAWITEMSTRUCT pdis,
PLOGOFF_DLG_CONTEXT  pContext 
)

Definition at line 1121 of file dialogs.cpp.

1122{
1123 BOOL bRet = FALSE;
1124 HDC hdcMem = NULL;
1125 HBITMAP hbmOld = NULL;
1126 int y = 0;
1127 RECT rect;
1128
1129 hdcMem = CreateCompatibleDC(pdis->hDC);
1130 hbmOld = (HBITMAP)SelectObject(hdcMem, pContext->hImageStrip);
1131 rect = pdis->rcItem;
1132
1133 /* Check the button ID for relevant bitmap to be used */
1134 switch (pdis->CtlID)
1135 {
1136 case IDC_LOG_OFF_BUTTON:
1137 {
1138 switch (pdis->itemAction)
1139 {
1140 case ODA_DRAWENTIRE:
1141 case ODA_FOCUS:
1142 case ODA_SELECT:
1143 {
1144 y = BUTTON_LOG_OFF;
1145 if (pdis->itemState & ODS_SELECTED)
1146 {
1148 }
1149 else if (pContext->bIsButtonHot[LOG_OFF_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1150 {
1152 }
1153 break;
1154 }
1155 }
1156 break;
1157 }
1158
1160 {
1161 switch (pdis->itemAction)
1162 {
1163 case ODA_DRAWENTIRE:
1164 case ODA_FOCUS:
1165 case ODA_SELECT:
1166 {
1168 if (pdis->itemState & ODS_SELECTED)
1169 {
1171 }
1172 else if (pContext->bIsButtonHot[SWITCH_USER_BUTTON_HOT] || (pdis->itemState & ODS_FOCUS))
1173 {
1175 }
1176
1177 /*
1178 * Since switch user functionality isn't implemented yet therefore the button has been disabled
1179 * temporarily hence show the disabled state
1180 */
1181 else if (pdis->itemState & ODS_DISABLED)
1182 {
1184 }
1185 break;
1186 }
1187 }
1188 break;
1189 }
1190 }
1191
1192 /* Draw it on the required button */
1193 bRet = BitBlt(pdis->hDC,
1194 (rect.right - rect.left - CX_BITMAP) / 2,
1195 (rect.bottom - rect.top - CY_BITMAP) / 2,
1197
1198 SelectObject(hdcMem, hbmOld);
1200
1201 return bRet;
1202}
#define BUTTON_SWITCH_USER_DISABLED
Definition: dialogs.cpp:1115
#define CX_BITMAP
Definition: dialogs.cpp:1103
#define LOG_OFF_BUTTON_HOT
Definition: dialogs.cpp:1118
#define BUTTON_SWITCH_USER
Definition: dialogs.cpp:1109
#define BUTTON_LOG_OFF_FOCUSED
Definition: dialogs.cpp:1114
#define BUTTON_LOG_OFF
Definition: dialogs.cpp:1112
#define CY_BITMAP
Definition: dialogs.cpp:1104
#define SWITCH_USER_BUTTON_HOT
Definition: dialogs.cpp:1119
#define BUTTON_SWITCH_USER_PRESSED
Definition: dialogs.cpp:1110
#define BUTTON_LOG_OFF_PRESSED
Definition: dialogs.cpp:1113
#define BUTTON_SWITCH_USER_FOCUSED
Definition: dialogs.cpp:1111
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:552
#define IDC_SWITCH_USER_BUTTON
Definition: shresdef.h:553
& rect
Definition: startmenu.cpp:1413
BOOL bIsButtonHot[2]
Definition: dialogs.cpp:39
HBITMAP hImageStrip
Definition: dialogs.cpp:40
Definition: windef.h:99
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:2583
#define ODS_SELECTED
Definition: winuser.h:2581
#define ODA_DRAWENTIRE
Definition: winuser.h:2578
#define ODA_FOCUS
Definition: winuser.h:2580
#define ODA_SELECT
Definition: winuser.h:2579
#define ODS_FOCUS
Definition: winuser.h:2585

Referenced by LogOffDialogProc().

◆ EnableOkButtonFromEditContents()

static void EnableOkButtonFromEditContents ( HWND  hwnd)
static

Definition at line 479 of file dialogs.cpp.

480{
481 BOOL Enable = FALSE;
482 INT Length, n;
485 if (Length > 0)
486 {
487 PWCHAR psz = (PWCHAR)HeapAlloc(GetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR));
488 if (psz)
489 {
490 GetWindowTextW(Edit, psz, Length + 1);
491 for (n = 0; n < Length && !Enable; ++n)
492 Enable = psz[n] != ' ';
493 HeapFree(GetProcessHeap(), 0, psz);
494 }
495 else
496 Enable = TRUE;
497 }
499}
#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:399
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:1382
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define IDOK
Definition: winuser.h:841
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 1042 of file dialogs.cpp.

1043{
1044 BOOL Success;
1045 HANDLE hToken;
1047
1050 &hToken);
1051 if (!Success) return Success;
1052
1054 lpszPrivilegeName,
1055 &tp.Privileges[0].Luid);
1056 if (!Success) goto Quit;
1057
1058 tp.PrivilegeCount = 1;
1059 tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);
1060
1061 Success = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
1062
1063Quit:
1064 CloseHandle(hToken);
1065 return Success;
1066}
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:942
#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 1309 of file dialogs.cpp.

1310{
1311 DeleteObject(pContext->hBrush);
1312 DeleteObject(pContext->hImageStrip);
1313 DeleteObject(pContext->hfFont);
1314
1315 /* Remove the subclass from the buttons */
1316 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1317 {
1320 (LONG_PTR)pContext->OldButtonProc);
1321 }
1322}
#define NUMBER_OF_BUTTONS
Definition: dialogs.cpp:1106
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:44
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SetWindowLongPtrW
Definition: winuser.h:5457

Referenced by LogOffDialogProc().

◆ EnumPickIconResourceProc()

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

Definition at line 69 of file dialogs.cpp.

73{
75 HWND hDlgCtrl = pIconContext->hDlgCtrl;
76
77 if (IS_INTRESOURCE(lpszName))
78 lParam = LOWORD(lpszName);
79 else
80 lParam = -1;
81
82 SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, lParam);
83
84 return TRUE;
85}
LPARAM lParam
Definition: combotst.c:139
#define IS_INTRESOURCE(x)
Definition: loader.c:613
struct PICK_ICON_CONTEXT * PPICK_ICON_CONTEXT
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DoLoadIcons().

◆ ExitWindowsDialog()

void WINAPI ExitWindowsDialog ( HWND  hWndOwner)

Definition at line 1604 of file dialogs.cpp.

1605{
1606 typedef DWORD (WINAPI *ShellShFunc)(HWND hWndParent, LPCWSTR pUserName, DWORD dwExcludeOptions);
1607 HINSTANCE msginaDll = LoadLibraryW(L"msgina.dll");
1608
1609 TRACE("(%p)\n", hWndOwner);
1610
1611 CComPtr<IUnknown> fadeHandler;
1612 HWND parent;
1613 if (!CallShellDimScreen(&fadeHandler, &parent))
1614 parent = hWndOwner;
1615
1616 /* If the DLL cannot be found for any reason, then it simply uses a
1617 dialog box to ask if the user wants to shut down the computer. */
1618 if (!msginaDll)
1619 {
1620 TRACE("Unable to load msgina.dll.\n");
1622 return;
1623 }
1624
1625 ShellShFunc pShellShutdownDialog = (ShellShFunc)GetProcAddress(msginaDll, "ShellShutdownDialog");
1626 if (pShellShutdownDialog)
1627 {
1628 /* Actually call the function */
1629 DWORD returnValue = pShellShutdownDialog(parent, NULL, 0);
1630
1631 switch (returnValue)
1632 {
1633 case 0x01: /* Log off user */
1634 {
1636 break;
1637 }
1638 case 0x02: /* Shut down */
1639 {
1640 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1642 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1643 break;
1644 }
1645 case 0x03: /* Install Updates/Shutdown (?) */
1646 {
1647 break;
1648 }
1649 case 0x04: /* Reboot */
1650 {
1651 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1653 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1654 break;
1655 }
1656 case 0x10: /* Sleep */
1657 {
1658 if (IsPwrSuspendAllowed())
1659 {
1660 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1662 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1663 }
1664 break;
1665 }
1666 case 0x40: /* Hibernate */
1667 {
1669 {
1670 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1672 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1673 }
1674 break;
1675 }
1676 /* If the option is any other value */
1677 default:
1678 break;
1679 }
1680 }
1681 else
1682 {
1683 /* If the function cannot be found, then revert to using the backup solution */
1684 TRACE("Unable to find the 'ShellShutdownDialog' function");
1686 }
1687
1688 FreeLibrary(msginaDll);
1689}
static LPWSTR pUserName
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: dialogs.cpp:1042
VOID ExitWindowsDialog_backup(HWND hWndOwner)
Definition: dialogs.cpp:1581
BOOL CallShellDimScreen(IUnknown **pUnknown, HWND *hWindow)
Definition: dialogs.cpp:1022
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:675
BOOLEAN WINAPI SetSuspendState(BOOLEAN Hibernate, BOOLEAN ForceCritical, BOOLEAN DisableWakeEvent)
Definition: powrprof.c:1017
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:713
#define TRACE(s)
Definition: solgame.cpp:4
#define WINAPI
Definition: msvc.h:6
#define EWX_SHUTDOWN
Definition: winuser.h:647
#define EWX_LOGOFF
Definition: winuser.h:644
#define EWX_REBOOT
Definition: winuser.h:646
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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

◆ ExitWindowsDialog_backup()

VOID ExitWindowsDialog_backup ( HWND  hWndOwner)

Definition at line 1581 of file dialogs.cpp.

1582{
1583 TRACE("(%p)\n", hWndOwner);
1584
1586 {
1587 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1589 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1590 }
1591}
static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
Definition: dialogs.cpp:1009
#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 1398 of file dialogs.cpp.

1399{
1400 HDC hdc = NULL;
1401 LONG lfHeight = NULL;
1402
1403 hdc = GetDC(NULL);
1405 ReleaseDC(NULL, hdc);
1406 pContext->hfFont = CreateFontW(lfHeight, 0, 0, 0, FW_MEDIUM, FALSE, 0, 0, 0, 0, 0, 0, 0, L"MS Shell Dlg");
1408
1410
1412
1413 /* Gather old button func */
1415
1416 /* Set bIsButtonHot to false, create tooltips for each buttons and subclass the buttons */
1417 for (int i = 0; i < NUMBER_OF_BUTTONS; i++)
1418 {
1419 pContext->bIsButtonHot[i] = FALSE;
1425 hwnd,
1427 }
1428}
#define IDB_IMAGE_STRIP
Definition: resource.h:79
VOID CreateToolTipForButtons(int controlID, int detailID, HWND hDlg, int titleID)
Definition: dialogs.cpp:1280
#define DARK_GREY_COLOR
Definition: dialogs.cpp:1099
INT_PTR CALLBACK OwnerDrawButtonSubclass(HWND hButton, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1204
#define FONT_POINT_SIZE
Definition: dialogs.cpp:1097
UINT_PTR WPARAM
Definition: minwindef.h:174
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:389
#define IDC_LOG_OFF_TEXT_STATIC
Definition: shresdef.h:556
#define IDS_LOG_OFF_DESC
Definition: shresdef.h:387
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:4931
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETFONT
Definition: winuser.h:1678
HDC WINAPI GetDC(_In_opt_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3008
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2515

Referenced by LogOffDialogProc().

◆ FillList()

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

Definition at line 778 of file dialogs.cpp.

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

Referenced by RunDlgProc().

◆ IsFriendlyUIActive()

static BOOL IsFriendlyUIActive ( VOID  )
static

Definition at line 1324 of file dialogs.cpp.

1325{
1326 DWORD dwType = 0, dwValue = 0, dwSize = 0;
1327 HKEY hKey = NULL;
1328 LONG lRet = 0;
1329
1331 L"SYSTEM\\CurrentControlSet\\Control\\Windows",
1332 0,
1334 &hKey);
1335 if (lRet != ERROR_SUCCESS)
1336 return FALSE;
1337
1338 /* First check an optional ReactOS specific override, that Windows does not check.
1339 We use this to allow users pairing 'Server'-configuration with FriendlyLogoff.
1340 Otherwise users would have to change CSDVersion or LogonType (side-effects AppCompat) */
1341 dwValue = 0;
1342 dwSize = sizeof(dwValue);
1343 lRet = RegQueryValueExW(hKey,
1344 L"EnforceFriendlyLogoff",
1345 NULL,
1346 &dwType,
1347 (LPBYTE)&dwValue,
1348 &dwSize);
1349
1350 if (lRet == ERROR_SUCCESS && dwType == REG_DWORD && dwValue != FRIENDLY_LOGOFF_IS_NOT_ENFORCED)
1351 {
1353 return TRUE;
1354 }
1355
1356 /* Check product version number */
1357 dwValue = 0;
1358 dwSize = sizeof(dwValue);
1359 lRet = RegQueryValueExW(hKey,
1360 L"CSDVersion",
1361 NULL,
1362 &dwType,
1363 (LPBYTE)&dwValue,
1364 &dwSize);
1366
1367 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD || dwValue != IS_PRODUCT_VERSION_WORKSTATION)
1368 {
1369 /* Allow Friendly UI only on Workstation */
1370 return FALSE;
1371 }
1372
1373 /* Check LogonType value */
1375 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
1376 0,
1378 &hKey);
1379 if (lRet != ERROR_SUCCESS)
1380 return FALSE;
1381
1382 dwValue = 0;
1383 dwSize = sizeof(dwValue);
1384 lRet = RegQueryValueExW(hKey,
1385 L"LogonType",
1386 NULL,
1387 &dwType,
1388 (LPBYTE)&dwValue,
1389 &dwSize);
1391
1392 if (lRet != ERROR_SUCCESS || dwType != REG_DWORD)
1393 return FALSE;
1394
1395 return (dwValue != 0);
1396}
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:1094
#define FRIENDLY_LOGOFF_IS_NOT_ENFORCED
Definition: dialogs.cpp:1095
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define REG_DWORD
Definition: sdbapi.c:615
#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 1435 of file dialogs.cpp.

1436{
1438 PLOGOFF_DLG_CONTEXT pContext;
1440
1441 switch (uMsg)
1442 {
1443 case WM_INITDIALOG:
1444 {
1445 pContext = (PLOGOFF_DLG_CONTEXT)lParam;
1447
1448 if (pContext->bFriendlyUI)
1449 FancyLogoffOnInit(hwnd, pContext);
1450 return TRUE;
1451 }
1452
1453 case WM_DESTROY:
1454 if (pContext->bFriendlyUI)
1455 EndFriendlyDialog(hwnd, pContext);
1456 return TRUE;
1457
1458 case WM_ACTIVATE:
1459 {
1460 /*
1461 * If the user deactivates the log-off dialog (it loses its focus
1462 * while the dialog is not being closed), then destroy the dialog
1463 * and cancel user logoff.
1464 */
1465 if (LOWORD(wParam) == WA_INACTIVE)
1466 {
1467 if (!pContext->bCloseDlg)
1468 {
1469 pContext->bCloseDlg = TRUE;
1471 }
1472 }
1473 return FALSE;
1474 }
1475
1476 case WM_CLOSE:
1477 pContext->bCloseDlg = TRUE;
1479 break;
1480
1481 case WM_COMMAND:
1482 switch (LOWORD(wParam))
1483 {
1484 case IDC_LOG_OFF_BUTTON:
1485 case IDOK:
1487 break;
1488
1489 case IDCANCEL:
1490 pContext->bCloseDlg = TRUE;
1492 break;
1493 }
1494 break;
1495
1496 case WM_CTLCOLORSTATIC:
1497 {
1498 /* Either make background transparent or fill it with color for required static controls */
1499 HDC hdcStatic = (HDC)wParam;
1501
1502 switch (StaticID)
1503 {
1505 SetTextColor(hdcStatic, DARK_GREY_COLOR);
1506 SetBkMode(hdcStatic, TRANSPARENT);
1508
1509 case IDC_LOG_OFF_STATIC:
1511 SetTextColor(hdcStatic, LIGHT_GREY_COLOR);
1512 SetBkMode(hdcStatic, TRANSPARENT);
1513 return (LONG_PTR)pContext->hBrush;
1514 }
1515 return FALSE;
1516 }
1517 break;
1518
1519 case WM_DRAWITEM:
1520 {
1521 /* Draw bitmaps on required buttons */
1522 switch (pdis->CtlID)
1523 {
1524 case IDC_LOG_OFF_BUTTON:
1526 return DrawIconOnOwnerDrawnButtons(pdis, pContext);
1527 }
1528 }
1529 break;
1530
1531 default:
1532 break;
1533 }
1534 return FALSE;
1535}
WPARAM wParam
Definition: combotst.c:138
BOOL DrawIconOnOwnerDrawnButtons(DRAWITEMSTRUCT *pdis, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1121
struct LOGOFF_DLG_CONTEXT * PLOGOFF_DLG_CONTEXT
VOID EndFriendlyDialog(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1309
static VOID FancyLogoffOnInit(HWND hwnd, PLOGOFF_DLG_CONTEXT pContext)
Definition: dialogs.cpp:1398
#define LIGHT_GREY_COLOR
Definition: dialogs.cpp:1100
#define IDC_LOG_OFF_STATIC
Definition: shresdef.h:554
#define IDC_SWITCH_USER_STATIC
Definition: shresdef.h:555
#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:917
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define WM_CLOSE
Definition: winuser.h:1649
#define IDCANCEL
Definition: winuser.h:842
#define GWL_ID
Definition: winuser.h:870
#define WM_COMMAND
Definition: winuser.h:1768
#define WA_INACTIVE
Definition: winuser.h:2664
#define WM_INITDIALOG
Definition: winuser.h:1767
#define WM_DRAWITEM
Definition: winuser.h:1673
#define WM_ACTIVATE
Definition: winuser.h:1640
#define WM_DESTROY
Definition: winuser.h:1637
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by LogoffWindowsDialog().

◆ LogoffWindowsDialog()

EXTERN_C int WINAPI LogoffWindowsDialog ( HWND  hWndOwner)

Definition at line 1541 of file dialogs.cpp.

1542{
1543 CComPtr<IUnknown> fadeHandler;
1544 HWND parent = NULL;
1545 DWORD LogoffDialogID = IDD_LOG_OFF;
1547
1548 if (!CallShellDimScreen(&fadeHandler, &parent))
1549 parent = hWndOwner;
1550
1551 Context.bFriendlyUI = IsFriendlyUIActive();
1552 if (Context.bFriendlyUI)
1553 {
1554 LogoffDialogID = IDD_LOG_OFF_FANCY;
1555 }
1556
1558 MAKEINTRESOURCEW(LogoffDialogID),
1559 parent,
1561 (LPARAM)&Context);
1562 return 0;
1563}
static BOOL IsFriendlyUIActive(VOID)
Definition: dialogs.cpp:1324
INT_PTR CALLBACK LogOffDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialogs.cpp:1435
#define IDD_LOG_OFF
Definition: shresdef.h:585
#define IDD_LOG_OFF_FANCY
Definition: shresdef.h:591
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 167 of file dialogs.cpp.

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

Referenced by PickIconProc().

◆ OwnerDrawButtonSubclass()

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

Definition at line 1204 of file dialogs.cpp.

1205{
1206 PLOGOFF_DLG_CONTEXT pContext;
1208
1209 int buttonID = GetDlgCtrlID(hButton);
1210
1211 switch (uMsg)
1212 {
1213 case WM_MOUSEMOVE:
1214 {
1215 HWND hwndTarget = NULL;
1217
1218 if (GetCapture() != hButton)
1219 {
1220 SetCapture(hButton);
1221
1222 switch (buttonID)
1223 {
1224 case IDC_LOG_OFF_BUTTON:
1225 {
1227 break;
1228 }
1230 {
1232 break;
1233 }
1234 }
1236 }
1237
1238 ClientToScreen(hButton, &pt);
1239 hwndTarget = WindowFromPoint(pt);
1240
1241 if (hwndTarget != hButton)
1242 {
1244
1245 switch (buttonID)
1246 {
1247 case IDC_LOG_OFF_BUTTON:
1248 {
1250 break;
1251 }
1253 {
1255 break;
1256 }
1257 }
1258 }
1259 InvalidateRect(hButton, NULL, FALSE);
1260 break;
1261 }
1262
1263 /* Whenever one of the buttons gets the keyboard focus, set it as default button */
1264 case WM_SETFOCUS:
1265 {
1266 SendMessageW(GetParent(hButton), DM_SETDEFID, buttonID, 0);
1267 break;
1268 }
1269
1270 /* Otherwise, set IDCANCEL as default button */
1271 case WM_KILLFOCUS:
1272 {
1274 break;
1275 }
1276 }
1277 return CallWindowProcW(pContext->OldButtonProc, hButton, uMsg, wParam, lParam);
1278}
#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:2135
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define WM_SETFOCUS
Definition: winuser.h:1641
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_MOUSEMOVE
Definition: winuser.h:1803
HWND WINAPI GetCapture(void)
Definition: message.c:2881
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2457
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:706
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:1642

Referenced by FancyLogoffOnInit().

◆ PickIconDlg()

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

Definition at line 352 of file dialogs.cpp.

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

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

Referenced by PickIconDlg().

◆ RestartDialog()

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

Definition at line 1569 of file dialogs.cpp.

1570{
1571 return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
1572}
UINT uFlags
Definition: api.c:59
int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
Definition: dialogs.cpp:1072

◆ RestartDialogEx()

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

Definition at line 1072 of file dialogs.cpp.

1073{
1074 TRACE("(%p)\n", hWndOwner);
1075
1076 CComPtr<IUnknown> fadeHandler;
1077 HWND parent;
1078
1079 if (!CallShellDimScreen(&fadeHandler, &parent))
1080 parent = hWndOwner;
1081
1082 /* FIXME: use lpwstrReason */
1084 {
1085 EnablePrivilege(L"SeShutdownPrivilege", TRUE);
1086 ExitWindowsEx(EWX_REBOOT, uReason);
1087 EnablePrivilege(L"SeShutdownPrivilege", FALSE);
1088 }
1089
1090 return 0;
1091}
#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 423 of file dialogs.cpp.

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

Referenced by RunDlgProc().

◆ RunDlgProc()

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

Definition at line 502 of file dialogs.cpp.

503{
505 HWND hwndCombo, hwndEdit;
506 COMBOBOXINFO ComboInfo;
507
508 switch (message)
509 {
510 case WM_INITDIALOG:
511 prfdp = (RUNFILEDLGPARAMS *)lParam;
513
514 if (prfdp->lpstrTitle)
516 if (prfdp->lpstrDescription)
518 if (prfdp->uFlags & RFF_NOBROWSE)
519 {
521 ShowWindow(browse, SW_HIDE);
522 EnableWindow(browse, FALSE);
523 }
524 if (prfdp->uFlags & RFF_NOLABEL)
526 if (prfdp->uFlags & RFF_NOSEPARATEMEM)
527 {
528 FIXME("RFF_NOSEPARATEMEM not supported\n");
529 }
530
531 /* Use the default Shell Run icon if no one is specified */
532 if (prfdp->hIcon == NULL)
534 /*
535 * NOTE: Starting Windows Vista, the "Run File" dialog gets a
536 * title icon that remains the same as the default one, even if
537 * the user specifies a custom icon.
538 * Since we currently imitate Windows 2003, therefore do not show
539 * any title icon.
540 */
541 // SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)prfdp->hIcon);
542 // SendMessageW(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)prfdp->hIcon);
544
545 hwndCombo = GetDlgItem(hwnd, IDC_RUNDLG_EDITPATH);
546 FillList(hwndCombo, NULL, 0, (prfdp->uFlags & RFF_NODEFAULT) == 0);
548
549 ComboInfo.cbSize = sizeof(ComboInfo);
550 GetComboBoxInfo(hwndCombo, &ComboInfo);
551 hwndEdit = ComboInfo.hwndItem;
553
554 // SHAutoComplete needs co init
556
558
559 SetFocus(hwndCombo);
560 return TRUE;
561
562 case WM_DESTROY:
563 if (prfdp->bCoInited)
565 break;
566
567 case WM_COMMAND:
568 switch (LOWORD(wParam))
569 {
570 case IDOK:
571 {
572 LRESULT lRet;
574 INT ic;
575 WCHAR *psz, *pszExpanded, *parent = NULL;
576 DWORD cchExpand;
577 SHELLEXECUTEINFOW sei = { sizeof(sei) };
578 NMRUNFILEDLGW nmrfd;
579
580 ic = GetWindowTextLengthW(htxt);
581 if (ic == 0)
582 {
584 return TRUE;
585 }
586
587 /*
588 * Allocate a new MRU entry, we need to add two characters
589 * for the terminating "\\1" part, then the NULL character.
590 */
591 psz = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, (ic + 2 + 1)*sizeof(WCHAR));
592 if (!psz)
593 {
595 return TRUE;
596 }
597
598 GetWindowTextW(htxt, psz, ic + 1);
599 sei.hwnd = hwnd;
600 sei.nShow = SW_SHOWNORMAL;
601 sei.lpFile = psz;
602 StrTrimW(psz, L" \t");
603
604 if (wcschr(psz, L'%') != NULL)
605 {
606 cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
607 pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
608 if (!pszExpanded)
609 {
610 HeapFree(GetProcessHeap(), 0, psz);
612 return TRUE;
613 }
614 ExpandEnvironmentStringsW(psz, pszExpanded, cchExpand);
615 StrTrimW(pszExpanded, L" \t");
616 }
617 else
618 {
619 pszExpanded = psz;
620 }
621
622 /*
623 * The precedence is the following: first the user-given
624 * current directory is used; if there is none, a current
625 * directory is computed if the RFF_CALCDIRECTORY is set,
626 * otherwise no current directory is defined.
627 */
628 LPCWSTR pszStartDir;
629 if (prfdp->lpstrDirectory)
630 {
631 sei.lpDirectory = prfdp->lpstrDirectory;
632 pszStartDir = prfdp->lpstrDirectory;
633 }
634 else if (prfdp->uFlags & RFF_CALCDIRECTORY)
635 {
637 pszStartDir = parent = RunDlg_GetParentDir(pszExpanded);
638 }
639 else
640 {
641 sei.lpDirectory = NULL;
642 pszStartDir = NULL;
643 }
644
645 /* Hide the dialog for now on, we will show it up in case of retry */
647
648 /*
649 * As shown by manual tests on Windows, modifying the contents
650 * of the notification structure will not modify what the
651 * Run-Dialog will use for the nShow parameter. However the
652 * lpFile and lpDirectory pointers are set to the buffers used
653 * by the Run-Dialog, as a consequence they can be modified by
654 * the notification receiver, as long as it respects the lengths
655 * of the buffers (to avoid buffer overflows).
656 */
657 nmrfd.hdr.code = RFN_VALIDATE;
658 nmrfd.hdr.hwndFrom = hwnd;
659 nmrfd.hdr.idFrom = 0;
660 nmrfd.lpFile = pszExpanded;
661 nmrfd.lpDirectory = pszStartDir;
662 nmrfd.nShow = SW_SHOWNORMAL;
663
664 lRet = SendMessageW(prfdp->hwndOwner, WM_NOTIFY, 0, (LPARAM)&nmrfd.hdr);
665
666 switch (lRet)
667 {
668 case RF_CANCEL:
670 break;
671
672 case RF_OK:
673 /* We use SECL_NO_UI because we don't want to see
674 * errors here, but we will try again below and
675 * there we will output our errors. */
676 if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
678 {
679 /* Call GetWindowText again in case the contents of the edit box have changed. */
680 GetWindowTextW(htxt, psz, ic + 1);
681 FillList(htxt, psz, ic + 2 + 1, FALSE);
683 break;
684 }
685 else if (ShellExecuteExW(&sei))
686 {
687 /* Call GetWindowText again in case the contents of the edit box have changed. */
688 GetWindowTextW(htxt, psz, ic + 1);
689 FillList(htxt, psz, ic + 2 + 1, FALSE);
691 break;
692 }
693
694 /* Fall-back */
695 case RF_RETRY:
696 default:
697 SendMessageW(htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1));
698 /* Show back the dialog */
700 break;
701 }
702
704 HeapFree(GetProcessHeap(), 0, psz);
705 if (psz != pszExpanded)
706 HeapFree(GetProcessHeap(), 0, pszExpanded);
707 return TRUE;
708 }
709
710 case IDCANCEL:
712 return TRUE;
713
715 {
716 HMODULE hComdlg = NULL;
717 LPFNOFN ofnProc = NULL;
718 WCHAR szFName[1024] = {0};
719 WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
721
724
725 ZeroMemory(&ofn, sizeof(ofn));
726 ofn.lStructSize = sizeof(ofn);
729 ofn.lpstrFile = szFName;
730 ofn.nMaxFile = _countof(szFName) - 1;
731 ofn.lpstrTitle = szCaption;
734
735 if (NULL == (hComdlg = LoadLibraryExW(L"comdlg32", NULL, 0)) ||
736 NULL == (ofnProc = (LPFNOFN)GetProcAddress(hComdlg, "GetOpenFileNameW")))
737 {
738 ERR("Couldn't get GetOpenFileName function entry (lib=%p, proc=%p)\n", hComdlg, ofnProc);
740 return TRUE;
741 }
742
743 if (ofnProc(&ofn))
744 {
750 }
751
752 FreeLibrary(hComdlg);
753
754 return TRUE;
755 }
757 {
760
761 // Delay handling dropdown changes until the edit box has been updated.
764 return TRUE;
765 }
766 }
767 return TRUE;
768 }
769 return FALSE;
770}
#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
BOOL WINAPI StrTrimW(WCHAR *str, const WCHAR *trim)
Definition: string.c:796
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:423
static void FillList(HWND, LPWSTR, UINT, BOOL)
Definition: dialogs.cpp:778
BOOL(WINAPI * LPFNOFN)(OPENFILENAMEW *)
Definition: dialogs.cpp:47
static void EnableOkButtonFromEditContents(HWND hwnd)
Definition: dialogs.cpp:479
#define ShellMessageBoxW
Definition: precomp.h:63
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 SHACF_FILESYSTEM
Definition: shlwapi.h:46
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:51
#define SHACF_URLALL
Definition: shlwapi.h:49
#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:2723
#define IDI_SHELL_RUN
Definition: shresdef.h:618
#define IDC_RUNDLG_LABEL
Definition: shresdef.h:400
#define IDS_RUNDLG_BROWSE_FILTER
Definition: shresdef.h:198
#define IDC_RUNDLG_ICON
Definition: shresdef.h:398
#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:396
LPCWSTR lpstrDirectory
Definition: dialogs.cpp:29
LPCWSTR lpstrTitle
Definition: dialogs.cpp:30
LPCWSTR lpstrDescription
Definition: dialogs.cpp:31
LPCWSTR lpFile
Definition: undocshell.h:192
LPCWSTR lpDirectory
Definition: undocshell.h:193
LPCWSTR lpDirectory
Definition: shellapi.h:340
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3260
UINT code
Definition: winuser.h:3261
HWND hwndFrom
Definition: winuser.h:3259
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define RF_OK
Definition: undocshell.h:202
#define RFN_VALIDATE
Definition: undocshell.h:179
#define RF_RETRY
Definition: undocshell.h:204
#define RF_CANCEL
Definition: undocshell.h:203
#define SW_SHOWNORMAL
Definition: winuser.h:781
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SW_HIDE
Definition: winuser.h:779
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define STM_SETICON
Definition: winuser.h:2128
#define CBN_SELCHANGE
Definition: winuser.h:2008
#define MB_ICONERROR
Definition: winuser.h:798
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI GetComboBoxInfo(_In_ HWND, _Inout_ PCOMBOBOXINFO)
#define MB_OK
Definition: winuser.h:801
#define PostMessage
Definition: winuser.h:5943
#define SW_SHOW
Definition: winuser.h:786
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2427
#define CBN_EDITCHANGE
Definition: winuser.h:2004

Referenced by RunFileDlg().

◆ RunFileDlg()

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

Definition at line 400 of file dialogs.cpp.

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

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

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )