ReactOS 0.4.15-dev-8100-g1887773
filetypes.cpp File Reference
#include "precomp.h"
Include dependency graph for filetypes.cpp:

Go to the source code of this file.

Classes

struct  FILE_TYPE_ENTRY
 
struct  EDITTYPE_DIALOG
 
struct  NEWEXT_DIALOG
 
struct  ACTION_DIALOG
 

Macros

#define LISTBOX_MARGIN   2
 

Typedefs

typedef struct FILE_TYPE_ENTRY FILE_TYPE_ENTRY
 
typedef struct FILE_TYPE_ENTRYPFILE_TYPE_ENTRY
 
typedef struct EDITTYPE_DIALOG EDITTYPE_DIALOG
 
typedef struct EDITTYPE_DIALOGPEDITTYPE_DIALOG
 
typedef struct NEWEXT_DIALOG NEWEXT_DIALOG
 
typedef struct NEWEXT_DIALOGPNEWEXT_DIALOG
 
typedef struct ACTION_DIALOG ACTION_DIALOG
 
typedef struct ACTION_DIALOGPACTION_DIALOG
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (fprop)
 
static BOOL DeleteExt (HWND hwndDlg, LPCWSTR pszExt)
 
static HICON DoExtractIcon (PFILE_TYPE_ENTRY Entry, LPCWSTR IconPath, INT iIndex=0, BOOL bSmall=FALSE)
 
static void DoFileTypeIconLocation (PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation)
 
static BOOL GetFileTypeIconsEx (PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation)
 
static BOOL GetFileTypeIconsByKey (HKEY hKey, PFILE_TYPE_ENTRY Entry)
 
static BOOL QueryFileDescription (LPCWSTR ProgramPath, LPWSTR pszName, INT cchName)
 
static void SetFileTypeEntryDefaultIcon (PFILE_TYPE_ENTRY Entry)
 
