oledb32/tests: Remove test_odbc_provider().
[wine.git] / programs / winecfg / driveui.c
blobe21c99a6697dffea355f4086ee4303396427994c
1 /*
2 * Drive management UI code
4 * Copyright 2003 Mark Westcott
5 * Copyright 2004 Chris Morgan
6 * Copyright 2003-2004 Mike Hearn
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <stdio.h>
26 #define WIN32_LEAN_AND_MEAN
27 #define COBJMACROS
29 #include <windows.h>
30 #include <shellapi.h>
31 #include <objbase.h>
32 #include <shlguid.h>
33 #include <shlwapi.h>
34 #include <shlobj.h>
36 #include <wine/debug.h>
38 #include "winecfg.h"
39 #include "resource.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
43 #define BOX_MODE_DEVICE 1
44 #define BOX_MODE_NORMAL 2
46 static BOOL advanced = FALSE;
47 static BOOL updating_ui = FALSE;
48 static struct drive* current_drive;
50 static void update_controls(HWND dialog);
52 static DWORD driveui_msgbox (HWND parent, UINT messageId, DWORD flags)
54 WCHAR* caption = load_string (IDS_WINECFG_TITLE);
55 WCHAR* text = load_string (messageId);
56 DWORD result = MessageBoxW (parent, text, caption, flags);
57 free (caption);
58 free (text);
59 return result;
62 /**** listview helper functions ****/
64 /* clears the item at index in the listview */
65 static void lv_clear_curr_select(HWND dialog, int index)
67 LVITEMW item;
69 item.mask = LVIF_STATE;
70 item.state = 0;
71 item.stateMask = LVIS_SELECTED;
72 SendDlgItemMessageW( dialog, IDC_LIST_DRIVES, LVM_SETITEMSTATE, index, (LPARAM)&item );
75 /* selects the item at index in the listview */
76 static void lv_set_curr_select(HWND dialog, int index)
78 LVITEMW item;
80 /* no more than one item can be selected in our listview */
81 lv_clear_curr_select(dialog, -1);
82 item.mask = LVIF_STATE;
83 item.state = LVIS_SELECTED;
84 item.stateMask = LVIS_SELECTED;
85 SendDlgItemMessageW( dialog, IDC_LIST_DRIVES, LVM_SETITEMSTATE, index, (LPARAM)&item );
88 /* returns the currently selected item in the listview */
89 static int lv_get_curr_select(HWND dialog)
91 return SendDlgItemMessageW(dialog, IDC_LIST_DRIVES, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
94 /* sets the item in the listview at item->iIndex */
95 static void lv_set_item(HWND dialog, LVITEMW *item)
97 SendDlgItemMessageW(dialog, IDC_LIST_DRIVES, LVM_SETITEMW, 0, (LPARAM) item);
100 /* sets specified item's text */
101 static void lv_set_item_text(HWND dialog, int item, int subItem, WCHAR *text)
103 LVITEMW lvItem;
104 if (item < 0 || subItem < 0) return;
105 lvItem.mask = LVIF_TEXT;
106 lvItem.iItem = item;
107 lvItem.iSubItem = subItem;
108 lvItem.pszText = text;
109 lvItem.cchTextMax = lstrlenW(lvItem.pszText);
110 lv_set_item(dialog, &lvItem);
113 /* inserts an item into the listview */
114 static void lv_insert_item(HWND dialog, LVITEMW *item)
116 SendDlgItemMessageW(dialog, IDC_LIST_DRIVES, LVM_INSERTITEMW, 0, (LPARAM) item);
119 /* retrieve the item at index item->iIndex */
120 static void lv_get_item(HWND dialog, LVITEMW *item)
122 SendDlgItemMessageW(dialog, IDC_LIST_DRIVES, LVM_GETITEMW, 0, (LPARAM) item);
125 static void set_advanced(HWND dialog)
127 int state;
128 WCHAR text[256];
130 if (advanced)
132 state = SW_NORMAL;
133 LoadStringW(GetModuleHandleW(NULL), IDS_HIDE_ADVANCED, text, 256);
135 else
137 state = SW_HIDE;
138 LoadStringW(GetModuleHandleW(NULL), IDS_SHOW_ADVANCED, text, 256);
141 ShowWindow(GetDlgItem(dialog, IDC_EDIT_DEVICE), state);
142 ShowWindow(GetDlgItem(dialog, IDC_STATIC_DEVICE), state);
143 ShowWindow(GetDlgItem(dialog, IDC_EDIT_LABEL), state);
144 ShowWindow(GetDlgItem(dialog, IDC_STATIC_LABEL), state);
145 ShowWindow(GetDlgItem(dialog, IDC_BUTTON_BROWSE_DEVICE), state);
146 ShowWindow(GetDlgItem(dialog, IDC_EDIT_SERIAL), state);
147 ShowWindow(GetDlgItem(dialog, IDC_STATIC_SERIAL), state);
148 ShowWindow(GetDlgItem(dialog, IDC_COMBO_TYPE), state);
149 ShowWindow(GetDlgItem(dialog, IDC_STATIC_TYPE), state);
151 /* update the button text based on the state */
152 SetWindowTextW(GetDlgItem(dialog, IDC_BUTTON_SHOW_HIDE_ADVANCED), text);
155 struct drive_typemap {
156 unsigned int sCode;
157 UINT idDesc;
160 static const struct drive_typemap type_pairs[] = {
161 { DRIVE_UNKNOWN, IDS_DRIVE_UNKNOWN },
162 { DRIVE_FIXED, IDS_DRIVE_FIXED },
163 { DRIVE_REMOTE, IDS_DRIVE_REMOTE },
164 { DRIVE_REMOVABLE, IDS_DRIVE_REMOVABLE },
165 { DRIVE_CDROM, IDS_DRIVE_CDROM }
168 #define DRIVE_TYPE_DEFAULT 0
170 static void enable_labelserial_box(HWND dialog, int mode)
172 WINE_TRACE("mode=%d\n", mode);
174 switch (mode)
176 case BOX_MODE_DEVICE:
177 /* FIXME: enable device editing */
178 disable(IDC_EDIT_DEVICE);
179 disable(IDC_BUTTON_BROWSE_DEVICE);
180 disable(IDC_EDIT_SERIAL);
181 disable(IDC_EDIT_LABEL);
182 break;
184 case BOX_MODE_NORMAL:
185 disable(IDC_EDIT_DEVICE);
186 disable(IDC_BUTTON_BROWSE_DEVICE);
187 enable(IDC_EDIT_SERIAL);
188 enable(IDC_EDIT_LABEL);
189 break;
193 static int fill_drives_list(HWND dialog)
195 int count = 0;
196 BOOL drivec_present = FALSE;
197 int i;
198 int prevsel = -1;
200 WINE_TRACE("\n");
202 updating_ui = TRUE;
204 prevsel = lv_get_curr_select(dialog);
206 /* Clear the listbox */
207 SendDlgItemMessageW(dialog, IDC_LIST_DRIVES, LVM_DELETEALLITEMS, 0, 0);
209 for(i = 0; i < 26; i++)
211 LVITEMW item;
212 WCHAR *path;
213 char letter[4];
215 /* skip over any unused drives */
216 if (!drives[i].in_use)
217 continue;
219 if (drives[i].letter == 'C')
220 drivec_present = TRUE;
222 letter[0] = 'A' + i;
223 letter[1] = ':';
224 letter[2] = 0;
226 item.mask = LVIF_TEXT | LVIF_PARAM;
227 item.iItem = count;
228 item.iSubItem = 0;
229 item.pszText = strdupU2W(letter);
230 item.cchTextMax = lstrlenW(item.pszText);
231 item.lParam = (LPARAM) &drives[i];
233 lv_insert_item(dialog, &item);
234 free(item.pszText);
236 path = strdupU2W(drives[i].unixpath);
237 lv_set_item_text(dialog, count, 1, path);
238 free(path);
240 count++;
243 WINE_TRACE("loaded %d drives\n", count);
245 /* show the warning if there is no Drive C */
246 if (!drivec_present)
247 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_NORMAL);
248 else
249 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_HIDE);
251 lv_set_curr_select(dialog, prevsel == -1 ? 0 : prevsel);
253 updating_ui = FALSE;
254 return count;
257 static void on_options_click(HWND dialog)
259 if (IsDlgButtonChecked(dialog, IDC_SHOW_DOT_FILES) == BST_CHECKED)
260 set_reg_key(config_key, L"", L"ShowDotFiles", L"Y");
261 else
262 set_reg_key(config_key, L"", L"ShowDotFiles", L"N");
264 SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
267 static INT_PTR CALLBACK drivechoose_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
269 static int i, sel;
270 WCHAR c;
271 WCHAR drive[] = L"X:";
273 switch(uMsg)
275 case WM_INITDIALOG:
277 ULONG mask = ~drive_available_mask(0); /* the mask is now which drives aren't available */
278 for( c = 'A'; c<= 'Z'; c++){
279 drive[0] = c;
280 if(!( mask & (1 << (c - 'A'))))
281 SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_ADDSTRING, 0, (LPARAM) drive);
283 drive[0] = lParam;
284 SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_SELECTSTRING, 0, (LPARAM) drive);
285 return TRUE;
287 case WM_COMMAND:
288 if(HIWORD(wParam) != BN_CLICKED) break;
289 switch (LOWORD(wParam))
291 case IDOK:
292 i = SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_GETCURSEL, 0, 0);
293 if( i != CB_ERR){
294 SendDlgItemMessageW( hwndDlg, IDC_DRIVESA2Z, CB_GETLBTEXT, i, (LPARAM) drive);
295 sel = drive[0];
296 } else
297 sel = -1;
298 EndDialog(hwndDlg, sel);
299 return TRUE;
300 case IDCANCEL:
301 EndDialog(hwndDlg, -1);
302 return TRUE;
305 return FALSE;
308 static void on_add_click(HWND dialog)
310 /* we should allocate a drive letter automatically. We also need
311 some way to let the user choose the mapping point, for now we
312 will just force them to enter a path automatically, with / being
313 the default. In future we should be able to temporarily map /
314 then invoke the directory chooser dialog. */
316 char new = 'C'; /* we skip A and B, they are historically floppy drives */
317 ULONG mask = ~drive_available_mask(0); /* the mask is now which drives aren't available */
318 int i, c;
319 INT_PTR ret;
321 while (mask & (1 << (new - 'A')))
323 new++;
324 if (new > 'Z')
326 driveui_msgbox (dialog, IDS_DRIVE_LETTERS_EXCEEDED, MB_OK | MB_ICONEXCLAMATION);
327 return;
332 ret = DialogBoxParamW(0, MAKEINTRESOURCEW(IDD_DRIVECHOOSE), dialog, drivechoose_dlgproc, new);
334 if( ret == -1) return;
335 new = ret;
337 WINE_TRACE("selected drive letter %c\n", new);
339 if (new == 'C')
341 WCHAR label[64];
342 LoadStringW(GetModuleHandleW(NULL), IDS_SYSTEM_DRIVE_LABEL, label, ARRAY_SIZE(label));
343 add_drive(new, "../drive_c", NULL, label, 0, DRIVE_FIXED);
345 else add_drive(new, "/", NULL, NULL, 0, DRIVE_UNKNOWN);
347 fill_drives_list(dialog);
349 /* select the newly created drive */
350 mask = ~drive_available_mask(0);
351 c = 0;
352 for (i = 0; i < 26; i++)
354 if ('A' + i == new) break;
355 if ((1 << i) & mask) c++;
357 lv_set_curr_select(dialog, c);
359 SetFocus(GetDlgItem(dialog, IDC_LIST_DRIVES));
361 update_controls(dialog);
362 SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
365 static void on_remove_click(HWND dialog)
367 int itemIndex;
368 struct drive *drive;
369 LVITEMW item;
371 itemIndex = lv_get_curr_select(dialog);
372 if (itemIndex == -1) return; /* no selection */
374 item.mask = LVIF_PARAM;
375 item.iItem = itemIndex;
376 item.iSubItem = 0;
378 lv_get_item(dialog, &item);
380 drive = (struct drive *) item.lParam;
382 WINE_TRACE("unixpath: %s\n", drive->unixpath);
384 if (drive->letter == 'C')
386 DWORD result = driveui_msgbox (dialog, IDS_CONFIRM_DELETE_C, MB_YESNO | MB_ICONEXCLAMATION);
387 if (result == IDNO) return;
390 delete_drive(drive);
392 fill_drives_list(dialog);
394 itemIndex = itemIndex - 1;
395 if (itemIndex < 0) itemIndex = 0;
396 lv_set_curr_select(dialog, itemIndex); /* previous item */
398 SetFocus(GetDlgItem(dialog, IDC_LIST_DRIVES));
400 update_controls(dialog);
401 SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
404 static void update_controls(HWND dialog)
406 static const WCHAR emptyW[1];
407 WCHAR *path;
408 unsigned int type;
409 char serial[16];
410 int i, selection = -1;
411 LVITEMW item;
413 updating_ui = TRUE;
415 i = lv_get_curr_select(dialog);
416 if (i == -1)
418 /* no selection? let's select something for the user. this will re-enter */
419 lv_set_curr_select(dialog, i);
420 return;
423 item.mask = LVIF_PARAM;
424 item.iItem = i;
425 item.iSubItem = 0;
427 lv_get_item(dialog, &item);
428 current_drive = (struct drive *) item.lParam;
430 WINE_TRACE("Updating sheet for drive %c\n", current_drive->letter);
432 /* path */
433 WINE_TRACE("set path control text to '%s'\n", current_drive->unixpath);
434 path = strdupU2W(current_drive->unixpath);
435 set_textW(dialog, IDC_EDIT_PATH, path);
436 free(path);
438 /* drive type */
439 type = current_drive->type;
440 SendDlgItemMessageW(dialog, IDC_COMBO_TYPE, CB_RESETCONTENT, 0, 0);
442 for (i = 0; i < ARRAY_SIZE(type_pairs); i++)
444 WCHAR driveDesc[64];
445 LoadStringW(GetModuleHandleW(NULL), type_pairs[i].idDesc, driveDesc, ARRAY_SIZE(driveDesc));
446 SendDlgItemMessageW (dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)driveDesc);
448 if (type_pairs[i].sCode == type)
450 selection = i;
454 if (selection == -1) selection = DRIVE_TYPE_DEFAULT;
455 SendDlgItemMessageW(dialog, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
457 EnableWindow( GetDlgItem( dialog, IDC_BUTTON_REMOVE ), (current_drive->letter != 'C') );
458 EnableWindow( GetDlgItem( dialog, IDC_EDIT_PATH ), (current_drive->letter != 'C') );
459 EnableWindow( GetDlgItem( dialog, IDC_BUTTON_BROWSE_PATH ), (current_drive->letter != 'C') );
460 EnableWindow( GetDlgItem( dialog, IDC_COMBO_TYPE ), (current_drive->letter != 'C') );
462 /* removable media properties */
463 set_textW(dialog, IDC_EDIT_LABEL, current_drive->label ? current_drive->label : emptyW);
465 /* set serial edit text */
466 sprintf( serial, "%lX", current_drive->serial );
467 set_text(dialog, IDC_EDIT_SERIAL, serial);
469 set_text(dialog, IDC_EDIT_DEVICE, current_drive->device);
471 if ((type == DRIVE_CDROM) || (type == DRIVE_REMOVABLE))
472 enable_labelserial_box(dialog, BOX_MODE_DEVICE);
473 else
474 enable_labelserial_box(dialog, BOX_MODE_NORMAL);
476 updating_ui = FALSE;
478 return;
481 static void on_edit_changed(HWND dialog, WORD id)
483 if (updating_ui) return;
485 WINE_TRACE("edit id %d changed\n", id);
487 switch (id)
489 case IDC_EDIT_LABEL:
491 WCHAR *label = get_text(dialog, id);
492 free(current_drive->label);
493 current_drive->label = label;
494 current_drive->modified = TRUE;
496 WINE_TRACE("set label to %s\n", wine_dbgstr_w(current_drive->label));
498 /* enable the apply button */
499 SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
500 break;
503 case IDC_EDIT_PATH:
505 WCHAR *wpath;
506 char *path;
507 int lenW;
509 wpath = get_text(dialog, id);
510 if( (lenW = WideCharToMultiByte(CP_UNIXCP, 0, wpath, -1, NULL, 0, NULL, NULL)) )
512 path = malloc(lenW);
513 WideCharToMultiByte(CP_UNIXCP, 0, wpath, -1, path, lenW, NULL, NULL);
515 else
517 path = NULL;
518 wpath = strdupU2W("drive_c");
521 free(current_drive->unixpath);
522 current_drive->unixpath = path ? path : strdup("drive_c");
523 current_drive->modified = TRUE;
525 WINE_TRACE("set path to %s\n", current_drive->unixpath);
527 lv_set_item_text(dialog, lv_get_curr_select(dialog), 1,
528 wpath);
529 free(wpath);
531 /* enable the apply button */
532 SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
533 break;
536 case IDC_EDIT_SERIAL:
538 WCHAR *serial;
540 serial = get_text(dialog, id);
541 current_drive->serial = serial ? wcstoul( serial, NULL, 16 ) : 0;
542 free(serial);
543 current_drive->modified = TRUE;
545 WINE_TRACE("set serial to %08lX\n", current_drive->serial);
547 /* enable the apply button */
548 SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
549 break;
552 case IDC_EDIT_DEVICE:
554 WCHAR *device = get_text(dialog, id);
555 /* TODO: handle device if/when it makes sense to do so.... */
556 free(device);
557 break;
562 BOOL browse_for_unix_folder(HWND dialog, WCHAR *pszPath)
564 static WCHAR wszUnixRootDisplayName[] = L"::{CC702EB2-7DC5-11D9-C687-0004238A01CD}";
565 WCHAR pszChoosePath[FILENAME_MAX];
566 BROWSEINFOW bi = {
567 dialog,
568 NULL,
569 NULL,
570 pszChoosePath,
572 NULL,
576 IShellFolder *pDesktop;
577 LPITEMIDLIST pidlUnixRoot, pidlSelectedPath;
578 HRESULT hr;
580 LoadStringW(GetModuleHandleW(NULL), IDS_CHOOSE_PATH, pszChoosePath, FILENAME_MAX);
582 hr = SHGetDesktopFolder(&pDesktop);
583 if (FAILED(hr)) return FALSE;
585 hr = IShellFolder_ParseDisplayName(pDesktop, NULL, NULL, wszUnixRootDisplayName, NULL,
586 &pidlUnixRoot, NULL);
587 if (FAILED(hr)) {
588 IShellFolder_Release(pDesktop);
589 return FALSE;
592 bi.pidlRoot = pidlUnixRoot;
593 pidlSelectedPath = SHBrowseForFolderW(&bi);
594 SHFree(pidlUnixRoot);
596 if (pidlSelectedPath) {
597 STRRET strSelectedPath;
598 WCHAR *pszSelectedPath;
599 HRESULT hr;
601 hr = IShellFolder_GetDisplayNameOf(pDesktop, pidlSelectedPath, SHGDN_FORPARSING,
602 &strSelectedPath);
603 IShellFolder_Release(pDesktop);
604 if (FAILED(hr)) {
605 SHFree(pidlSelectedPath);
606 return FALSE;
609 hr = StrRetToStrW(&strSelectedPath, pidlSelectedPath, &pszSelectedPath);
610 SHFree(pidlSelectedPath);
611 if (FAILED(hr)) return FALSE;
613 lstrcpyW(pszPath, pszSelectedPath);
615 CoTaskMemFree(pszSelectedPath);
616 return TRUE;
618 return FALSE;
621 static void init_listview_columns(HWND dialog)
623 LVCOLUMNW listColumn;
624 RECT viewRect;
625 int width;
626 WCHAR column[64];
628 GetClientRect(GetDlgItem(dialog, IDC_LIST_DRIVES), &viewRect);
629 width = (viewRect.right - viewRect.left) / 6 - 5;
631 LoadStringW(GetModuleHandleW(NULL), IDS_COL_DRIVELETTER, column, ARRAY_SIZE(column));
632 listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
633 listColumn.pszText = column;
634 listColumn.cchTextMax = lstrlenW (listColumn.pszText);
635 listColumn.cx = width;
637 SendDlgItemMessageW (dialog, IDC_LIST_DRIVES, LVM_INSERTCOLUMNW, 0, (LPARAM) &listColumn);
639 LoadStringW(GetModuleHandleW(NULL), IDS_COL_DRIVEMAPPING, column, ARRAY_SIZE(column));
640 listColumn.cx = viewRect.right - viewRect.left - width;
641 listColumn.pszText = column;
642 listColumn.cchTextMax = lstrlenW (listColumn.pszText);
644 SendDlgItemMessageW (dialog, IDC_LIST_DRIVES, LVM_INSERTCOLUMNW, 1, (LPARAM) &listColumn);
647 static void load_drive_options(HWND dialog)
649 if (!wcscmp(get_reg_key(config_key, L"", L"ShowDotFiles", L"N"), L"Y"))
650 CheckDlgButton(dialog, IDC_SHOW_DOT_FILES, BST_CHECKED);
653 INT_PTR CALLBACK
654 DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
656 int item;
658 switch (msg)
660 case WM_INITDIALOG:
661 init_listview_columns(dialog);
662 if (!load_drives())
664 ShowWindow( GetDlgItem( dialog, IDC_STATIC_MOUNTMGR_ERROR ), SW_SHOW );
665 ShowWindow( GetDlgItem( dialog, IDC_LIST_DRIVES ), SW_HIDE );
666 ShowWindow( GetDlgItem( dialog, IDC_BUTTON_ADD ), SW_HIDE );
667 ShowWindow( GetDlgItem( dialog, IDC_BUTTON_REMOVE ), SW_HIDE );
668 ShowWindow( GetDlgItem( dialog, IDC_STATIC_PATH ), SW_HIDE );
669 ShowWindow( GetDlgItem( dialog, IDC_EDIT_PATH ), SW_HIDE );
670 ShowWindow( GetDlgItem( dialog, IDC_BUTTON_BROWSE_PATH ), SW_HIDE );
671 ShowWindow( GetDlgItem( dialog, IDC_COMBO_TYPE ), SW_HIDE );
672 ShowWindow( GetDlgItem( dialog, IDC_BUTTON_SHOW_HIDE_ADVANCED ), SW_HIDE );
673 set_advanced(dialog);
674 break;
676 ShowWindow( GetDlgItem( dialog, IDC_STATIC_MOUNTMGR_ERROR ), SW_HIDE );
677 load_drive_options(dialog);
679 if (!drives[2].in_use)
680 driveui_msgbox (dialog, IDS_NO_DRIVE_C, MB_OK | MB_ICONEXCLAMATION);
682 fill_drives_list(dialog);
683 update_controls(dialog);
684 /* put in non-advanced mode by default */
685 set_advanced(dialog);
686 break;
688 case WM_SHOWWINDOW:
689 set_window_title(dialog);
690 break;
692 case WM_COMMAND:
693 switch (HIWORD(wParam))
695 case EN_CHANGE:
696 on_edit_changed(dialog, LOWORD(wParam));
697 break;
699 case BN_CLICKED:
700 switch (LOWORD(wParam))
702 case IDC_SHOW_DOT_FILES:
703 on_options_click(dialog);
704 break;
706 break;
708 case CBN_SELCHANGE:
709 SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
710 break;
713 switch (LOWORD(wParam))
715 case IDC_BUTTON_ADD:
716 if (HIWORD(wParam) != BN_CLICKED) break;
717 on_add_click(dialog);
718 break;
720 case IDC_BUTTON_REMOVE:
721 if (HIWORD(wParam) != BN_CLICKED) break;
722 on_remove_click(dialog);
723 break;
725 case IDC_BUTTON_EDIT:
726 if (HIWORD(wParam) != BN_CLICKED) break;
727 item = SendMessageW(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_GETCURSEL, 0, 0);
728 SendMessageW(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_GETITEMDATA, item, 0);
729 break;
731 case IDC_BUTTON_SHOW_HIDE_ADVANCED:
732 advanced = !advanced;
733 set_advanced(dialog);
734 break;
736 case IDC_BUTTON_BROWSE_PATH:
738 WCHAR szTargetPath[FILENAME_MAX];
739 if (browse_for_unix_folder(dialog, szTargetPath))
740 set_textW(dialog, IDC_EDIT_PATH, szTargetPath);
741 break;
744 case IDC_COMBO_TYPE:
746 int mode = BOX_MODE_NORMAL;
747 int selection;
749 if (HIWORD(wParam) != CBN_SELCHANGE) break;
751 selection = SendDlgItemMessageW(dialog, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
753 if (selection >= 0 &&
754 (type_pairs[selection].sCode == DRIVE_CDROM ||
755 type_pairs[selection].sCode == DRIVE_REMOVABLE))
756 mode = BOX_MODE_DEVICE;
757 else
758 mode = BOX_MODE_NORMAL;
760 enable_labelserial_box(dialog, mode);
762 current_drive->type = type_pairs[selection].sCode;
763 current_drive->modified = TRUE;
764 break;
768 break;
770 case WM_NOTIFY:
771 switch (((LPNMHDR)lParam)->code)
773 case PSN_KILLACTIVE:
774 WINE_TRACE("PSN_KILLACTIVE\n");
775 SetWindowLongPtrW(dialog, DWLP_MSGRESULT, FALSE);
776 break;
777 case PSN_APPLY:
778 apply_drive_changes();
779 SetWindowLongPtrW(dialog, DWLP_MSGRESULT, PSNRET_NOERROR);
780 break;
781 case PSN_SETACTIVE:
782 break;
783 case LVN_ITEMCHANGED:
785 LPNMLISTVIEW lpnm = (LPNMLISTVIEW)lParam;
786 if (!(lpnm->uOldState & LVIS_SELECTED) &&
787 (lpnm->uNewState & LVIS_SELECTED))
788 update_controls(dialog);
789 break;
792 break;
795 return FALSE;