Mike Hearn <mike@theoretic.com> Move Applications tab before Libraries tab Add convenience makefile dependencies Improve return_if_fail Partly implement appdefaults UI Replace usage of EnableWindow with clearer enable/disable macros diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/drive.c programs/winecfg/drive.c --- ../head/programs/winecfg/drive.c 2003-09-19 13:32:52.000000000 +0100 +++ programs/winecfg/drive.c 2003-09-29 16:36:24.000000000 +0100 @@ -285,52 +285,52 @@ #define BOX_MODE_CD_AUTODETECT 2 #define BOX_MODE_NONE 3 #define BOX_MODE_NORMAL 4 -void enable_labelserial_box(HWND hDlg, int mode) +void enable_labelserial_box(HWND dialog, int mode) { WINE_TRACE("mode=%d\n", mode); switch (mode) { case BOX_MODE_CD_ASSIGN: - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_AUTODETECT ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_ASSIGN ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_DEVICE ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_BUTTON_BROWSE_DEVICE ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_SERIAL ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_LABEL ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_SERIAL ), 1); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_LABEL ), 1); + enable(IDC_RADIO_AUTODETECT); + enable(IDC_RADIO_ASSIGN); + disable(IDC_EDIT_DEVICE); + disable(IDC_BUTTON_BROWSE_DEVICE); + enable(IDC_EDIT_SERIAL); + enable(IDC_EDIT_LABEL); + enable(IDC_STATIC_SERIAL); + enable(IDC_STATIC_LABEL); break; case BOX_MODE_CD_AUTODETECT: - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_AUTODETECT ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_ASSIGN ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_DEVICE ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_BUTTON_BROWSE_DEVICE ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_SERIAL ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_LABEL ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_SERIAL ), 0); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_LABEL ), 0); + enable(IDC_RADIO_AUTODETECT); + enable(IDC_RADIO_ASSIGN); + enable(IDC_EDIT_DEVICE); + enable(IDC_BUTTON_BROWSE_DEVICE); + disable(IDC_EDIT_SERIAL); + disable(IDC_EDIT_LABEL); + disable(IDC_STATIC_SERIAL); + disable(IDC_STATIC_LABEL); break; case BOX_MODE_NONE: - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_AUTODETECT ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_ASSIGN ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_DEVICE ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_BUTTON_BROWSE_DEVICE ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_SERIAL ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_LABEL ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_SERIAL ), 0); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_LABEL ), 0); + disable(IDC_RADIO_AUTODETECT); + disable(IDC_RADIO_ASSIGN); + disable(IDC_EDIT_DEVICE); + disable(IDC_BUTTON_BROWSE_DEVICE); + disable(IDC_EDIT_SERIAL); + disable(IDC_EDIT_LABEL); + disable(IDC_STATIC_SERIAL); + disable(IDC_STATIC_LABEL); break; case BOX_MODE_NORMAL: - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_AUTODETECT ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_RADIO_ASSIGN ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_DEVICE ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_BUTTON_BROWSE_DEVICE ), 0 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_SERIAL ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_EDIT_LABEL ), 1 ); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_SERIAL ), 1); - EnableWindow( GetDlgItem( hDlg, IDC_STATIC_LABEL ), 1); + disable(IDC_RADIO_AUTODETECT); + enable(IDC_RADIO_ASSIGN); + disable(IDC_EDIT_DEVICE); + disable(IDC_BUTTON_BROWSE_DEVICE); + enable(IDC_EDIT_SERIAL); + enable(IDC_EDIT_LABEL); + enable(IDC_STATIC_SERIAL); + enable(IDC_STATIC_LABEL); break; } } diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/En.rc programs/winecfg/En.rc --- ../head/programs/winecfg/En.rc 2003-09-25 12:04:48.000000000 +0100 +++ programs/winecfg/En.rc 2003-09-29 14:19:29.000000000 +0100 @@ -51,11 +51,23 @@ STYLE WS_CHILD | WS_DISABLED FONT 8, "MS Sans Serif" BEGIN - CONTROL "List2",IDC_LIST_APPS,"SysListView32",LVS_LIST | +/* CONTROL "List2",IDC_LIST_APPS,"SysListView32",LVS_LIST | LVS_NOLABELWRAP | WS_BORDER | WS_TABSTOP,16,39,226,108 - GROUPBOX "Application Specific Setting",IDC_STATIC,8,4,244,151 - LTEXT "These settings allow you to overwrite Wine default settings (as specified in other configuration tabs) on a per-application basis.", - IDC_STATIC,15,17,228,20 + */ + CONTROL "Configuring global settings",IDC_EDITING_GLOBAL, + "Button",BS_AUTORADIOBUTTON,8,8,244,10 + CONTROL "Configuring application specific setttings",IDC_EDITING_APP, + "Button",BS_AUTORADIOBUTTON,8,18,244,10 + + + LTEXT "Here you can override the default settings on a per-application basis:", + IDC_STATIC,8,35,244,20 + + LISTBOX IDC_LIST_APPS,8,48,244,108,WS_TABSTOP | WS_VSCROLL + + PUSHBUTTON "Add new application...",IDC_ADD_APPDEFAULT,170,155,82,14 + PUSHBUTTON "Remove",IDC_REMOVE_APPDEFAULT,130,155,37,14 + END IDD_X11DRVCFG DIALOG DISCARDABLE 0, 0, 260, 250 @@ -65,9 +77,9 @@ LTEXT "Screen color depth: ",IDC_STATIC,8,10,60,30 COMBOBOX IDC_SCREEN_DEPTH,70,8,180,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Can DirectX programs prevent the mouse leaving their window?",IDC_DX_MOUSE_GRAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,35,242,8 - CONTROL "Enable desktop double buffering",IDC_DOUBLE_BUFFER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,45,242,8 - CONTROL "UseTakeFocus (FIXME)",IDC_USE_TAKE_FOCUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,55,242,8 + CONTROL "Can DirectX programs prevent the mouse leaving their window?",IDC_DX_MOUSE_GRAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,35,230,8 + CONTROL "Enable desktop double buffering",IDC_DOUBLE_BUFFER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,45,230,8 + CONTROL "UseTakeFocus (FIXME)",IDC_USE_TAKE_FOCUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,55,230,8 GROUPBOX " Window settings ",IDC_STATIC,8,25,244,120 diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/main.c programs/winecfg/main.c --- ../head/programs/winecfg/main.c 2003-09-17 14:34:45.000000000 +0100 +++ programs/winecfg/main.c 2003-09-27 21:51:23.000000000 +0100 @@ -162,20 +162,6 @@ } -INT_PTR CALLBACK -AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_COMMAND: - break; - - default: - break; - } - return FALSE; -} - #define NUM_PROPERTY_PAGES 5 INT_PTR doPropertySheet (HINSTANCE hInstance, HWND hOwner) @@ -197,31 +183,31 @@ psp[0].lParam = 0; /* - * Fill out the (Libraries) PROPSHEETPAGE data structure + * Fill out the (Applications) PROPSHEETPAGE data structure * for the property sheet */ psp[1].dwSize = sizeof (PROPSHEETPAGE); psp[1].dwFlags = PSP_USETITLE; psp[1].hInstance = hInstance; - psp[1].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG); + psp[1].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG); psp[1].u2.pszIcon = NULL; - psp[1].pfnDlgProc = DllDlgProc; - psp[1].pszTitle = "Libraries"; + psp[1].pfnDlgProc = AppDlgProc; + psp[1].pszTitle = "Applications"; psp[1].lParam = 0; /* - * Fill out the (Applications) PROPSHEETPAGE data structure + * Fill out the (Libraries) PROPSHEETPAGE data structure * for the property sheet */ psp[2].dwSize = sizeof (PROPSHEETPAGE); psp[2].dwFlags = PSP_USETITLE; psp[2].hInstance = hInstance; - psp[2].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG); + psp[2].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG); psp[2].u2.pszIcon = NULL; - psp[2].pfnDlgProc = AppDlgProc; - psp[2].pszTitle = "Applications"; + psp[2].pfnDlgProc = DllDlgProc; + psp[2].pszTitle = "Libraries"; psp[2].lParam = 0; - + /* * Fill out the (X11Drv) PROPSHEETPAGE data structure * for the property sheet @@ -256,6 +242,7 @@ psh.nPages = NUM_PROPERTY_PAGES; psh.u3.ppsp = (LPCPROPSHEETPAGE) & psp; psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback; + psh.u2.nStartPage = 0; /* * Display the modal property sheet @@ -293,8 +280,9 @@ InitCommonControls (); if (doPropertySheet (hInstance, NULL) > 0) { WINE_TRACE("OK\n"); - } else + } else { WINE_TRACE("Cancel\n"); + } ExitProcess (0); diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/Makefile.in programs/winecfg/Makefile.in --- ../head/programs/winecfg/Makefile.in 2003-08-30 01:49:00.000000000 +0100 +++ programs/winecfg/Makefile.in 2003-09-29 14:24:40.000000000 +0100 @@ -11,10 +11,14 @@ main.c \ properties.c \ winecfg.c \ - x11drvdlg.c + x11drvdlg.c \ + appdefaults.c RC_SRCS = winecfg.rc @MAKE_PROG_RULES@ ### Dependencies: +winecfg.res: En.rc + +winecfg.o: winecfg.h \ No newline at end of file diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/resource.h programs/winecfg/resource.h --- ../head/programs/winecfg/resource.h 2003-09-25 12:04:52.000000000 +0100 +++ programs/winecfg/resource.h 2003-09-29 14:18:50.000000000 +0100 @@ -45,7 +45,6 @@ #define IDC_SYSCOLORS 1017 #define IDC_PRIVATEMAP 1018 #define IDC_PERFECTGRAPH 1019 -#define IDC_LIST_APPS 1021 #define IDC_MANAGED 1022 #define IDC_DESKTOP_WIDTH 1023 #define IDC_DESKTOP_HEIGHT 1024 @@ -67,6 +66,8 @@ #define IDC_EDIT_REAL 1039 #define IDC_BUTTON_REAL 1040 #define IDC_BUTTON_FOLDERS 1041 + +/* drive editing */ #define IDC_LIST_DRIVES 1042 #define IDC_BUTTON_ADD 1043 #define IDC_BUTTON_REMOVE 1044 @@ -102,8 +103,17 @@ #define IDC_STATIC_LABEL 1073 #define IDC_ENABLE_DESKTOP 1074 #define IDS_DRIVE_NO_C 1075 + +/* x11drv */ #define IDC_ENABLE_MANAGED 1076 #define IDC_SCREEN_DEPTH 1077 #define IDC_DX_MOUSE_GRAB 1078 #define IDC_USE_TAKE_FOCUS 1079 #define IDC_DOUBLE_BUFFER 1080 + +/* applications tab */ +#define IDC_LIST_APPS 1021 +#define IDC_EDITING_GLOBAL 1081 +#define IDC_EDITING_APP 1082 +#define IDC_ADD_APPDEFAULT 1083 +#define IDC_REMOVE_APPDEFAULT 1084 diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.c programs/winecfg/winecfg.c --- ../head/programs/winecfg/winecfg.c 2003-09-25 12:00:59.000000000 +0100 +++ programs/winecfg/winecfg.c 2003-09-29 16:35:28.000000000 +0100 @@ -22,7 +22,6 @@ * TODO: (in rough order of priority) * - A mind bogglingly vast amount of stuff * - * - Complete X11DRV page, so all controls are hooked up * - Implement autodetect for drive configuration * - Figure out whether we need the virtual vs real drive selection stuff at the top of the property page * - Implement explicit mode vs instant-apply mode @@ -36,6 +35,10 @@ * Minor things that should be done someday: * - Make the desktop size UI a combo box, with a Custom option, so it's more obvious what you might want to choose here * + * BUGS: + * - WineLook default fallback doesn't work + * - x11drv page triggers key writes on entry + * */ #include <assert.h> @@ -94,7 +97,7 @@ } goto end; } - + res = RegQueryValueExA( hSubKey, valueName, NULL, NULL, NULL, &dataLength); if( res == ERROR_FILE_NOT_FOUND ) { WINE_TRACE("Value not present - using default\n"); diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.h programs/winecfg/winecfg.h --- ../head/programs/winecfg/winecfg.h 2003-09-19 13:32:55.000000000 +0100 +++ programs/winecfg/winecfg.h 2003-09-29 14:41:23.000000000 +0100 @@ -37,10 +37,10 @@ #define IS_OPTION_FALSE(ch) \ ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0') -#define return_if_fail(try, ret) \ +#define return_if_fail(try) \ if (!(try)) { \ - WINE_ERR("assertion (##try) failed, returning\n"); \ - return ret; \ + WINE_ERR("check (" #try ") at %s:%d failed, returning\n", __FILE__, __LINE__ - 1); \ + return; \ } #define WRITEME(owner) MessageBox(owner, "Write me!", "", MB_OK | MB_ICONEXCLAMATION); @@ -63,6 +63,13 @@ extern int instantApply; /* non-zero means apply all changes instantly */ +#define EDITING_GLOBAL 0 +#define EDITING_APP 1 +extern int appSettings; /* non-zero means we are editing appdefault settings */ + +/* returns a string of the form AppDefaults\\appname.exe\\section */ +/* no explicit free is needed of the string returned by this function */ +char *getSectionForApp(char *section); /* Commits a transaction to the registry */ void processTransaction(struct transaction *trans); @@ -101,10 +108,14 @@ INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); /* some basic utilities to make win32 suck less */ char *getDialogItemText(HWND hDlg, WORD controlID); +#define disable(id) EnableWindow(GetDlgItem(dialog, id), 0); +#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1); -#define WINE_KEY_ROOT "Software\\Wine\\WineCfg\\Config" + +#define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config" #endif diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/x11drvdlg.c programs/winecfg/x11drvdlg.c --- ../head/programs/winecfg/x11drvdlg.c 2003-09-25 12:03:20.000000000 +0100 +++ programs/winecfg/x11drvdlg.c 2003-09-29 16:32:06.000000000 +0100 @@ -35,35 +35,37 @@ WINE_DEFAULT_DEBUG_CHANNEL(winecfg); #define RES_MAXLEN 5 /* the maximum number of characters in a screen dimension. 5 digits should be plenty, what kind of crazy person runs their screen >10,000 pixels across? */ +#define section (appSettings == EDITING_GLOBAL ? "x11drv" : (getSectionForApp("x11drv"))) int updatingUI; -void updateGUIForDesktopMode(HWND hDlg) { +void updateGUIForDesktopMode(HWND dialog) { WINE_TRACE("\n"); updatingUI = TRUE; /* do we have desktop mode enabled? */ if (doesConfigValueExist("x11drv", "Desktop") == S_OK) { - CheckDlgButton(hDlg, IDC_ENABLE_DESKTOP, BST_CHECKED); + CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED); /* enable the controls */ - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), 1); - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), 1); - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_SIZE), 1); - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_BY), 1); - SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), "640"); - SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), "480"); + enable(IDC_DESKTOP_WIDTH); + enable(IDC_DESKTOP_HEIGHT); + enable(IDC_DESKTOP_SIZE); + enable(IDC_DESKTOP_BY); + + SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "640"); + SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "480"); } else { - CheckDlgButton(hDlg, IDC_ENABLE_DESKTOP, BST_UNCHECKED); + CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_UNCHECKED); /* disable the controls */ - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), 0); - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), 0); - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_SIZE), 0); - EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_BY), 0); + disable(IDC_DESKTOP_WIDTH); + disable(IDC_DESKTOP_HEIGHT); + disable(IDC_DESKTOP_SIZE); + disable(IDC_DESKTOP_BY); - SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), ""); - SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), ""); + SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), ""); + SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), ""); } updatingUI = FALSE; --- /dev/null 2003-01-30 10:24:37.000000000 +0000 +++ programs/winecfg/appdefaults.c 2003-09-29 16:29:13.000000000 +0100 @@ -0,0 +1,147 @@ +/* + * Application defaults page + * + * Copyright 2003 Mike Hearn + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <stdio.h> + +#include "winecfg.h" +#include <windef.h> +#include <winbase.h> +#include <winreg.h> +#include <wine/debug.h> + +#include "resource.h" + +WINE_DEFAULT_DEBUG_CHANNEL(winecfg); + +int appSettings = EDITING_GLOBAL; /* start by editing global */ +char *currentApp; /* the app we are currently editing, or NULL if editing global */ + +char *getSectionForApp(char *section) { + static char *lastResult = NULL; + if (lastResult) HeapFree(GetProcessHeap(), 0, lastResult); + lastResult = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\\") + strlen(currentApp) + 2 /* \\ */ + strlen(section) + 1 /* terminator */); + sprintf(lastResult, "AppDefaults\\%s\\%s", currentApp, section); + return lastResult; +} + +static void configureFor(HWND dialog, int mode) { + CheckRadioButton(dialog, IDC_EDITING_GLOBAL, IDC_EDITING_APP, mode == EDITING_APP ? IDC_EDITING_APP : IDC_EDITING_GLOBAL); + if (mode == EDITING_GLOBAL) { + disable(IDC_LIST_APPS); + disable(IDC_ADD_APPDEFAULT); + disable(IDC_REMOVE_APPDEFAULT); + if (currentApp) HeapFree(GetProcessHeap(), 0, currentApp); + } else { + enable(IDC_LIST_APPS); + enable(IDC_ADD_APPDEFAULT); + enable(IDC_REMOVE_APPDEFAULT); + } + appSettings = mode; +} + +/* fill the dialog with the current appdefault entries */ +static void refreshDialog(HWND dialog) { + HKEY key; + char *subKeyName = HeapAlloc(GetProcessHeap(), 0, MAX_NAME_LENGTH); + DWORD sizeOfSubKeyName = MAX_NAME_LENGTH; + int i, itemIndex; + + WINE_TRACE("\n"); + + /* Clear the listbox */ + SendMessageA(GetDlgItem(dialog, IDC_LIST_APPS), LB_RESETCONTENT, 0, 0); + + return_if_fail( + RegCreateKey(HKEY_LOCAL_MACHINE, WINE_KEY_ROOT "\\AppDefaults", &key) == ERROR_SUCCESS + ); + + /* Iterate over each subkey in the AppDefaults tree */ + for (i = 0; + RegEnumKeyEx(key, i, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS; + ++i, sizeOfSubKeyName = MAX_NAME_LENGTH) { + + WINE_TRACE("appdefault entry=%s\n", subKeyName); + itemIndex = SendMessageA(GetDlgItem(dialog, IDC_LIST_APPS), LB_ADDSTRING ,(WPARAM) -1, (LPARAM) subKeyName); + } + + configureFor(dialog, appSettings); + + WINE_TRACE("done\n"); + RegCloseKey(key); + HeapFree(GetProcessHeap(), 0, subKeyName); +} + +static void onAppsListSelChange(HWND dialog) { + int newPos = SendDlgItemMessage(dialog, IDC_LIST_APPS, LB_GETCURSEL, 0, 0); + int appLen = SendDlgItemMessage(dialog, IDC_LIST_APPS, LB_GETTEXTLEN, newPos, 0); + if (currentApp) HeapFree(GetProcessHeap(), 0, currentApp); + currentApp = HeapAlloc(GetProcessHeap(), 0, appLen+1); + return_if_fail( + SendDlgItemMessage(dialog, IDC_LIST_APPS, LB_GETTEXT, newPos, (LPARAM) currentApp) != LB_ERR + ); + WINE_TRACE("new selection is %s\n", currentApp); +} + +INT_PTR CALLBACK +AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_COMMAND: switch (LOWORD(wParam)) { + case IDC_EDITING_APP: + configureFor(hDlg, EDITING_APP); + break; + case IDC_EDITING_GLOBAL: + configureFor(hDlg, EDITING_GLOBAL); + break; + case IDC_ADD_APPDEFAULT: + WRITEME(hDlg); + break; + case IDC_REMOVE_APPDEFAULT: + WRITEME(hDlg); + break; + case IDC_LIST_APPS: + if (HIWORD(wParam) == LBN_SELCHANGE) onAppsListSelChange(hDlg); + break; + } + break; + + case WM_NOTIFY: switch(((LPNMHDR)lParam)->code) { + case PSN_KILLACTIVE: + SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); + break; + case PSN_APPLY: + SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); + break; + case PSN_SETACTIVE: + refreshDialog(hDlg); + break; + + }; + break; + + case WM_INITDIALOG: + WINE_TRACE("Init appdefaults\n"); + break; + + } + return FALSE; +}