static void EditTypeDlg_OnChangeIcon (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnDrawItem (HWND hwndDlg, LPDRAWITEMSTRUCT pDraw, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnMeasureItem (HWND hwndDlg, LPMEASUREITEMSTRUCT pMeasure, PEDITTYPE_DIALOG pEditType)
 
static VOID NewExtDlg_OnAdvanced (HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
 
static BOOL NewExtDlg_OnInitDialog (HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
 
static BOOL NewExtDlg_OnOK (HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
 
static INT_PTR CALLBACK NewExtDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL FileTypesDlg_InsertToLV (HWND hListView, LPCWSTR szName, INT iItem, LPCWSTR szFile)
 
static BOOL FileTypesDlg_AddExt (HWND hwndDlg, LPCWSTR pszExt, LPCWSTR pszFileType)
 
static BOOL FileTypesDlg_RemoveExt (HWND hwndDlg)
 
static void ActionDlg_OnBrowse (HWND hwndDlg, PACTION_DIALOG pNewAct, BOOL bEdit=FALSE)
 
static void NewActionDlg_OnOK (HWND hwndDlg, PACTION_DIALOG pNewAct)
 
static INT_PTR CALLBACK NewActionDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static void EditActionDlg_OnOK (HWND hwndDlg, PACTION_DIALOG pEditAct)
 
static INT_PTR CALLBACK EditActionDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL EditTypeDlg_UpdateEntryIcon (HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR IconPath, INT IconIndex)
 
static BOOL EditTypeDlg_WriteClass (HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR ClassKey, LPCWSTR ClassName, INT cchName)
 
static BOOL EditTypeDlg_ReadClass (HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR ClassKey)
 
static void EditTypeDlg_OnOK (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnRemove (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static void EditTypeDlg_OnCommand (HWND hwndDlg, UINT id, UINT code, PEDITTYPE_DIALOG pEditType)
 
static BOOL EditTypeDlg_OnInitDialog (HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
 
static INT_PTR CALLBACK EditTypeDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT CALLBACK FileTypesDlg_CompareItems (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 
static VOID FileTypesDlg_InitListView (HWND hwndDlg, HWND hListView)
 
static PFILE_TYPE_ENTRY FileTypesDlg_DoList (HWND hwndDlg)
 
static PFILE_TYPE_ENTRY FileTypesDlg_GetEntry (HWND hListView, INT iItem=-1)
 
static void FileTypesDlg_OnDelete (HWND hwndDlg)
 
static void FileTypesDlg_OnItemChanging (HWND hwndDlg, PFILE_TYPE_ENTRY pEntry)
 
INT_PTR CALLBACK FolderOptionsFileTypesDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ LISTBOX_MARGIN

#define LISTBOX_MARGIN   2

Definition at line 210 of file filetypes.cpp.

Typedef Documentation

◆ ACTION_DIALOG

◆ EDITTYPE_DIALOG

◆ FILE_TYPE_ENTRY

◆ NEWEXT_DIALOG

◆ PACTION_DIALOG

◆ PEDITTYPE_DIALOG

◆ PFILE_TYPE_ENTRY

◆ PNEWEXT_DIALOG

Function Documentation

◆ ActionDlg_OnBrowse()

static void ActionDlg_OnBrowse ( HWND  hwndDlg,
PACTION_DIALOG  pNewAct,
BOOL  bEdit = FALSE 
)
static

Definition at line 825 of file filetypes.cpp.

826{
827 WCHAR szFile[MAX_PATH];
828 szFile[0] = 0;
829
832
834
836 ZeroMemory(&ofn, sizeof(ofn));
838 ofn.hwndOwner = hwndDlg;
840 ofn.lpstrFile = szFile;
841 ofn.nMaxFile = _countof(szFile);
842 ofn.lpstrTitle = strTitle;
844 ofn.lpstrDefExt = L"exe";
845 if (GetOpenFileNameW(&ofn))
846 {
847 if (bEdit)
848 {
849 CStringW str = szFile;
850 str += L" \"%1\"";
852 }
853 else
854 {
855 SetDlgItemTextW(hwndDlg, IDC_ACTION_APP, szFile);
856 }
857 }
858}
#define shell32_hInstance
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OPENFILENAME_SIZE_VERSION_400W
Definition: commdlg.h:397
#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
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
#define MAX_PATH
Definition: compat.h:34
LPTSTR szFilter
Definition: mplay32.c:30
CAtlStringW CStringW
Definition: atlstr.h:130
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
#define IDS_EXE_FILTER
Definition: shresdef.h:333
#define IDC_ACTION_APP
Definition: shresdef.h:497
#define IDS_OPEN_WITH
Definition: shresdef.h:136
OPENFILENAME ofn
Definition: sndrec32.cpp:56
#define _countof(array)
Definition: sndvol32.h:70
LPCSTR lpstrDefExt
Definition: commdlg.h:345
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
#define ZeroMemory
Definition: winbase.h:1712
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by EditActionDlgProc(), and NewActionDlgProc().

◆ DeleteExt()

static BOOL DeleteExt ( HWND  hwndDlg,
LPCWSTR  pszExt 
)
static

Definition at line 48 of file filetypes.cpp.

49{
50 if (*pszExt != L'.')
51 return FALSE;
52
53 // open ".ext" key
54 HKEY hKey;
56 return FALSE;
57
58 // query "extfile" key name
59 WCHAR szValue[64] = { 0 };
60 DWORD cbValue = sizeof(szValue);
61 RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(szValue), &cbValue);
63
64 // delete "extfile" key (if any)
65 if (szValue[0])
67
68 // delete ".ext" key
70
71 // notify
73
74 return ret;
75}
#define RegCloseKey(hKey)
Definition: registry.h:49
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define KEY_READ
Definition: nt_native.h:1023
#define SHCNE_ASSOCCHANGED
Definition: shlobj.h:1897
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1915
unsigned char * LPBYTE
Definition: typedefs.h:53
int ret
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by FileTypesDlg_RemoveExt(), and NewExtDlg_OnOK().

◆ DoExtractIcon()

static HICON DoExtractIcon ( PFILE_TYPE_ENTRY  Entry,
LPCWSTR  IconPath,
INT  iIndex = 0,
BOOL  bSmall = FALSE 
)
inlinestatic

Definition at line 78 of file filetypes.cpp.

80{
82
83 if (iIndex < 0)
84 {
85 // A negative value will be interpreted as a negated resource ID.
86 iIndex = -iIndex;
87
88 INT cx, cy;
90 if (bSmall)
91 {
94 }
95 else
96 {
99 }
101 cx, cy, 0));
102 FreeLibrary(hDLL);
103 }
104 else
105 {
106 // A positive value is icon index.
107 if (bSmall)
108 ExtractIconExW(IconPath, iIndex, NULL, &hIcon, 1);
109 else
110 ExtractIconExW(IconPath, iIndex, &hIcon, NULL, 1);
111 }
112 return hIcon;
113}
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
static const WCHAR IconPath[]
Definition: install.c:51
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:849
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
int32_t INT
Definition: typedefs.h:58
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2234
#define SM_CYSMICON
Definition: winuser.h:1013
#define SM_CXSMICON
Definition: winuser.h:1012
#define SM_CYICON
Definition: winuser.h:973
#define SM_CXICON
Definition: winuser.h:972
int WINAPI GetSystemMetrics(_In_ int)

Referenced by DoFileTypeIconLocation(), EditTypeDlg_OnChangeIcon(), and EditTypeDlg_UpdateEntryIcon().

◆ DoFileTypeIconLocation()

static void DoFileTypeIconLocation ( PFILE_TYPE_ENTRY  Entry,
LPCWSTR  IconLocation 
)
static

Definition at line 116 of file filetypes.cpp.

117{
118 // Expand the REG_EXPAND_SZ string by environment variables
119 WCHAR szLocation[MAX_PATH + 32];
120 if (!ExpandEnvironmentStringsW(IconLocation, szLocation, _countof(szLocation)))
121 return;
122
123 Entry->nIconIndex = PathParseIconLocationW(szLocation);
124 StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), szLocation);
125 Entry->hIconLarge = DoExtractIcon(Entry, szLocation, Entry->nIconIndex, FALSE);
126 Entry->hIconSmall = DoExtractIcon(Entry, szLocation, Entry->nIconIndex, TRUE);
127}
#define TRUE
Definition: types.h:120
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1092
static HICON DoExtractIcon(PFILE_TYPE_ENTRY Entry, LPCWSTR IconPath, INT iIndex=0, BOOL bSmall=FALSE)
Definition: filetypes.cpp:78
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
base of all file and directory entries
Definition: entries.h:83

Referenced by GetFileTypeIconsEx().

◆ EditActionDlg_OnOK()

static void EditActionDlg_OnOK ( HWND  hwndDlg,
PACTION_DIALOG  pEditAct 
)
static

Definition at line 938 of file filetypes.cpp.

939{
940 // check action
941 GetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, pEditAct->szAction, _countof(pEditAct->szAction));
942 StrTrimW(pEditAct->szAction, g_pszSpace);
943 if (pEditAct->szAction[0] == 0)
944 {
945 // action was empty. show error
946 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
947 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
948 SetFocus(hwndCtrl);
951 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
952 }
953
954 // check app
955 GetDlgItemTextW(hwndDlg, IDC_ACTION_APP, pEditAct->szApp, _countof(pEditAct->szApp));
956 StrTrimW(pEditAct->szApp, g_pszSpace);
957 if (pEditAct->szApp[0] == 0)
958 {
959 // app was empty. show error
960 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_APP);
961 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
962 SetFocus(hwndCtrl);
965 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
966 }
967
968 EndDialog(hwndDlg, IDOK);
969}
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1877
LPCWSTR g_pszSpace
#define IDS_SPECIFY_ACTION
Definition: shresdef.h:329
#define IDS_INVALID_PROGRAM
Definition: shresdef.h:330
#define IDS_FILE_TYPES
Definition: shresdef.h:187
#define IDC_ACTION_ACTION
Definition: shresdef.h:496
WCHAR szAction[64]
Definition: filetypes.cpp:819
WCHAR szApp[MAX_PATH]
Definition: filetypes.cpp:820
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define MB_ICONERROR
Definition: winuser.h:787
HWND WINAPI SetFocus(_In_opt_ HWND)
#define EM_SETSEL
Definition: winuser.h:2018
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by EditActionDlgProc().

◆ EditActionDlgProc()

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

Definition at line 973 of file filetypes.cpp.

974{
975 static PACTION_DIALOG s_pEditAct = NULL;
976
977 switch (uMsg)
978 {
979 case WM_INITDIALOG:
980 s_pEditAct = (PACTION_DIALOG)lParam;
981 s_pEditAct->bUseDDE = FALSE;
982 SetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, s_pEditAct->szAction);
983 SetDlgItemTextW(hwndDlg, IDC_ACTION_APP, s_pEditAct->szApp);
986 {
987 // set title
989 str += s_pEditAct->ClassName;
990 SetWindowTextW(hwndDlg, str);
991 }
992 return TRUE;
993
994 case WM_COMMAND:
995 switch (LOWORD(wParam))
996 {
997 case IDOK:
998 EditActionDlg_OnOK(hwndDlg, s_pEditAct);
999 break;
1000
1001 case IDCANCEL:
1002 EndDialog(hwndDlg, IDCANCEL);
1003 break;
1004
1005 case IDC_ACTION_BROWSE:
1006 ActionDlg_OnBrowse(hwndDlg, s_pEditAct, TRUE);
1007 break;
1008 }
1009 break;
1010 }
1011 return 0;
1012}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static void EditActionDlg_OnOK(HWND hwndDlg, PACTION_DIALOG pEditAct)
Definition: filetypes.cpp:938
struct ACTION_DIALOG * PACTION_DIALOG
static void ActionDlg_OnBrowse(HWND hwndDlg, PACTION_DIALOG pNewAct, BOOL bEdit=FALSE)
Definition: filetypes.cpp:825
#define LOWORD(l)
Definition: pedump.c:82
#define IDC_ACTION_BROWSE
Definition: shresdef.h:498
#define IDC_ACTION_USE_DDE
Definition: shresdef.h:499
#define IDS_EDITING_ACTION
Definition: shresdef.h:334
WCHAR ClassName[64]
Definition: filetypes.cpp:818
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_OnChangeIcon()

static void EditTypeDlg_OnChangeIcon ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 223 of file filetypes.cpp.

224{
227
229 IconIndex = pEditType->nIconIndex;
230 if (PickIconDlg(hwndDlg, szPath, _countof(szPath), &IconIndex))
231 {
232 // replace Windows directory with "%SystemRoot%" (for portability)
233 WCHAR szWinDir[MAX_PATH];
234 GetWindowsDirectoryW(szWinDir, _countof(szWinDir));
235 if (wcsstr(szPath, szWinDir) == 0)
236 {
237 CStringW str(L"%SystemRoot%");
238 str += &szPath[wcslen(szWinDir)];
240 }
241
242 // update FILE_TYPE_ENTRY
243 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
244 DestroyIcon(pEntry->hIconLarge);
245 DestroyIcon(pEntry->hIconSmall);
248
249 // update EDITTYPE_DIALOG
250 StringCbCopyW(pEditType->szIconPath, sizeof(pEditType->szIconPath), szPath);
251 pEditType->nIconIndex = IconIndex;
252
253 // set icon to dialog
255 }
256}
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
static const WCHAR IconIndex[]
Definition: install.c:52
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:362
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
LPCWSTR szPath
Definition: env.c:37
#define IDC_EDITTYPE_ICON
Definition: shresdef.h:483
WCHAR szIconPath[MAX_PATH]
Definition: filetypes.cpp:217
PFILE_TYPE_ENTRY pEntry
Definition: filetypes.cpp:215
Definition: filetypes.cpp:33
UINT_PTR WPARAM
Definition: windef.h:207
#define STM_SETICON
Definition: winuser.h:2092
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2084
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_OnCommand()

static void EditTypeDlg_OnCommand ( HWND  hwndDlg,
UINT  id,
UINT  code,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1280 of file filetypes.cpp.

1281{
1282 INT iItem, iIndex;
1284 switch (id)
1285 {
1286 case IDOK:
1287 EditTypeDlg_OnOK(hwndDlg, pEditType);
1288 break;
1289
1290 case IDCANCEL:
1291 EndDialog(hwndDlg, IDCANCEL);
1292 break;
1293
1295 EditTypeDlg_OnChangeIcon(hwndDlg, pEditType);
1296 break;
1297
1298 case IDC_EDITTYPE_NEW:
1299 action.bUseDDE = FALSE;
1300 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1301 StringCbPrintfW(action.ClassName, sizeof(action.ClassName), pEditType->pEntry->ClassName);
1302 // open 'New Action' dialog
1305 {
1306 if (SendMessageW(action.hwndLB, LB_FINDSTRING, -1, (LPARAM)action.szAction) != LB_ERR)
1307 {
1308 // already exists, error
1309 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
1310 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
1311 SetFocus(hwndCtrl);
1312
1313 CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_FILE_TYPES));
1314 strText.Format(IDS_ACTION_EXISTS, action.szAction);
1315 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
1316 }
1317 else
1318 {
1319 // add it
1320 CStringW strCommandLine = action.szApp;
1321 strCommandLine += L" \"%1\"";
1322 pEditType->CommandLineMap.SetAt(action.szAction, strCommandLine);
1323 SendMessageW(action.hwndLB, LB_ADDSTRING, 0, LPARAM(action.szAction));
1324 if (SendMessageW(action.hwndLB, LB_GETCOUNT, 0, 0) == 1)
1325 {
1326 // set default
1327 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), action.szAction);
1328 InvalidateRect(action.hwndLB, NULL, TRUE);
1329 }
1330 }
1331 }
1332 break;
1333
1335 if (code == LBN_SELCHANGE)
1336 {
1337 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1338 INT iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1339 SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1340 if (lstrcmpiW(action.szAction, pEditType->szDefaultVerb) == 0)
1341 {
1343 }
1344 else
1345 {
1347 }
1348 break;
1349 }
1350 else if (code != LBN_DBLCLK)
1351 {
1352 break;
1353 }
1354 // FALL THROUGH
1355
1357 action.bUseDDE = FALSE;
1358 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1359 StringCbPrintfW(action.ClassName, sizeof(action.ClassName), pEditType->pEntry->ClassName);
1360 iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1361 if (iItem == LB_ERR)
1362 break;
1363
1364 // get action
1365 SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1366
1367 // get app
1368 {
1369 iIndex = pEditType->CommandLineMap.FindKey(action.szAction);
1370 CStringW str = pEditType->CommandLineMap.GetValueAt(iIndex);
1371 StringCbCopyW(action.szApp, sizeof(action.szApp), LPCWSTR(str));
1372 }
1373
1374 // open dialog
1377 {
1378 SendMessageW(action.hwndLB, LB_DELETESTRING, iItem, 0);
1379 SendMessageW(action.hwndLB, LB_INSERTSTRING, iItem, LPARAM(action.szAction));
1380 pEditType->CommandLineMap.SetAt(action.szAction, action.szApp);
1381 }
1382 break;
1383
1385 EditTypeDlg_OnRemove(hwndDlg, pEditType);
1386 break;
1387
1389 action.hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
1390 iItem = SendMessageW(action.hwndLB, LB_GETCURSEL, 0, 0);
1391 if (iItem == LB_ERR)
1392 break;
1393
1394 SendMessageW(action.hwndLB, LB_GETTEXT, iItem, LPARAM(action.szAction));
1395
1396 // set default
1397 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), action.szAction);
1399 InvalidateRect(action.hwndLB, NULL, TRUE);
1400 break;
1401 }
1402}
TVal & GetValueAt(int nIndex)
Definition: atlsimpcoll.h:358
BOOL SetAt(const TKey &key, const TVal &val)
Definition: atlsimpcoll.h:402
int FindKey(const TKey &key) const
Definition: atlsimpcoll.h:315
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
const WCHAR * action
Definition: action.c:7479
static INT_PTR CALLBACK NewActionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:902
static BOOL EditTypeDlg_OnRemove(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1254
static void EditTypeDlg_OnChangeIcon(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:223
static INT_PTR CALLBACK EditActionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:973
static void EditTypeDlg_OnOK(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1232
#define IDD_ACTION
Definition: shresdef.h:522
#define IDC_EDITTYPE_SET_DEFAULT
Definition: shresdef.h:490
#define IDC_EDITTYPE_EDIT_BUTTON
Definition: shresdef.h:488
#define IDC_EDITTYPE_LISTBOX
Definition: shresdef.h:486
#define IDS_ACTION_EXISTS
Definition: shresdef.h:332
#define IDC_EDITTYPE_NEW
Definition: shresdef.h:487
#define IDC_EDITTYPE_CHANGE_ICON
Definition: shresdef.h:485
#define IDC_EDITTYPE_REMOVE
Definition: shresdef.h:489
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
CSimpleMap< CStringW, CStringW > CommandLineMap
Definition: filetypes.cpp:216
WCHAR szDefaultVerb[64]
Definition: filetypes.cpp:219
WCHAR ClassName[64]
Definition: filetypes.cpp:37
Definition: inflate.c:139
LONG_PTR LPARAM
Definition: windef.h:208
#define LB_ERR
Definition: winuser.h:2432
#define LB_GETCOUNT
Definition: winuser.h:2038
#define LB_GETTEXT
Definition: winuser.h:2049
#define LBN_DBLCLK
Definition: winuser.h:2071
#define LB_ADDSTRING
Definition: winuser.h:2031
#define LB_DELETESTRING
Definition: winuser.h:2032
#define LB_FINDSTRING
Definition: winuser.h:2034
#define LB_INSERTSTRING
Definition: winuser.h:2053
#define LBN_SELCHANGE
Definition: winuser.h:2075
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define LB_GETCURSEL
Definition: winuser.h:2039
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnDrawItem()

static BOOL EditTypeDlg_OnDrawItem ( HWND  hwndDlg,
LPDRAWITEMSTRUCT  pDraw,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 259 of file filetypes.cpp.

260{
261 WCHAR szText[64];
262 HFONT hFont, hFont2;
263
264 if (!pDraw)
265 return FALSE;
266
267 // fill rect and set colors
268 if (pDraw->itemState & ODS_SELECTED)
269 {
270 FillRect(pDraw->hDC, &pDraw->rcItem, HBRUSH(COLOR_HIGHLIGHT + 1));
273 }
274 else
275 {
276 FillRect(pDraw->hDC, &pDraw->rcItem, HBRUSH(COLOR_WINDOW + 1));
279 }
280
281 // get listbox text
282 HWND hwndListBox = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
283 SendMessageW(hwndListBox, LB_GETTEXT, pDraw->itemID, (LPARAM)szText);
284
285 // is it default?
286 hFont = (HFONT)SendMessageW(hwndListBox, WM_GETFONT, 0, 0);
287 if (lstrcmpiW(pEditType->szDefaultVerb, szText) == 0)
288 {
289 // default. set bold
290 LOGFONTW lf;
291 GetObject(hFont, sizeof(lf), &lf);
292 lf.lfWeight = FW_BOLD;
293 hFont2 = CreateFontIndirectW(&lf);
294 if (hFont2)
295 {
296 HGDIOBJ hFontOld = SelectObject(pDraw->hDC, hFont2);
298 DrawTextW(pDraw->hDC, szText, -1, &pDraw->rcItem,
301 SelectObject(pDraw->hDC, hFontOld);
302 DeleteObject(hFont2);
303 }
304 }
305 else
306 {
307 // non-default
309 DrawTextW(pDraw->hDC, szText, -1, &pDraw->rcItem,
312 }
313
314 // draw focus rect
315 if (pDraw->itemState & ODS_FOCUS)
316 {
317 DrawFocusRect(pDraw->hDC, &pDraw->rcItem);
318 }
319 return TRUE;
320}
HFONT hFont
Definition: main.c:53
#define LISTBOX_MARGIN
Definition: filetypes.cpp:210
pKey DeleteObject()
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
LONG lfWeight
Definition: dimm.idl:63
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
#define FW_BOLD
Definition: wingdi.h:378
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
#define GetObject
Definition: wingdi.h:4468
DWORD WINAPI GetSysColor(_In_ int)
#define ODS_SELECTED
Definition: winuser.h:2545
#define DT_NOPREFIX
Definition: winuser.h:537
#define COLOR_WINDOW
Definition: winuser.h:918
#define COLOR_WINDOWTEXT
Definition: winuser.h:921
#define COLOR_HIGHLIGHT
Definition: winuser.h:926
#define DT_SINGLELINE
Definition: winuser.h:540
#define WM_GETFONT
Definition: winuser.h:1651
#define DT_LEFT
Definition: winuser.h:534
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:927
#define DT_VCENTER
Definition: winuser.h:543
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define ODS_FOCUS
Definition: winuser.h:2549

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnInitDialog()

static BOOL EditTypeDlg_OnInitDialog ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1405 of file filetypes.cpp.

1406{
1407 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1408 StringCbCopyW(pEditType->szIconPath, sizeof(pEditType->szIconPath), pEntry->IconPath);
1409 pEditType->nIconIndex = pEntry->nIconIndex;
1410 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), L"open");
1411
1412 // set info
1414 SetDlgItemTextW(hwndDlg, IDC_EDITTYPE_TEXT, pEntry->ClassName);
1415 EditTypeDlg_ReadClass(hwndDlg, pEditType, pEntry->ClassKey);
1417
1418 // is listbox empty?
1419 if (SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_LISTBOX, LB_GETCOUNT, 0, 0) == 0)
1420 {
1424 }
1425 else
1426 {
1427 // select first item
1429 }
1430
1432
1433 return TRUE;
1434}
static BOOL EditTypeDlg_ReadClass(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR ClassKey)
Definition: filetypes.cpp:1165
#define IDC_EDITTYPE_TEXT
Definition: shresdef.h:484
#define IDC_EDITTYPE_SAME_WINDOW
Definition: shresdef.h:493
#define LB_SETCURSEL
Definition: winuser.h:2063

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnMeasureItem()

static BOOL EditTypeDlg_OnMeasureItem ( HWND  hwndDlg,
LPMEASUREITEMSTRUCT  pMeasure,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 323 of file filetypes.cpp.

324{
325 if (!pMeasure)
326 return FALSE;
327
328 HWND hwndLB = GetDlgItem(hwndDlg, IDC_EDITTYPE_LISTBOX);
329
330 HDC hDC = GetDC(hwndLB);
331 if (hDC)
332 {
335 pMeasure->itemHeight = tm.tmHeight + LISTBOX_MARGIN * 2;
336 ReleaseDC(hwndLB, hDC);
337 return TRUE;
338 }
339 return FALSE;
340}
static HDC hDC
Definition: 3dtext.c:33
static HDC
Definition: imagelist.c:92
Definition: time.h:68
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by EditTypeDlgProc().

◆ EditTypeDlg_OnOK()

static void EditTypeDlg_OnOK ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1232 of file filetypes.cpp.

1233{
1234 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1235
1236 // get class name
1237 GetDlgItemTextW(hwndDlg, IDC_EDITTYPE_TEXT, pEntry->ClassName, _countof(pEntry->ClassName));
1238 StrTrimW(pEntry->ClassName, g_pszSpace);
1239
1240 // update entry icon
1241 EditTypeDlg_UpdateEntryIcon(hwndDlg, pEditType, pEditType->szIconPath, pEditType->nIconIndex);
1242
1243 // write registry
1244 EditTypeDlg_WriteClass(hwndDlg, pEditType, pEntry->ClassKey, pEntry->ClassName,
1245 _countof(pEntry->ClassName));
1246
1247 // update the icon cache
1249
1250 EndDialog(hwndDlg, IDOK);
1251}
static BOOL EditTypeDlg_UpdateEntryIcon(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR IconPath, INT IconIndex)
Definition: filetypes.cpp:1018
static BOOL EditTypeDlg_WriteClass(HWND hwndDlg, PEDITTYPE_DIALOG pEditType, LPCWSTR ClassKey, LPCWSTR ClassName, INT cchName)
Definition: filetypes.cpp:1063

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_OnRemove()

static BOOL EditTypeDlg_OnRemove ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType 
)
static

Definition at line 1254 of file filetypes.cpp.

1255{
1256 // get current selection
1258 if (iItem == LB_ERR)
1259 return FALSE;
1260
1261 // ask user for removal
1264 if (MessageBoxW(hwndDlg, strText, strTitle, MB_ICONINFORMATION | MB_YESNO) == IDNO)
1265 return FALSE;
1266
1267 // get text
1268 WCHAR szText[64];
1269 szText[0] = 0;
1270 SendDlgItemMessageW(hwndDlg, IDC_EDITTYPE_LISTBOX, LB_GETTEXT, iItem, (LPARAM)szText);
1271 StrTrimW(szText, g_pszSpace);
1272
1273 // remove it
1274 pEditType->CommandLineMap.Remove(szText);
1276 return TRUE;
1277}
BOOL Remove(const TKey &key)
Definition: atlsimpcoll.h:378
#define IDS_REMOVE_ACTION
Definition: shresdef.h:331
#define MB_YESNO
Definition: winuser.h:817
#define IDNO
Definition: winuser.h:836
#define MB_ICONINFORMATION
Definition: winuser.h:802

Referenced by EditTypeDlg_OnCommand().

◆ EditTypeDlg_ReadClass()

static BOOL EditTypeDlg_ReadClass ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType,
LPCWSTR  ClassKey 
)
static

Definition at line 1165 of file filetypes.cpp.

1166{
1167 // open class key
1170 return FALSE;
1171
1172 // open "shell" key
1173 HKEY hShellKey;
1174 if (RegOpenKeyExW(hClassKey, L"shell", 0, KEY_READ, &hShellKey) != ERROR_SUCCESS)
1175 {
1177 return FALSE;
1178 }
1179
1180 WCHAR DefaultVerb[64];
1181 DWORD dwSize = sizeof(DefaultVerb);
1182 if (RegQueryValueExW(hShellKey, NULL, NULL, NULL,
1183 LPBYTE(DefaultVerb), &dwSize) == ERROR_SUCCESS)
1184 {
1185 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), DefaultVerb);
1186 }
1187 else
1188 {
1189 StringCbCopyW(pEditType->szDefaultVerb, sizeof(pEditType->szDefaultVerb), L"open");
1190 }
1191
1192 // enumerate shell verbs
1193 WCHAR szVerbName[64];
1194 DWORD dwIndex = 0;
1195 while (RegEnumKeyW(hShellKey, dwIndex, szVerbName, _countof(szVerbName)) == ERROR_SUCCESS)
1196 {
1197 // open verb key
1198 HKEY hVerbKey;
1199 LONG nResult = RegOpenKeyExW(hShellKey, szVerbName, 0, KEY_READ, &hVerbKey);
1200 if (nResult == ERROR_SUCCESS)
1201 {
1202 // open command key
1203 HKEY hCommandKey;
1204 nResult = RegOpenKeyExW(hVerbKey, L"command", 0, KEY_READ, &hCommandKey);
1205 if (nResult == ERROR_SUCCESS)
1206 {
1207 // get command line
1208 WCHAR szValue[MAX_PATH + 32];
1209 dwSize = sizeof(szValue);
1210 nResult = RegQueryValueExW(hCommandKey, NULL, NULL, NULL, LPBYTE(szValue), &dwSize);
1211 if (nResult == ERROR_SUCCESS)
1212 {
1213 pEditType->CommandLineMap.SetAt(szVerbName, szValue);
1214 }
1215
1216 RegCloseKey(hCommandKey);
1217 }
1218
1219 RegCloseKey(hVerbKey);
1220 }
1222 ++dwIndex;
1223 }
1224
1225 RegCloseKey(hShellKey);
1227
1228 return TRUE;
1229}
HKEY hClassKey
Definition: umpnpmgr.c:45
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
long LONG
Definition: pedump.c:60

