static void on_remove_click(HWND dialog) { int sel = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0); struct dll *dll; if (sel == LB_ERR) return; dll = (struct dll *) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, sel, 0); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_DELETESTRING, sel, 0); SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); set_reg_key(config_key, keypath("DllOverrides"), dll->name, NULL); HeapFree(GetProcessHeap(), 0, dll->name); HeapFree(GetProcessHeap(), 0, dll); if (SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCOUNT, 0, 0) > 0) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETCURSEL, max(sel - 1, 0), 0); else { disable(IDC_DLLS_EDITDLL); disable(IDC_DLLS_REMOVEDLL); } set_controls_from_selection(dialog); }
INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: init_libsheet(hDlg); break; case WM_SHOWWINDOW: set_window_title(hDlg); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_SETACTIVE: load_library_settings(hDlg); break; } break; case WM_COMMAND: switch(HIWORD(wParam)) { case CBN_EDITCHANGE: if (LOWORD(wParam) == IDC_DLLCOMBO) on_add_combo_change(hDlg); break; case CBN_SETFOCUS: if (LOWORD(wParam) == IDC_DLLCOMBO) on_add_combo_change(hDlg); break; case CBN_KILLFOCUS: if (LOWORD(wParam) == IDC_DLLCOMBO) SendMessageW(GetParent(hDlg), DM_SETDEFID, IDOK, 0); break; case BN_CLICKED: switch(LOWORD(wParam)) { case IDC_DLLS_ADDDLL: on_add_click(hDlg); break; case IDC_DLLS_EDITDLL: on_edit_click(hDlg); break; case IDC_DLLS_REMOVEDLL: on_remove_click(hDlg); break; } break; case LBN_SELCHANGE: if(LOWORD(wParam) == IDC_DLLCOMBO) on_add_combo_change(hDlg); else set_controls_from_selection(hDlg); break; } break; } return 0; }
static void on_add_click(HWND dialog) { static const char dotDll[] = ".dll"; char buffer[1024], *ptr; ZeroMemory(buffer, sizeof(buffer)); SendDlgItemMessageA(dialog, IDC_DLLCOMBO, WM_GETTEXT, sizeof(buffer), (LPARAM) buffer); if (lstrlenA(buffer) >= sizeof(dotDll)) { ptr = buffer + lstrlenA(buffer) - sizeof(dotDll) + 1; if (!lstrcmpiA(ptr, dotDll)) { WINE_TRACE("Stripping dll extension\n"); *ptr = '\0'; } } /* check if dll is in the builtin-only list */ if (!(ptr = strrchr( buffer, '\\' ))) { ptr = buffer; if (*ptr == '*') ptr++; } else ptr++; if (is_builtin_only( ptr )) { MSGBOXPARAMSA params; params.cbSize = sizeof(params); params.hwndOwner = dialog; params.hInstance = GetModuleHandleA( NULL ); params.lpszText = MAKEINTRESOURCEA( IDS_DLL_WARNING ); params.lpszCaption = MAKEINTRESOURCEA( IDS_DLL_WARNING_CAPTION ); params.dwStyle = MB_ICONWARNING | MB_YESNO; params.lpszIcon = NULL; params.dwContextHelpId = 0; params.lpfnMsgBoxCallback = NULL; params.dwLanguageId = 0; if (MessageBoxIndirectA( ¶ms ) != IDYES) return; } SendDlgItemMessageW(dialog, IDC_DLLCOMBO, WM_SETTEXT, 0, (LPARAM)emptyW); disable(IDC_DLLS_ADDDLL); SendMessageW(GetParent(dialog), DM_SETDEFID, IDOK, 0); WINE_TRACE("Adding %s as native, builtin\n", buffer); SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); set_reg_key(config_key, keypath("DllOverrides"), buffer, "native,builtin"); load_library_settings(dialog); SendDlgItemMessageA(dialog, IDC_DLLS_LIST, LB_SELECTSTRING, 0, (LPARAM) buffer); set_controls_from_selection(dialog); }
static void load_library_settings(HWND dialog) { char **overrides = enumerate_values(config_key, keypath("DllOverrides")); char **p; int sel, count = 0; sel = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0); WINE_TRACE("sel=%d\n", sel); clear_settings(dialog); if (!overrides || *overrides == NULL) { set_controls_from_selection(dialog); disable(IDC_DLLS_EDITDLL); disable(IDC_DLLS_REMOVEDLL); HeapFree(GetProcessHeap(), 0, overrides); return; } enable(IDC_DLLS_EDITDLL); enable(IDC_DLLS_REMOVEDLL); for (p = overrides; *p != NULL; p++) { int index; char *str, *value; const char *label; struct dll *dll; value = get_reg_key(config_key, keypath("DllOverrides"), *p, NULL); label = mode_to_label(string_to_mode(value)); str = HeapAlloc(GetProcessHeap(), 0, strlen(*p) + 2 + strlen(label) + 2); strcpy(str, *p); strcat(str, " ("); strcat(str, label); strcat(str, ")"); dll = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dll)); dll->name = *p; dll->mode = string_to_mode(value); index = SendDlgItemMessageA(dialog, IDC_DLLS_LIST, LB_ADDSTRING, (WPARAM) -1, (LPARAM) str); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETITEMDATA, index, (LPARAM) dll); HeapFree(GetProcessHeap(), 0, str); count++; } HeapFree(GetProcessHeap(), 0, overrides); /* restore the previous selection, if possible */ if (sel >= count - 1) sel = count - 1; else if (sel == -1) sel = 0; SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETCURSEL, sel, 0); set_controls_from_selection(dialog); }
INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: init_libsheet(hDlg); break; case WM_SHOWWINDOW: set_window_title(hDlg); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_SETACTIVE: load_library_settings(hDlg); break; } break; case WM_COMMAND: switch(HIWORD(wParam)) { case CBN_EDITCHANGE: if (LOWORD(wParam) == IDC_DLLCOMBO) on_add_combo_change(hDlg); break; case CBN_SETFOCUS: if (LOWORD(wParam) == IDC_DLLCOMBO) on_add_combo_change(hDlg); break; case CBN_KILLFOCUS: if (LOWORD(wParam) == IDC_DLLCOMBO) SendMessageW(GetParent(hDlg), DM_SETDEFID, IDOK, 0); break; case BN_CLICKED: switch(LOWORD(wParam)) { case IDC_DLLS_ADDDLL: on_add_click(hDlg); break; case IDC_DLLS_EDITDLL: on_edit_click(hDlg); break; case IDC_DLLS_REMOVEDLL: on_remove_click(hDlg); break; } break; case LBN_SELCHANGE: if(LOWORD(wParam) == IDC_DLLCOMBO) on_add_combo_change(hDlg); else set_controls_from_selection(hDlg); break; case CBN_DBLCLK: if (LOWORD(wParam) == IDC_DLLS_LIST) { int index; POINT p; if (GetCursorPos(&p) && ScreenToClient((HWND)lParam, &p)) { index = SendDlgItemMessageW(hDlg, IDC_DLLS_LIST, LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y)); if (!HIWORD(index)) on_edit_click(hDlg); } } break; } break; } return 0; }