Referenced by EditTypeDlg_OnInitDialog().

◆ EditTypeDlg_UpdateEntryIcon()

static BOOL EditTypeDlg_UpdateEntryIcon ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType,
LPCWSTR  IconPath,
INT  IconIndex 
)
static

Definition at line 1018 of file filetypes.cpp.

1020{
1021 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1022
1023 BOOL bIconSet = FALSE;
1024 if (IconPath && IconPath[0])
1025 {
1026 DestroyIcon(pEntry->hIconLarge);
1027 DestroyIcon(pEntry->hIconSmall);
1030
1031 bIconSet = (pEntry->hIconLarge && pEntry->hIconSmall);
1032 }
1033 if (bIconSet)
1034 {
1035 StringCbCopyW(pEntry->IconPath, sizeof(pEntry->IconPath), IconPath);
1036 pEntry->nIconIndex = IconIndex;
1037 }
1038 else
1039 {
1041 }
1042
1043 HWND hListView = pEditType->hwndLV;
1044 HIMAGELIST himlLarge = ListView_GetImageList(hListView, LVSIL_NORMAL);
1045 HIMAGELIST himlSmall = ListView_GetImageList(hListView, LVSIL_SMALL);
1046
1047 INT iLargeImage = ImageList_AddIcon(himlLarge, pEntry->hIconLarge);
1048 INT iSmallImage = ImageList_AddIcon(himlSmall, pEntry->hIconSmall);
1049 ASSERT(iLargeImage == iSmallImage);
1051
1052 INT iItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
1053 if (iItem != -1)
1054 {
1055 LV_ITEMW Item = { LVIF_IMAGE, iItem };
1056 Item.iImage = iSmallImage;
1057 ListView_SetItem(hListView, &Item);
1058 }
1059 return TRUE;
1060}
static void SetFileTypeEntryDefaultIcon(PFILE_TYPE_ENTRY Entry)
Definition: filetypes.cpp:196
#define ASSERT(a)
Definition: mode.c:44
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define ListView_GetImageList(hwnd, iImageList)
Definition: commctrl.h:2296
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
#define ListView_SetItem(hwnd, pitem)
Definition: commctrl.h:2401
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define LV_ITEMW
Definition: commctrl.h:2332
#define LVIF_IMAGE
Definition: commctrl.h:2310
#define LVSIL_NORMAL
Definition: commctrl.h:2298
_In_ WDFCOLLECTION _In_ WDFOBJECT Item

Referenced by EditTypeDlg_OnOK().

◆ EditTypeDlg_WriteClass()

static BOOL EditTypeDlg_WriteClass ( HWND  hwndDlg,
PEDITTYPE_DIALOG  pEditType,
LPCWSTR  ClassKey,
LPCWSTR  ClassName,
INT  cchName 
)
static

Definition at line 1063 of file filetypes.cpp.

1065{
1066 PFILE_TYPE_ENTRY pEntry = pEditType->pEntry;
1067
1068 if (ClassKey[0] == 0)
1069 return FALSE;
1070
1071 // create or open class key
1073 if (RegCreateKeyExW(HKEY_CLASSES_ROOT, ClassKey, 0, NULL, 0, KEY_WRITE, NULL,
1075 {
1076 return FALSE;
1077 }
1078
1079 // create "DefaultIcon" key
1080 if (pEntry->IconPath[0])
1081 {
1082 HKEY hDefaultIconKey;
1083 if (RegCreateKeyExW(hClassKey, L"DefaultIcon", 0, NULL, 0, KEY_WRITE, NULL,
1084 &hDefaultIconKey, NULL) == ERROR_SUCCESS)
1085 {
1086 WCHAR szText[MAX_PATH];
1087 StringCbPrintfW(szText, sizeof(szText), L"%s,%d",
1088 pEntry->IconPath, pEntry->nIconIndex);
1089
1090 // set icon location
1091 DWORD dwSize = (lstrlenW(szText) + 1) * sizeof(WCHAR);
1092 RegSetValueExW(hDefaultIconKey, NULL, 0, REG_EXPAND_SZ, LPBYTE(szText), dwSize);
1093
1094 RegCloseKey(hDefaultIconKey);
1095 }
1096 }
1097
1098 // create "shell" key
1099 HKEY hShellKey;
1100 if (RegCreateKeyExW(hClassKey, L"shell", 0, NULL, 0, KEY_WRITE, NULL,
1101 &hShellKey, NULL) != ERROR_SUCCESS)
1102 {
1104 return FALSE;
1105 }
1106
1107 // delete shell commands
1108 WCHAR szVerbName[64];
1109 DWORD dwIndex = 0;
1110 while (RegEnumKeyW(hShellKey, dwIndex, szVerbName, _countof(szVerbName)) == ERROR_SUCCESS)
1111 {
1112 if (pEditType->CommandLineMap.FindKey(szVerbName) == -1)
1113 {
1114 // doesn't exist in CommandLineMap, then delete it
1115 if (SHDeleteKeyW(hShellKey, szVerbName) == ERROR_SUCCESS)
1116 {
1117 --dwIndex;
1118 }
1119 }
1120 ++dwIndex;
1121 }
1122
1123 // set default action
1124 RegSetValueExW(hShellKey, NULL, 0, REG_SZ,
1125 LPBYTE(pEditType->szDefaultVerb), sizeof(pEditType->szDefaultVerb));
1126
1127 // write shell commands
1128 const INT nCount = pEditType->CommandLineMap.GetSize();
1129 for (INT i = 0; i < nCount; ++i)
1130 {
1131 CStringW& key = pEditType->CommandLineMap.GetKeyAt(i);
1132 CStringW& value = pEditType->CommandLineMap.GetValueAt(i);
1133
1134 // create verb key
1135 HKEY hVerbKey;
1136 if (RegCreateKeyExW(hShellKey, key, 0, NULL, 0, KEY_WRITE, NULL,
1137 &hVerbKey, NULL) == ERROR_SUCCESS)
1138 {
1139 // create command key
1140 HKEY hCommandKey;
1141 if (RegCreateKeyExW(hVerbKey, L"command", 0, NULL, 0, KEY_WRITE, NULL,
1142 &hCommandKey, NULL) == ERROR_SUCCESS)
1143 {
1144 // write the default value
1145 DWORD dwSize = (value.GetLength() + 1) * sizeof(WCHAR);
1147
1148 RegCloseKey(hCommandKey);
1149 }
1150
1151 RegCloseKey(hVerbKey);
1152 }
1153 }
1154
1155 // set class name to class key
1156 RegSetValueExW(hClassKey, NULL, 0, REG_SZ, LPBYTE(ClassName), cchName);
1157
1158 RegCloseKey(hShellKey);
1160
1161 return TRUE;
1162}
TKey & GetKeyAt(int nIndex)
Definition: atlsimpcoll.h:341
int GetSize() const
Definition: atlsimpcoll.h:353
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
#define lstrlenW
Definition: compat.h:750
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
#define REG_SZ
Definition: layer.c:22
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
Definition: copy.c:22
Definition: pdh_main.c:94
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2767

Referenced by EditTypeDlg_OnOK().

◆ EditTypeDlgProc()

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

Definition at line 1438 of file filetypes.cpp.

1439{
1440 static PEDITTYPE_DIALOG s_pEditType = NULL;
1441 LPDRAWITEMSTRUCT pDraw;
1442 LPMEASUREITEMSTRUCT pMeasure;
1443
1444 switch (uMsg)
1445 {
1446 case WM_INITDIALOG:
1447 s_pEditType = (PEDITTYPE_DIALOG)lParam;
1448 return EditTypeDlg_OnInitDialog(hwndDlg, s_pEditType);
1449
1450 case WM_DRAWITEM:
1451 pDraw = LPDRAWITEMSTRUCT(lParam);
1452 return EditTypeDlg_OnDrawItem(hwndDlg, pDraw, s_pEditType);
1453
1454 case WM_MEASUREITEM:
1455 pMeasure = LPMEASUREITEMSTRUCT(lParam);
1456 return EditTypeDlg_OnMeasureItem(hwndDlg, pMeasure, s_pEditType);
1457
1458 case WM_COMMAND:
1459 EditTypeDlg_OnCommand(hwndDlg, LOWORD(wParam), HIWORD(wParam), s_pEditType);
1460 break;
1461 }
1462
1463 return 0;
1464}
struct EDITTYPE_DIALOG * PEDITTYPE_DIALOG
static BOOL EditTypeDlg_OnDrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT pDraw, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:259
static BOOL EditTypeDlg_OnMeasureItem(HWND hwndDlg, LPMEASUREITEMSTRUCT pMeasure, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:323
static BOOL EditTypeDlg_OnInitDialog(HWND hwndDlg, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1405
static void EditTypeDlg_OnCommand(HWND hwndDlg, UINT id, UINT code, PEDITTYPE_DIALOG pEditType)
Definition: filetypes.cpp:1280
#define HIWORD(l)
Definition: typedefs.h:247
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
struct tagMEASUREITEMSTRUCT * LPMEASUREITEMSTRUCT
#define WM_DRAWITEM
Definition: winuser.h:1645
#define WM_MEASUREITEM
Definition: winuser.h:1646

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_AddExt()

static BOOL FileTypesDlg_AddExt ( HWND  hwndDlg,
LPCWSTR  pszExt,
LPCWSTR  pszFileType 
)
static

Definition at line 715 of file filetypes.cpp.

716{
717 DWORD dwValue = 1;
718 HKEY hKey;
719 WCHAR szKey[13]; // max. "ft4294967295" + "\0"
720 LONG nResult;
721
722 // Search the next "ft%06u" key name
723 do
724 {
725 StringCbPrintfW(szKey, sizeof(szKey), L"ft%06u", dwValue);
726
727 nResult = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hKey);
728 if (nResult != ERROR_SUCCESS)
729 break;
730
732 ++dwValue;
733 } while (dwValue != 0);
734
736
737 if (dwValue == 0)
738 return FALSE;
739
740 // Create new "ft%06u" key
741 nResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
742 if (ERROR_SUCCESS != nResult)
743 return FALSE;
744
746
747 // Create the ".ext" key
748 WCHAR szExt[16];
749 if (*pszExt == L'.')
750 ++pszExt;
751 StringCbPrintfW(szExt, sizeof(szExt), L".%s", pszExt);
752 _wcslwr(szExt);
753 nResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, szExt, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
754 _wcsupr(szExt);
755 if (ERROR_SUCCESS != nResult)
756 return FALSE;
757
758 // Set the default value of ".ext" to "ft%06u"
759 DWORD dwSize = (lstrlen(szKey) + 1) * sizeof(WCHAR);
761
763
764 // Make up the file type name
765 WCHAR szFile[100];
767 StringCbPrintfW(szFile, sizeof(szFile), strFormat, &szExt[1]);
768
769 // Insert an item to the listview
770 HWND hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
771 INT iItem = ListView_GetItemCount(hListView);
772 if (!FileTypesDlg_InsertToLV(hListView, szExt, iItem, szFile))
773 return FALSE;
774
776 ZeroMemory(&item, sizeof(item));
777 item.mask = LVIF_STATE | LVIF_TEXT;
778 item.iItem = iItem;
780 item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
781 item.pszText = &szExt[1];
782 ListView_SetItem(hListView, &item);
783
784 item.pszText = szFile;
785 item.iSubItem = 1;
786 ListView_SetItem(hListView, &item);
787
788 ListView_EnsureVisible(hListView, iItem, FALSE);
789
790 return TRUE;
791}
static BOOL FileTypesDlg_InsertToLV(HWND hListView, LPCWSTR szName, INT iItem, LPCWSTR szFile)
Definition: filetypes.cpp:565
static ATOM item
Definition: dde.c:856
#define LVIF_STATE
Definition: commctrl.h:2312
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
#define LVIS_SELECTED
Definition: commctrl.h:2319
#define LV_ITEM
Definition: commctrl.h:2337
#define LVIF_TEXT
Definition: commctrl.h:2309
#define LVIS_FOCUSED
Definition: commctrl.h:2318
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2519
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
_CRTIMP wchar_t *__cdecl _wcslwr(_Inout_z_ wchar_t *_String)
#define IDC_FILETYPES_LISTVIEW
Definition: shresdef.h:441
#define IDS_FILE_EXT_TYPE
Definition: shresdef.h:190
#define lstrlen
Definition: winbase.h:3876
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_CompareItems()

static INT CALLBACK FileTypesDlg_CompareItems ( LPARAM  lParam1,
LPARAM  lParam2,
LPARAM  lParamSort 
)
static

Definition at line 1470 of file filetypes.cpp.

1471{
1472 PFILE_TYPE_ENTRY Entry1, Entry2;
1473 int x;
1474
1475 Entry1 = (PFILE_TYPE_ENTRY)lParam1;
1476 Entry2 = (PFILE_TYPE_ENTRY)lParam2;
1477
1478 x = wcsicmp(Entry1->FileExtension, Entry2->FileExtension);
1479 if (x != 0)
1480 return x;
1481
1482 return wcsicmp(Entry1->FileDescription, Entry2->FileDescription);
1483}
#define wcsicmp
Definition: compat.h:15
struct FILE_TYPE_ENTRY * PFILE_TYPE_ENTRY
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
WCHAR FileExtension[30]
Definition: filetypes.cpp:34
WCHAR FileDescription[100]
Definition: filetypes.cpp:35

Referenced by FileTypesDlg_DoList().

◆ FileTypesDlg_DoList()

static PFILE_TYPE_ENTRY FileTypesDlg_DoList ( HWND  hwndDlg)
static

Definition at line 1534 of file filetypes.cpp.

1535{
1536 HWND hListView;
1537 DWORD dwIndex = 0;
1538 WCHAR szName[50];
1539 WCHAR szFile[100];
1540 DWORD dwName;
1541 LVITEMW lvItem;
1542 INT iItem = 0;
1543 HIMAGELIST himlLarge, himlSmall;
1544
1545 // create imagelists
1547 ILC_COLOR32 | ILC_MASK, 256, 20);
1549 ILC_COLOR32 | ILC_MASK, 256, 20);
1550
1551 // set imagelists to listview.
1552 hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1553 ListView_SetImageList(hListView, himlLarge, LVSIL_NORMAL);
1554 ListView_SetImageList(hListView, himlSmall, LVSIL_SMALL);
1555
1556 FileTypesDlg_InitListView(hwndDlg, hListView);
1557
1558 szFile[0] = 0;
1560 {
1561 // default to english
1562 wcscpy(szFile, L"%s File");
1563 }
1564 szFile[(_countof(szFile)) - 1] = 0;
1565
1566 dwName = _countof(szName);
1567
1568 while (RegEnumKeyExW(HKEY_CLASSES_ROOT, dwIndex++, szName, &dwName,
1570 {
1571 if (FileTypesDlg_InsertToLV(hListView, szName, iItem, szFile))
1572 ++iItem;
1573 dwName = _countof(szName);
1574 }
1575
1576 // Leave if the list is empty
1577 if (iItem == 0)
1578 return NULL;
1579
1580 // sort list
1582
1583 // select first item
1584 ZeroMemory(&lvItem, sizeof(LVITEMW));
1585 lvItem.mask = LVIF_STATE;
1586 lvItem.stateMask = (UINT)-1;
1587 lvItem.state = LVIS_FOCUSED | LVIS_SELECTED;
1588 lvItem.iItem = 0;
1589 ListView_SetItem(hListView, &lvItem);
1590
1591 lvItem.mask = LVIF_PARAM;
1592 ListView_GetItem(hListView, &lvItem);
1593
1594 return (PFILE_TYPE_ENTRY)lvItem.lParam;
1595}
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
static VOID FileTypesDlg_InitListView(HWND hwndDlg, HWND hListView)
Definition: filetypes.cpp:1486
static INT CALLBACK FileTypesDlg_CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: filetypes.cpp:1470
unsigned int UINT
Definition: ndis.h:50
static const WCHAR szName[]
Definition: powrprof.c:45
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
#define ILC_COLOR32
Definition: commctrl.h:358
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2703
#define LVIF_PARAM
Definition: commctrl.h:2311
#define ILC_MASK
Definition: commctrl.h:351
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2394
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
UINT state
Definition: commctrl.h:2363
UINT mask
Definition: commctrl.h:2360
LPARAM lParam
Definition: commctrl.h:2368
UINT stateMask
Definition: commctrl.h:2364

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_GetEntry()

static PFILE_TYPE_ENTRY FileTypesDlg_GetEntry ( HWND  hListView,
INT  iItem = -1 
)
inlinestatic

Definition at line 1598 of file filetypes.cpp.

1599{
1600 if (iItem == -1)
1601 {
1602 iItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
1603 if (iItem == -1)
1604 return NULL;
1605 }
1606
1607 LV_ITEMW lvItem = { LVIF_PARAM, iItem };
1608 if (ListView_GetItem(hListView, &lvItem))
1609 return (PFILE_TYPE_ENTRY)lvItem.lParam;
1610
1611 return NULL;
1612}

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_InitListView()

static VOID FileTypesDlg_InitListView ( HWND  hwndDlg,
HWND  hListView 
)
static

Definition at line 1486 of file filetypes.cpp.

1487{
1488 RECT clientRect;
1489 LVCOLUMNW col;
1490 WCHAR szName[50];
1491 DWORD dwStyle;
1492 INT columnSize;
1493
1495 {
1496 // default to english
1497 wcscpy(szName, L"Extensions");
1498 }
1499
1500 // make sure its null terminated
1501 szName[_countof(szName) - 1] = 0;
1502
1503 GetClientRect(hListView, &clientRect);
1504 ZeroMemory(&col, sizeof(LV_COLUMN));
1505 columnSize = (clientRect.right - clientRect.left) / 4;
1506 col.iSubItem = 0;
1508 col.fmt = LVCFMT_FIXED_WIDTH;
1509 col.cx = columnSize | LVCFMT_LEFT;
1510 col.cchTextMax = wcslen(szName);
1511 col.pszText = szName;
1512 SendMessageW(hListView, LVM_INSERTCOLUMNW, 0, (LPARAM)&col);
1513
1515 {
1516 // default to english
1517 wcscpy(szName, L"File Types");
1518 ERR("Failed to load localized string!\n");
1519 }
1520
1521 col.iSubItem = 1;
1522 col.cx = clientRect.right - clientRect.left - columnSize - GetSystemMetrics(SM_CYVSCROLL);
1523 col.cchTextMax = wcslen(szName);
1524 col.pszText = szName;
1525 SendMessageW(hListView, LVM_INSERTCOLUMNW, 1, (LPARAM)&col);
1526
1527 // set full select style
1528 dwStyle = (DWORD)SendMessage(hListView, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
1529 dwStyle = dwStyle | LVS_EX_FULLROWSELECT;
1530 SendMessage(hListView, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
1531}
#define ERR(fmt,...)
Definition: debug.h:113
#define DWORD
Definition: nt_native.h:44
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2632
#define LVM_GETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2727
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define LVCF_TEXT
Definition: commctrl.h:2588
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2724
#define LV_COLUMN
Definition: commctrl.h:2547
#define IDS_COLUMN_EXTENSION
Definition: shresdef.h:144
int cchTextMax
Definition: commctrl.h:2568
LPWSTR pszText
Definition: commctrl.h:2567
LONG right
Definition: windef.h:308
LONG left
Definition: windef.h:306
#define SM_CYVSCROLL
Definition: winuser.h:981
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SendMessage
Definition: winuser.h:5843

Referenced by FileTypesDlg_DoList().

◆ FileTypesDlg_InsertToLV()

static BOOL FileTypesDlg_InsertToLV ( HWND  hListView,
LPCWSTR  szName,
INT  iItem,
LPCWSTR  szFile 
)
static

Definition at line 565 of file filetypes.cpp.

566{
568 HKEY hKey;
569 LVITEMW lvItem;
571 DWORD dwType;
572
573 if (szName[0] != L'.')
574 {
575 // FIXME handle URL protocol handlers
576 return FALSE;
577 }
578
579 // get imagelists of listview
580 HIMAGELIST himlLarge = ListView_GetImageList(hListView, LVSIL_NORMAL);
581 HIMAGELIST himlSmall = ListView_GetImageList(hListView, LVSIL_SMALL);
582
583 // allocate file type entry
585 if (!Entry)
586 return FALSE;
587
588 // open key
590 {
592 return FALSE;
593 }
594
595 // FIXME check for duplicates
596
597 // query for the default key
598 dwSize = sizeof(Entry->ClassKey);
600 {
601 // no link available
602 Entry->ClassKey[0] = 0;
603 }
604
605 Entry->ClassName[0] = 0;
606 if (Entry->ClassKey[0])
607 {
608 HKEY hTemp;
609 // try open linked key
610 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, Entry->ClassKey, 0, KEY_READ, &hTemp) == ERROR_SUCCESS)
611 {
612 DWORD dwSize = sizeof(Entry->ClassName);
613 RegQueryValueExW(hTemp, NULL, NULL, NULL, LPBYTE(Entry->ClassName), &dwSize);
614
615 // use linked key
617 hKey = hTemp;
618 }
619 }
620
621 // read friendly type name
622 if (RegLoadMUIStringW(hKey, L"FriendlyTypeName", Entry->FileDescription,
623 sizeof(Entry->FileDescription), NULL, 0, NULL) != ERROR_SUCCESS)
624 {
625 // read file description
626 dwSize = sizeof(Entry->FileDescription);
627 Entry->FileDescription[0] = 0;
628
629 // read default key
630 RegQueryValueExW(hKey, NULL, NULL, NULL, LPBYTE(Entry->FileDescription), &dwSize);
631 }
632
633 // Read the EditFlags value
634 Entry->EditFlags = 0;
635 if (!RegQueryValueExW(hKey, L"EditFlags", NULL, &dwType, NULL, &dwSize))
636 {
637 if ((dwType == REG_DWORD || dwType == REG_BINARY) && dwSize == sizeof(DWORD))
638 RegQueryValueExW(hKey, L"EditFlags", NULL, NULL, (LPBYTE)&Entry->EditFlags, &dwSize);
639 }
640
641 // convert extension to upper case
642 wcscpy(Entry->FileExtension, szName);
643 _wcsupr(Entry->FileExtension);
644
645 // get icon
647 {
648 // set default icon
650 }
651
652 // close key
654
655 // get program path and app name
656 DWORD cch = _countof(Entry->ProgramPath);
658 Entry->FileExtension, NULL, Entry->ProgramPath, &cch))
659 {
660 QueryFileDescription(Entry->ProgramPath, Entry->AppName, _countof(Entry->AppName));
661 }
662 else
663 {
664 Entry->ProgramPath[0] = Entry->AppName[0] = 0;
665 }
666
667 // add icon to imagelist
668 INT iLargeImage = -1, iSmallImage = -1;
669 if (Entry->hIconLarge && Entry->hIconSmall)
670 {
671 iLargeImage = ImageList_AddIcon(himlLarge, Entry->hIconLarge);
672 iSmallImage = ImageList_AddIcon(himlSmall, Entry->hIconSmall);
673 ASSERT(iLargeImage == iSmallImage);
675 }
676
677 // Do not add excluded entries
678 if (Entry->EditFlags & 0x00000001) //FTA_Exclude
679 {
680 DestroyIcon(Entry->hIconLarge);
681 DestroyIcon(Entry->hIconSmall);
683 return FALSE;
684 }
685
686 if (!Entry->FileDescription[0])
687 {
688 // construct default 'FileExtensionFile' by formatting the uppercase extension
689 // with IDS_FILE_EXT_TYPE, outputting something like a l18n 'INI File'
690
691 StringCbPrintfW(Entry->FileDescription, sizeof(Entry->FileDescription),
692 szFile, &Entry->FileExtension[1]);
693 }
694
695 ZeroMemory(&lvItem, sizeof(LVITEMW));
696 lvItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
697 lvItem.iSubItem = 0;
698 lvItem.pszText = &Entry->FileExtension[1];
699 lvItem.iItem = iItem;
700 lvItem.lParam = (LPARAM)Entry;
701 lvItem.iImage = iSmallImage;
702 SendMessageW(hListView, LVM_INSERTITEMW, 0, (LPARAM)&lvItem);
703
704 ZeroMemory(&lvItem, sizeof(LVITEMW));
705 lvItem.mask = LVIF_TEXT;
706 lvItem.pszText = Entry->FileDescription;
707 lvItem.iItem = iItem;
708 lvItem.iSubItem = 1;
709 ListView_SetItem(hListView, &lvItem);
710
711 return TRUE;
712}
LONG RegLoadMUIStringW(IN HKEY hKey, IN LPCWSTR pszValue OPTIONAL, OUT LPWSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCWSTR pszDirectory OPTIONAL)
Definition: muireg.c:53
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:436
static BOOL QueryFileDescription(LPCWSTR ProgramPath, LPWSTR pszName, INT cchName)
Definition: filetypes.cpp:183
static BOOL GetFileTypeIconsByKey(HKEY hKey, PFILE_TYPE_ENTRY Entry)
Definition: filetypes.cpp:159
#define S_OK
Definition: intsafe.h:52
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define REG_BINARY
Definition: nt_native.h:1496
#define LVM_INSERTITEMW
Definition: commctrl.h:2404
#define REG_DWORD
Definition: sdbapi.c:596
@ ASSOCSTR_EXECUTABLE
Definition: shlwapi.h:604
@ ASSOCF_INIT_IGNOREUNKNOWN
Definition: shlwapi.h:593
LPWSTR pszText
Definition: commctrl.h:2365
int iSubItem
Definition: commctrl.h:2362
int iImage
Definition: commctrl.h:2367

Referenced by FileTypesDlg_AddExt(), and FileTypesDlg_DoList().

◆ FileTypesDlg_OnDelete()

static void FileTypesDlg_OnDelete ( HWND  hwndDlg)
static

Definition at line 1615 of file filetypes.cpp.

1616{
1619 if (MessageBoxW(hwndDlg, strRemoveExt, strTitle, MB_ICONQUESTION | MB_YESNO) == IDYES)
1620 {
1621 FileTypesDlg_RemoveExt(hwndDlg);
1622
1623 // Select first item (Win2k3 does it)
1624 LV_ITEMW item = { LVIF_STATE };
1625 item.stateMask = item.state = LVIS_FOCUSED | LVIS_SELECTED;
1626 item.iItem = 0;
1628 }
1629}
static BOOL FileTypesDlg_RemoveExt(HWND hwndDlg)
Definition: filetypes.cpp:794
#define IDS_REMOVE_EXT
Definition: shresdef.h:336
#define MB_ICONQUESTION
Definition: winuser.h:789
#define IDYES
Definition: winuser.h:835

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_OnItemChanging()

static void FileTypesDlg_OnItemChanging ( HWND  hwndDlg,
PFILE_TYPE_ENTRY  pEntry 
)
static

Definition at line 1632 of file filetypes.cpp.

1633{
1634 WCHAR Buffer[255];
1635 static HBITMAP s_hbmProgram = NULL;
1636
1637 // format buffer and set groupbox text
1639 StringCbPrintfW(Buffer, sizeof(Buffer), strFormat, &pEntry->FileExtension[1]);
1641
1642 // format buffer and set description
1643 strFormat.LoadString(IDS_FILE_DETAILSADV);
1644 StringCbPrintfW(Buffer, sizeof(Buffer), strFormat,
1645 &pEntry->FileExtension[1], pEntry->FileDescription,
1646 pEntry->FileDescription);
1648
1649 // delete previous program image
1650 if (s_hbmProgram)
1651 {
1652 DeleteObject(s_hbmProgram);
1653 s_hbmProgram = NULL;
1654 }
1655
1656 // set program image
1657 HICON hIconSm = NULL;
1658 ExtractIconExW(pEntry->ProgramPath, 0, NULL, &hIconSm, 1);
1659 s_hbmProgram = BitmapFromIcon(hIconSm, 16, 16);
1662
1663 // set program name
1664 if (pEntry->AppName[0])
1665 SetDlgItemTextW(hwndDlg, IDC_FILETYPES_APPNAME, pEntry->AppName);
1666 else
1667 SetDlgItemTextW(hwndDlg, IDC_FILETYPES_APPNAME, L"ReactOS");
1668
1669 // Enable the Delete button
1670 if (pEntry->EditFlags & 0x00000010) // FTA_NoRemove
1672 else
1674}
Definition: bufpool.h:45
static HBITMAP BitmapFromIcon(HICON hIcon)
Definition: kbswitch.c:300
static HBITMAP
Definition: button.c:44
HICON hIconSm
Definition: msconfig.c:44
#define IDC_FILETYPES_DESCRIPTION
Definition: shresdef.h:447
#define IDS_FILE_DETAILS
Definition: shresdef.h:188
#define IDC_FILETYPES_DETAILS_GROUPBOX
Definition: shresdef.h:444
#define IDC_FILETYPES_ICON
Definition: shresdef.h:449
#define IDC_FILETYPES_APPNAME
Definition: shresdef.h:445
#define IDC_FILETYPES_DELETE
Definition: shresdef.h:443
#define IDS_FILE_DETAILSADV
Definition: shresdef.h:189
#define IMAGE_BITMAP
Definition: winuser.h:211
#define STM_SETIMAGE
Definition: winuser.h:2093

Referenced by FolderOptionsFileTypesDlg().

◆ FileTypesDlg_RemoveExt()

static BOOL FileTypesDlg_RemoveExt ( HWND  hwndDlg)
static

Definition at line 794 of file filetypes.cpp.

795{
796 HWND hListView = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
797
798 INT iItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
799 if (iItem == -1)
800 return FALSE;
801
802 WCHAR szExt[20];
803 szExt[0] = L'.';
804 ListView_GetItemText(hListView, iItem, 0, &szExt[1], _countof(szExt) - 1);
805 _wcslwr(szExt);
806
807 DeleteExt(hwndDlg, szExt);
808 ListView_DeleteItem(hListView, iItem);
809 return TRUE;
810}
static BOOL DeleteExt(HWND hwndDlg, LPCWSTR pszExt)
Definition: filetypes.cpp:48
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2684
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2411

Referenced by FileTypesDlg_OnDelete().

◆ FolderOptionsFileTypesDlg()

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

Definition at line 1678 of file filetypes.cpp.

1683{
1684 LPNMLISTVIEW lppl;
1687 NEWEXT_DIALOG newext;
1688 EDITTYPE_DIALOG edittype;
1689
1690 switch (uMsg)
1691 {
1692 case WM_INITDIALOG:
1693 pEntry = FileTypesDlg_DoList(hwndDlg);
1694
1695 // Disable the Delete button if the listview is empty
1696 // the selected item should not be deleted by the user
1697 if (pEntry == NULL || (pEntry->EditFlags & 0x00000010)) // FTA_NoRemove
1699 return TRUE;
1700
1701 case WM_COMMAND:
1702 switch (LOWORD(wParam))
1703 {
1704 case IDC_FILETYPES_NEW:
1705 newext.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1707 hwndDlg, NewExtDlgProc, (LPARAM)&newext))
1708 {
1709 FileTypesDlg_AddExt(hwndDlg, newext.szExt, newext.szFileType);
1710 }
1711 break;
1712
1714 FileTypesDlg_OnDelete(hwndDlg);
1715 break;
1716
1719 if (pEntry)
1720 {
1721 ZeroMemory(&Info, sizeof(Info));
1723 Info.pcszFile = pEntry->FileExtension;
1724 Info.pcszClass = NULL;
1725 SHOpenWithDialog(hwndDlg, &Info);
1726 }
1727 break;
1728
1730 edittype.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1731 edittype.pEntry = FileTypesDlg_GetEntry(edittype.hwndLV);
1732 if (edittype.pEntry)
1733 {
1735 hwndDlg, EditTypeDlgProc, (LPARAM)&edittype);
1736 }
1737 break;
1738 }
1739 break;
1740
1741 case WM_NOTIFY:
1742 lppl = (LPNMLISTVIEW) lParam;
1743 switch (lppl->hdr.code)
1744 {
1745 case LVN_KEYDOWN:
1746 {
1747 LV_KEYDOWN *pKeyDown = (LV_KEYDOWN *)lParam;
1748 if (pKeyDown->wVKey == VK_DELETE)
1749 {
1750 FileTypesDlg_OnDelete(hwndDlg);
1751 }
1752 break;
1753 }
1754
1755 case NM_DBLCLK:
1756 edittype.hwndLV = GetDlgItem(hwndDlg, IDC_FILETYPES_LISTVIEW);
1757 edittype.pEntry = FileTypesDlg_GetEntry(edittype.hwndLV);
1758 if (edittype.pEntry)
1759 {
1761 hwndDlg, EditTypeDlgProc, (LPARAM)&edittype);
1762 }
1763 break;
1764
1765 case LVN_DELETEALLITEMS:
1766 return FALSE; // send LVN_DELETEITEM
1767
1768 case LVN_DELETEITEM:
1770 if (pEntry)
1771 {
1772 DestroyIcon(pEntry->hIconLarge);
1773 DestroyIcon(pEntry->hIconSmall);
1775 }
1776 return FALSE;
1777
1778 case LVN_ITEMCHANGING:
1780 if (!pEntry)
1781 {
1782 return TRUE;
1783 }
1784
1785 if (!(lppl->uOldState & LVIS_FOCUSED) && (lppl->uNewState & LVIS_FOCUSED))
1786 {
1788 }
1789 break;
1790
1791 case PSN_SETACTIVE:
1792 // On page activation, set the focus to the listview
1794 break;
1795 }
1796 break;
1797 }
1798
1799 return FALSE;
1800}
HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
static void FileTypesDlg_OnItemChanging(HWND hwndDlg, PFILE_TYPE_ENTRY pEntry)
Definition: filetypes.cpp:1632
static void FileTypesDlg_OnDelete(HWND hwndDlg)
Definition: filetypes.cpp:1615
static INT_PTR CALLBACK NewExtDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:528
static INT_PTR CALLBACK EditTypeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1438
static PFILE_TYPE_ENTRY FileTypesDlg_GetEntry(HWND hListView, INT iItem=-1)
Definition: filetypes.cpp:1598
static PFILE_TYPE_ENTRY FileTypesDlg_DoList(HWND hwndDlg)
Definition: filetypes.cpp:1534
static BOOL FileTypesDlg_AddExt(HWND hwndDlg, LPCWSTR pszExt, LPCWSTR pszFileType)
Definition: filetypes.cpp:715
#define PSN_SETACTIVE
Definition: prsht.h:115
#define NM_DBLCLK
Definition: commctrl.h:131
#define LVN_DELETEALLITEMS
Definition: commctrl.h:3134
#define LVN_ITEMCHANGING
Definition: commctrl.h:3130
struct tagNMLISTVIEW * LPNMLISTVIEW
#define LVN_KEYDOWN
Definition: commctrl.h:3184
#define LV_KEYDOWN
Definition: commctrl.h:3186
#define LVN_DELETEITEM
Definition: commctrl.h:3133
#define WM_NOTIFY
Definition: richedit.h:61
@ OAIF_REGISTER_EXT
Definition: shlobj.h:2667
@ OAIF_ALLOW_REGISTRATION
Definition: shlobj.h:2666
#define IDD_NEWEXTENSION
Definition: shresdef.h:520
#define IDD_EDITTYPE
Definition: shresdef.h:521
#define IDC_FILETYPES_ADVANCED
Definition: shresdef.h:448
#define IDC_FILETYPES_CHANGE
Definition: shresdef.h:446
#define IDC_FILETYPES_NEW
Definition: shresdef.h:442
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
UINT uNewState
Definition: commctrl.h:3036
UINT uOldState
Definition: commctrl.h:3037
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
#define VK_DELETE
Definition: winuser.h:2233

Referenced by CFolderOptions::AddPages(), and ShowFolderOptionsDialogThreadProc().

◆ GetFileTypeIconsByKey()

static BOOL GetFileTypeIconsByKey ( HKEY  hKey,
PFILE_TYPE_ENTRY  Entry 
)
static

Definition at line 159 of file filetypes.cpp.

160{
161 Entry->hIconLarge = Entry->hIconSmall = NULL;
162
163 // Open the "DefaultIcon" registry key
164 HKEY hDefIconKey;
165 LONG nResult = RegOpenKeyExW(hKey, L"DefaultIcon", 0, KEY_READ, &hDefIconKey);
166 if (nResult != ERROR_SUCCESS)
167 return FALSE;
168
169 // Get the icon location
170 WCHAR szLocation[MAX_PATH + 32] = { 0 };
171 DWORD dwSize = sizeof(szLocation);
172 nResult = RegQueryValueExW(hDefIconKey, NULL, NULL, NULL, LPBYTE(szLocation), &dwSize);
173
174 RegCloseKey(hDefIconKey);
175
176 if (nResult != ERROR_SUCCESS || szLocation[0] == 0)
177 return FALSE;
178
179 return GetFileTypeIconsEx(Entry, szLocation);
180}
static BOOL GetFileTypeIconsEx(PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation)
Definition: filetypes.cpp:130

Referenced by FileTypesDlg_InsertToLV().

◆ GetFileTypeIconsEx()

static BOOL GetFileTypeIconsEx ( PFILE_TYPE_ENTRY  Entry,
LPCWSTR  IconLocation 
)
static

Definition at line 130 of file filetypes.cpp.

131{
132 Entry->hIconLarge = Entry->hIconSmall = NULL;
133
134 if (lstrcmpiW(Entry->FileExtension, L".exe") == 0 ||
135 lstrcmpiW(Entry->FileExtension, L".scr") == 0)
136 {
137 // It's an executable
142 IMAGE_ICON, cx, cy, 0));
143 StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), g_pszShell32);
144 Entry->nIconIndex = -IDI_SHELL_EXE;
145 }
146 else if (lstrcmpW(IconLocation, L"%1") == 0)
147 {
148 return FALSE; // self icon
149 }
150 else
151 {
153 }
154
155 return Entry->hIconLarge && Entry->hIconSmall;
156}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
static void DoFileTypeIconLocation(PFILE_TYPE_ENTRY Entry, LPCWSTR IconLocation)
Definition: filetypes.cpp:116
LPCWSTR g_pszShell32
#define IDI_SHELL_EXE
Definition: shresdef.h:553
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2106

Referenced by GetFileTypeIconsByKey().

◆ NewActionDlg_OnOK()

static void NewActionDlg_OnOK ( HWND  hwndDlg,
PACTION_DIALOG  pNewAct 
)
static

Definition at line 864 of file filetypes.cpp.

865{
866 // check action
867 GetDlgItemTextW(hwndDlg, IDC_ACTION_ACTION, pNewAct->szAction, _countof(pNewAct->szAction));
868 StrTrimW(pNewAct->szAction, g_pszSpace);
869 if (pNewAct->szAction[0] == 0)
870 {
871 // action was empty, error
872 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_ACTION);
873 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
874 SetFocus(hwndCtrl);
877 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
878 return;
879 }
880
881 // check app
882 GetDlgItemTextW(hwndDlg, IDC_ACTION_APP, pNewAct->szApp, _countof(pNewAct->szApp));
883 StrTrimW(pNewAct->szApp, g_pszSpace);
884 if (pNewAct->szApp[0] == 0 ||
886 {
887 // app was empty or invalid
888 HWND hwndCtrl = GetDlgItem(hwndDlg, IDC_ACTION_APP);
889 SendMessageW(hwndCtrl, EM_SETSEL, 0, -1);
890 SetFocus(hwndCtrl);
893 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
894 return;
895 }
896
897 EndDialog(hwndDlg, IDOK);
898}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by NewActionDlgProc().

◆ NewActionDlgProc()

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

Definition at line 902 of file filetypes.cpp.

903{
904 static PACTION_DIALOG s_pNewAct = NULL;
905
906 switch (uMsg)
907 {
908 case WM_INITDIALOG:
909 s_pNewAct = (PACTION_DIALOG)lParam;
910 s_pNewAct->bUseDDE = FALSE;
912 return TRUE;
913
914 case WM_COMMAND:
915 switch (LOWORD(wParam))
916 {
917 case IDOK:
918 NewActionDlg_OnOK(hwndDlg, s_pNewAct);
919 break;
920
921 case IDCANCEL:
922 EndDialog(hwndDlg, IDCANCEL);
923 break;
924
926 ActionDlg_OnBrowse(hwndDlg, s_pNewAct, FALSE);
927 break;
928 }
929 break;
930 }
931 return 0;
932}
static void NewActionDlg_OnOK(HWND hwndDlg, PACTION_DIALOG pNewAct)
Definition: filetypes.cpp:864

Referenced by EditTypeDlg_OnCommand().

◆ NewExtDlg_OnAdvanced()

static VOID NewExtDlg_OnAdvanced ( HWND  hwndDlg,
PNEWEXT_DIALOG  pNewExt 
)
static

Definition at line 356 of file filetypes.cpp.

357{
358 // If "Advanced" button was clicked, then we shrink or expand the dialog.
359 RECT rc, rc1, rc2;
360
361 GetWindowRect(hwndDlg, &rc);
362 rc.bottom = rc.top + (pNewExt->rcDlg.bottom - pNewExt->rcDlg.top);
363
364 GetWindowRect(GetDlgItem(hwndDlg, IDOK), &rc1);
365 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc1, 2);
366
368 MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc2, 2);
369
370 if (pNewExt->bAdvanced)
371 {
372 rc1.top += pNewExt->dy;
373 rc1.bottom += pNewExt->dy;
374
375 rc2.top += pNewExt->dy;
376 rc2.bottom += pNewExt->dy;
377
380
382 SetDlgItemTextW(hwndDlg, IDC_NEWEXT_ADVANCED, strLeft);
383
385 }
386 else
387 {
388 rc1.top -= pNewExt->dy;
389 rc1.bottom -= pNewExt->dy;
390
391 rc2.top -= pNewExt->dy;
392 rc2.bottom -= pNewExt->dy;
393
396
398 SetDlgItemTextW(hwndDlg, IDC_NEWEXT_ADVANCED, strRight);
399
400 rc.bottom -= pNewExt->dy;
401
403 SetDlgItemTextW(hwndDlg, IDC_NEWEXT_COMBOBOX, strText);
404 }
405
406 HDWP hDWP = BeginDeferWindowPos(3);
407
408 if (hDWP)
409 hDWP = DeferWindowPos(hDWP, GetDlgItem(hwndDlg, IDOK), NULL,
410 rc1.left, rc1.top, rc1.right - rc1.left, rc1.bottom - rc1.top,
412 if (hDWP)
413 hDWP = DeferWindowPos(hDWP, GetDlgItem(hwndDlg, IDCANCEL), NULL,
414 rc2.left, rc2.top, rc2.right - rc2.left, rc2.bottom - rc2.top,
416 if (hDWP)
417 hDWP = DeferWindowPos(hDWP, hwndDlg, NULL,
418 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
420
421 if (hDWP)
422 EndDeferWindowPos(hDWP);
423}
static const WCHAR rc2[]
Definition: oid.c:1216
#define IDC_NEWEXT_ADVANCED
Definition: shresdef.h:453
#define IDC_NEWEXT_COMBOBOX
Definition: shresdef.h:454
#define IDS_NEWEXT_ADVANCED_RIGHT
Definition: shresdef.h:323
#define IDS_NEWEXT_ADVANCED_LEFT
Definition: shresdef.h:322
#define IDS_NEWEXT_NEW
Definition: shresdef.h:324
#define IDC_NEWEXT_ASSOC
Definition: shresdef.h:455
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
#define SW_HIDE
Definition: winuser.h:768
#define SWP_NOACTIVATE
Definition: winuser.h:1242
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SW_SHOWNOACTIVATE
Definition: winuser.h:774
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOZORDER
Definition: winuser.h:1247
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by NewExtDlg_OnInitDialog(), and NewExtDlgProc().

◆ NewExtDlg_OnInitDialog()

static BOOL NewExtDlg_OnInitDialog ( HWND  hwndDlg,
PNEWEXT_DIALOG  pNewExt 
)
static

Definition at line 426 of file filetypes.cpp.

427{
428 pNewExt->bAdvanced = FALSE;
429
430 // get window rectangle
431 GetWindowRect(hwndDlg, &pNewExt->rcDlg);
432
433 // get delta Y
434 RECT rc1, rc2;
437 pNewExt->dy = rc2.top - rc1.top;
438
439 // initialize
444
445 // shrink it first time
446 NewExtDlg_OnAdvanced(hwndDlg, pNewExt);
447
448 return TRUE;
449}
static VOID NewExtDlg_OnAdvanced(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:356
#define IDC_NEWEXT_EDIT
Definition: shresdef.h:452
WCHAR szExt[16]
Definition: filetypes.cpp:351
#define CB_SETCURSEL
Definition: winuser.h:1961
#define EM_SETLIMITTEXT
Definition: winuser.h:2011
#define CB_ADDSTRING
Definition: winuser.h:1936

Referenced by NewExtDlgProc().

◆ NewExtDlg_OnOK()

static BOOL NewExtDlg_OnOK ( HWND  hwndDlg,
PNEWEXT_DIALOG  pNewExt 
)
static

Definition at line 452 of file filetypes.cpp.

453{
455 INT iItem;
456
457 GetDlgItemTextW(hwndDlg, IDC_NEWEXT_EDIT, pNewExt->szExt, _countof(pNewExt->szExt));
458 StrTrimW(pNewExt->szExt, g_pszSpace);
459 _wcsupr(pNewExt->szExt);
460
462 StrTrimW(pNewExt->szFileType, g_pszSpace);
463
464 if (pNewExt->szExt[0] == 0)
465 {
468 MessageBoxW(hwndDlg, strText, strTitle, MB_ICONERROR);
469 return FALSE;
470 }
471
472 ZeroMemory(&find, sizeof(find));
473 find.flags = LVFI_STRING;
474 if (pNewExt->szExt[0] == L'.')
475 {
476 find.psz = &pNewExt->szExt[1];
477 }
478 else
479 {
480 find.psz = pNewExt->szExt;
481 }
482
483 iItem = ListView_FindItem(pNewExt->hwndLV, -1, &find);
484 if (iItem >= 0)
485 {
486 // already exists
487
488 // get file type
489 WCHAR szFileType[64];
491 ZeroMemory(&item, sizeof(item));
492 item.mask = LVIF_TEXT;
493 item.pszText = szFileType;
494 item.cchTextMax = _countof(szFileType);
495 item.iItem = iItem;
496 item.iSubItem = 1;
497 ListView_GetItem(pNewExt->hwndLV, &item);
498
499 // get text
500 CStringW strText;
501 strText.Format(IDS_NEWEXT_ALREADY_ASSOC, find.psz, szFileType, find.psz, szFileType);
502
503 // get title
504 CStringW strTitle;
506
507 if (MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING | MB_YESNO) == IDNO)
508 {
509 return FALSE;
510 }
511
512 // Delete the extension
513 CStringW strExt(L".");
514 strExt += find.psz;
515 strExt.MakeLower();
516 DeleteExt(hwndDlg, strExt);
517
518 // Delete the item
519 ListView_DeleteItem(pNewExt->hwndLV, iItem);
520 }
521
522 EndDialog(hwndDlg, IDOK);
523 return TRUE;
524}
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:639
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
static TAGID TAGID find
Definition: db.cpp:155
#define LVFI_STRING
Definition: commctrl.h:2437
#define LV_FINDINFO
Definition: commctrl.h:2445
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2470
#define IDS_NEWEXT_SPECIFY_EXT
Definition: shresdef.h:325
#define IDS_NEWEXT_EXT_IN_USE
Definition: shresdef.h:327
#define IDS_NEWEXT_ALREADY_ASSOC
Definition: shresdef.h:326
WCHAR szFileType[64]
Definition: filetypes.cpp:352
#define MB_ICONWARNING
Definition: winuser.h:786

Referenced by NewExtDlgProc().

◆ NewExtDlgProc()

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

Definition at line 528 of file filetypes.cpp.

533{
534 static PNEWEXT_DIALOG s_pNewExt = NULL;
535
536 switch (uMsg)
537 {
538 case WM_INITDIALOG:
539 s_pNewExt = (PNEWEXT_DIALOG)lParam;
540 NewExtDlg_OnInitDialog(hwndDlg, s_pNewExt);
541 return TRUE;
542
543 case WM_COMMAND:
544 switch (LOWORD(wParam))
545 {
546 case IDOK:
547 NewExtDlg_OnOK(hwndDlg, s_pNewExt);
548 break;
549
550 case IDCANCEL:
551 EndDialog(hwndDlg, IDCANCEL);
552 break;
553
555 s_pNewExt->bAdvanced = !s_pNewExt->bAdvanced;
556 NewExtDlg_OnAdvanced(hwndDlg, s_pNewExt);
557 break;
558 }
559 break;
560 }
561 return 0;
562}
static BOOL NewExtDlg_OnInitDialog(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:426
static BOOL NewExtDlg_OnOK(HWND hwndDlg, PNEWEXT_DIALOG pNewExt)
Definition: filetypes.cpp:452
struct NEWEXT_DIALOG * PNEWEXT_DIALOG

Referenced by FolderOptionsFileTypesDlg().

◆ QueryFileDescription()

static BOOL QueryFileDescription ( LPCWSTR  ProgramPath,
LPWSTR  pszName,
INT  cchName 
)
static

Definition at line 183 of file filetypes.cpp.

184{
185 SHFILEINFOW FileInfo = { 0 };
186 if (SHGetFileInfoW(ProgramPath, 0, &FileInfo, sizeof(FileInfo), SHGFI_DISPLAYNAME))
187 {
188 StringCchCopyW(pszName, cchName, FileInfo.szDisplayName);
189 return TRUE;
190 }
191
192 return !!GetFileTitleW(ProgramPath, pszName, cchName);
193}
short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, WORD cbBuf)
Definition: filedlg.c:4856
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:415
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:166
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by FileTypesDlg_InsertToLV().

◆ SetFileTypeEntryDefaultIcon()

static void SetFileTypeEntryDefaultIcon ( PFILE_TYPE_ENTRY  Entry)
static

Definition at line 196 of file filetypes.cpp.

197{
202 IMAGE_ICON, cxSmall, cySmall, 0));
203 StringCbCopyW(Entry->IconPath, sizeof(Entry->IconPath), g_pszShell32);
204 Entry->nIconIndex = -IDI_SHELL_FOLDER_OPTIONS;
205}
#define IDI_SHELL_FOLDER_OPTIONS
Definition: shresdef.h:664

Referenced by EditTypeDlg_UpdateEntryIcon(), and FileTypesDlg_InsertToLV().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( fprop  )