Assorted French translation improvements.
[wine/testsucceed.git] / programs / winecfg / driveui.c
blob0be623a8846096cf9d2c18f308c4087ad75d7817
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_CD_ASSIGN 1
44 #define BOX_MODE_CD_AUTODETECT 2
45 #define BOX_MODE_NONE 3
46 #define BOX_MODE_NORMAL 4
48 static BOOL advanced = FALSE;
49 static BOOL updating_ui = FALSE;
50 static struct drive* current_drive;
52 static void get_etched_rect(HWND dialog, RECT *rect);
53 static void update_controls(HWND dialog);
55 static DWORD driveui_msgbox (HWND parent, UINT messageId, DWORD flags)
57 WCHAR* caption = load_string (IDS_WINECFG_TITLE);
58 WCHAR* text = load_string (messageId);
59 DWORD result = MessageBoxW (parent, text, caption, flags);
60 HeapFree (GetProcessHeap(), 0, caption);
61 HeapFree (GetProcessHeap(), 0, text);
62 return result;
65 /**** listview helper functions ****/
67 /* clears the item at index in the listview */
68 static void lv_clear_curr_select(HWND dialog, int index)
70 ListView_SetItemState(GetDlgItem(dialog, IDC_LIST_DRIVES), index, 0, LVIS_SELECTED);
73 /* selects the item at index in the listview */
74 static void lv_set_curr_select(HWND dialog, int index)
76 /* no more than one item can be selected in our listview */
77 lv_clear_curr_select(dialog, -1);
78 ListView_SetItemState(GetDlgItem(dialog, IDC_LIST_DRIVES), index, LVIS_SELECTED, LVIS_SELECTED);
81 /* returns the currently selected item in the listview */
82 static int lv_get_curr_select(HWND dialog)
84 return SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
87 /* sets the item in the listview at item->iIndex */
88 static void lv_set_item(HWND dialog, LVITEM *item)
90 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_SETITEM, 0, (LPARAM) item);
93 /* sets specified item's text */
94 static void lv_set_item_text(HWND dialog, int item, int subItem, char *text)
96 LVITEM lvItem;
97 if (item < 0 || subItem < 0) return;
98 lvItem.mask = LVIF_TEXT;
99 lvItem.iItem = item;
100 lvItem.iSubItem = subItem;
101 lvItem.pszText = text;
102 lvItem.cchTextMax = lstrlen(lvItem.pszText);
103 lv_set_item(dialog, &lvItem);
106 /* inserts an item into the listview */
107 static void lv_insert_item(HWND dialog, LVITEM *item)
109 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_INSERTITEM, 0, (LPARAM) item);
112 /* retrieve the item at index item->iIndex */
113 static void lv_get_item(HWND dialog, LVITEM *item)
115 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_GETITEM, 0, (LPARAM) item);
118 static void set_advanced(HWND dialog)
120 int state;
121 char text[256];
122 RECT rect;
124 if (advanced)
126 state = SW_NORMAL;
127 LoadString(GetModuleHandle(NULL), IDS_HIDE_ADVANCED, text, 256);
129 else
131 state = SW_HIDE;
132 LoadString(GetModuleHandle(NULL), IDS_SHOW_ADVANCED, text, 256);
135 ShowWindow(GetDlgItem(dialog, IDC_RADIO_AUTODETECT), state);
136 ShowWindow(GetDlgItem(dialog, IDC_RADIO_ASSIGN), state);
137 ShowWindow(GetDlgItem(dialog, IDC_EDIT_LABEL), state);
138 ShowWindow(GetDlgItem(dialog, IDC_EDIT_DEVICE), state);
139 ShowWindow(GetDlgItem(dialog, IDC_STATIC_LABEL), state);
140 ShowWindow(GetDlgItem(dialog, IDC_BUTTON_BROWSE_DEVICE), state);
141 ShowWindow(GetDlgItem(dialog, IDC_EDIT_SERIAL), state);
142 ShowWindow(GetDlgItem(dialog, IDC_STATIC_SERIAL), state);
143 ShowWindow(GetDlgItem(dialog, IDC_LABELSERIAL_STATIC), state);
144 ShowWindow(GetDlgItem(dialog, IDC_COMBO_TYPE), state);
145 ShowWindow(GetDlgItem(dialog, IDC_STATIC_TYPE), state);
147 /* update the button text based on the state */
148 SetWindowText(GetDlgItem(dialog, IDC_BUTTON_SHOW_HIDE_ADVANCED), text);
150 /* redraw for the etched line */
151 get_etched_rect(dialog, &rect);
152 InflateRect(&rect, 5, 5);
153 InvalidateRect(dialog, &rect, TRUE);
156 struct drive_typemap {
157 unsigned int sCode;
158 UINT idDesc;
161 static const struct drive_typemap type_pairs[] = {
162 { DRIVE_UNKNOWN, IDS_DRIVE_UNKNOWN },
163 { DRIVE_FIXED, IDS_DRIVE_FIXED },
164 { DRIVE_REMOTE, IDS_DRIVE_REMOTE },
165 { DRIVE_REMOVABLE, IDS_DRIVE_REMOVABLE },
166 { DRIVE_CDROM, IDS_DRIVE_CDROM }
169 #define DRIVE_TYPE_DEFAULT 0
171 static void fill_drive_droplist(long mask, char curletter, HWND dialog)
173 int i;
174 int selection;
175 int count;
176 int next_letter;
177 char sName[4];
179 strcpy(sName, "A:");
180 for (i = 0, count = 0, selection = -1, next_letter = -1; i <= 'Z'-'A'; ++i)
182 if (mask & DRIVE_MASK_BIT('A' + i))
184 int index;
186 sName[0] = 'A' + i;
187 index = SendDlgItemMessage(dialog, IDC_COMBO_LETTER, CB_ADDSTRING, 0, (LPARAM) sName);
189 if (toupper(curletter) == 'A' + i)
191 selection = count;
194 if (i >= 2 && next_letter == -1)
196 /* default drive is first one of C-Z */
197 next_letter = count;
200 count++;
204 if (selection == -1)
206 selection = next_letter;
209 SendDlgItemMessage(dialog, IDC_COMBO_LETTER, CB_SETCURSEL, selection, 0);
213 static void enable_labelserial_box(HWND dialog, int mode)
215 WINE_TRACE("mode=%d\n", mode);
217 switch (mode)
219 case BOX_MODE_CD_ASSIGN:
220 enable(IDC_RADIO_ASSIGN);
221 disable(IDC_EDIT_DEVICE);
222 disable(IDC_BUTTON_BROWSE_DEVICE);
223 enable(IDC_EDIT_SERIAL);
224 enable(IDC_EDIT_LABEL);
225 enable(IDC_STATIC_SERIAL);
226 enable(IDC_STATIC_LABEL);
227 break;
229 case BOX_MODE_CD_AUTODETECT:
230 enable(IDC_RADIO_ASSIGN);
231 enable(IDC_EDIT_DEVICE);
232 enable(IDC_BUTTON_BROWSE_DEVICE);
233 disable(IDC_EDIT_SERIAL);
234 disable(IDC_EDIT_LABEL);
235 disable(IDC_STATIC_SERIAL);
236 disable(IDC_STATIC_LABEL);
237 break;
239 case BOX_MODE_NONE:
240 disable(IDC_RADIO_ASSIGN);
241 disable(IDC_EDIT_DEVICE);
242 disable(IDC_BUTTON_BROWSE_DEVICE);
243 disable(IDC_EDIT_SERIAL);
244 disable(IDC_EDIT_LABEL);
245 disable(IDC_STATIC_SERIAL);
246 disable(IDC_STATIC_LABEL);
247 break;
249 case BOX_MODE_NORMAL:
250 enable(IDC_RADIO_ASSIGN);
251 disable(IDC_EDIT_DEVICE);
252 disable(IDC_BUTTON_BROWSE_DEVICE);
253 enable(IDC_EDIT_SERIAL);
254 enable(IDC_EDIT_LABEL);
255 enable(IDC_STATIC_SERIAL);
256 enable(IDC_STATIC_LABEL);
257 break;
261 static int fill_drives_list(HWND dialog)
263 int count = 0;
264 BOOL drivec_present = FALSE;
265 int i;
266 int prevsel = -1;
268 WINE_TRACE("\n");
270 updating_ui = TRUE;
272 prevsel = lv_get_curr_select(dialog);
274 /* Clear the listbox */
275 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_DELETEALLITEMS, 0, 0);
277 for(i = 0; i < 26; i++)
279 LVITEM item;
280 char letter[4];
282 /* skip over any unused drives */
283 if (!drives[i].in_use)
284 continue;
286 if (drives[i].letter == 'C')
287 drivec_present = TRUE;
289 letter[0] = 'A' + i;
290 letter[1] = ':';
291 letter[2] = 0;
293 memset(&item, 0, sizeof(item));
294 item.mask = LVIF_TEXT | LVIF_PARAM;
295 item.iItem = count;
296 item.iSubItem = 0;
297 item.pszText = letter;
298 item.cchTextMax = lstrlen(item.pszText);
299 item.lParam = (LPARAM) &drives[i];
301 lv_insert_item(dialog, &item);
302 lv_set_item_text(dialog, count, 1, drives[i].unixpath);
304 count++;
307 WINE_TRACE("loaded %d drives\n", count);
309 /* show the warning if there is no Drive C */
310 if (!drivec_present)
311 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_NORMAL);
312 else
313 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_HIDE);
315 lv_set_curr_select(dialog, prevsel == -1 ? 0 : prevsel);
317 updating_ui = FALSE;
318 return count;
321 static void on_options_click(HWND dialog)
323 if (IsDlgButtonChecked(dialog, IDC_SHOW_DOT_FILES) == BST_CHECKED)
324 set_reg_key(config_key, "", "ShowDotFiles", "Y");
325 else
326 set_reg_key(config_key, "", "ShowDotFiles", "N");
328 SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
331 static void on_add_click(HWND dialog)
333 /* we should allocate a drive letter automatically. We also need
334 some way to let the user choose the mapping point, for now we
335 will just force them to enter a path automatically, with / being
336 the default. In future we should be able to temporarily map /
337 then invoke the directory chooser dialog. */
339 char new = 'C'; /* we skip A and B, they are historically floppy drives */
340 long mask = ~drive_available_mask(0); /* the mask is now which drives aren't available */
341 int i, c;
343 while (mask & (1 << (new - 'A')))
345 new++;
346 if (new > 'Z')
348 driveui_msgbox (dialog, IDS_DRIVE_LETTERS_EXCEEDED, MB_OK | MB_ICONEXCLAMATION);
349 return;
353 WINE_TRACE("allocating drive letter %c\n", new);
355 if (new == 'C')
357 char label[64];
358 LoadStringA (GetModuleHandle (NULL), IDS_SYSTEM_DRIVE_LABEL, label,
359 sizeof(label)/sizeof(label[0]));
360 add_drive(new, "../drive_c", label, "", DRIVE_FIXED);
362 else add_drive(new, "/", "", "", DRIVE_UNKNOWN);
364 fill_drives_list(dialog);
366 /* select the newly created drive */
367 mask = ~drive_available_mask(0);
368 c = 0;
369 for (i = 0; i < 26; i++)
371 if ('A' + i == new) break;
372 if ((1 << i) & mask) c++;
374 lv_set_curr_select(dialog, c);
376 SetFocus(GetDlgItem(dialog, IDC_LIST_DRIVES));
378 update_controls(dialog);
381 static void on_remove_click(HWND dialog)
383 int itemIndex;
384 struct drive *drive;
385 LVITEM item;
387 itemIndex = lv_get_curr_select(dialog);
388 if (itemIndex == -1) return; /* no selection */
390 memset(&item, 0, sizeof(item));
391 item.mask = LVIF_PARAM;
392 item.iItem = itemIndex;
393 item.iSubItem = 0;
395 lv_get_item(dialog, &item);
397 drive = (struct drive *) item.lParam;
399 WINE_ERR("unixpath: %s\n", drive->unixpath);
401 if (drive->letter == 'C')
403 DWORD result = driveui_msgbox (dialog, IDS_CONFIRM_DELETE_C, MB_YESNO | MB_ICONEXCLAMATION);
404 if (result == IDNO) return;
407 delete_drive(drive);
409 fill_drives_list(dialog);
411 itemIndex = itemIndex - 1;
412 if (itemIndex < 0) itemIndex = 0;
413 lv_set_curr_select(dialog, itemIndex); /* previous item */
415 SetFocus(GetDlgItem(dialog, IDC_LIST_DRIVES));
417 update_controls(dialog);
420 static void update_controls(HWND dialog)
422 char *path;
423 unsigned int type;
424 char *label;
425 char *serial;
426 const char *device;
427 int i, selection = -1;
428 LVITEM item;
430 updating_ui = TRUE;
432 i = lv_get_curr_select(dialog);
433 if (i == -1)
435 /* no selection? let's select something for the user. this will re-enter */
436 lv_set_curr_select(dialog, i);
437 return;
440 memset(&item, 0, sizeof(item));
441 item.mask = LVIF_PARAM;
442 item.iItem = i;
443 item.iSubItem = 0;
445 lv_get_item(dialog, &item);
446 current_drive = (struct drive *) item.lParam;
448 WINE_TRACE("Updating sheet for drive %c\n", current_drive->letter);
450 /* Drive letters */
451 fill_drive_droplist(drive_available_mask(current_drive->letter), current_drive->letter, dialog);
453 /* path */
454 path = current_drive->unixpath;
455 WINE_TRACE("set path control text to '%s'\n", path);
456 set_text(dialog, IDC_EDIT_PATH, path);
458 /* drive type */
459 type = current_drive->type;
460 SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_RESETCONTENT, 0, 0);
462 for (i = 0; i < sizeof(type_pairs) / sizeof(struct drive_typemap); i++)
464 WCHAR driveDesc[64];
465 LoadStringW (GetModuleHandle (NULL), type_pairs[i].idDesc, driveDesc,
466 sizeof(driveDesc)/sizeof(driveDesc[0]));
467 SendDlgItemMessageW (dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)driveDesc);
469 if (type_pairs[i].sCode == type)
471 selection = i;
475 if (selection == -1) selection = DRIVE_TYPE_DEFAULT;
476 SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
478 /* removeable media properties */
479 label = current_drive->label;
480 set_text(dialog, IDC_EDIT_LABEL, label);
482 /* set serial edit text */
483 serial = current_drive->serial;
484 set_text(dialog, IDC_EDIT_SERIAL, serial);
486 /* TODO: get the device here to put into the edit box */
487 device = "Not implemented yet";
488 set_text(dialog, IDC_EDIT_DEVICE, device);
489 device = NULL;
491 selection = IDC_RADIO_ASSIGN;
492 if ((type == DRIVE_CDROM) || (type == DRIVE_REMOVABLE))
494 if (device)
496 selection = IDC_RADIO_AUTODETECT;
497 enable_labelserial_box(dialog, BOX_MODE_CD_AUTODETECT);
499 else
501 selection = IDC_RADIO_ASSIGN;
502 enable_labelserial_box(dialog, BOX_MODE_CD_ASSIGN);
505 else
507 enable_labelserial_box(dialog, BOX_MODE_NORMAL);
508 selection = IDC_RADIO_ASSIGN;
511 CheckRadioButton(dialog, IDC_RADIO_AUTODETECT, IDC_RADIO_ASSIGN, selection);
513 updating_ui = FALSE;
515 return;
518 static void on_edit_changed(HWND dialog, WORD id)
520 if (updating_ui) return;
522 WINE_TRACE("edit id %d changed\n", id);
524 switch (id)
526 case IDC_EDIT_LABEL:
528 char *label;
530 label = get_text(dialog, id);
531 HeapFree(GetProcessHeap(), 0, current_drive->label);
532 current_drive->label = label ? label : strdupA("");
534 WINE_TRACE("set label to %s\n", current_drive->label);
536 /* enable the apply button */
537 SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
538 break;
541 case IDC_EDIT_PATH:
543 char *path;
545 path = get_text(dialog, id);
546 HeapFree(GetProcessHeap(), 0, current_drive->unixpath);
547 current_drive->unixpath = path ? path : strdupA("drive_c");
549 WINE_TRACE("set path to %s\n", current_drive->unixpath);
551 lv_set_item_text(dialog, lv_get_curr_select(dialog), 1,
552 current_drive->unixpath);
554 /* enable the apply button */
555 SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
556 break;
559 case IDC_EDIT_SERIAL:
561 char *serial;
563 serial = get_text(dialog, id);
564 HeapFree(GetProcessHeap(), 0, current_drive->serial);
565 current_drive->serial = serial ? serial : strdupA("");
567 WINE_TRACE("set serial to %s", current_drive->serial);
569 /* enable the apply button */
570 SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
571 break;
574 case IDC_EDIT_DEVICE:
576 char *device = get_text(dialog, id);
577 /* TODO: handle device if/when it makes sense to do so.... */
578 HeapFree(GetProcessHeap(), 0, device);
579 break;
584 static void get_etched_rect(HWND dialog, RECT *rect)
586 GetClientRect(dialog, rect);
588 /* these dimensions from the labelserial static in En.rc */
589 rect->top = 265;
590 rect->bottom = 265;
591 rect->left += 25;
592 rect->right -= 25;
595 /* this just draws a nice line to separate the advanced gui from the n00b gui :) */
596 static void paint(HWND dialog)
598 PAINTSTRUCT ps;
600 BeginPaint(dialog, &ps);
602 if (advanced)
604 RECT rect;
606 get_etched_rect(dialog, &rect);
608 DrawEdge(ps.hdc, &rect, EDGE_ETCHED, BF_TOP);
611 EndPaint(dialog, &ps);
614 BOOL browse_for_unix_folder(HWND dialog, char *pszPath)
616 static WCHAR wszUnixRootDisplayName[] =
617 { ':',':','{','C','C','7','0','2','E','B','2','-','7','D','C','5','-','1','1','D','9','-',
618 'C','6','8','7','-','0','0','0','4','2','3','8','A','0','1','C','D','}', 0 };
619 char pszChoosePath[256];
620 BROWSEINFOA bi = {
621 dialog,
622 NULL,
623 NULL,
624 pszChoosePath,
626 NULL,
630 IShellFolder *pDesktop;
631 LPITEMIDLIST pidlUnixRoot, pidlSelectedPath;
632 HRESULT hr;
634 LoadString(GetModuleHandle(NULL), IDS_CHOOSE_PATH, pszChoosePath, 256);
636 hr = SHGetDesktopFolder(&pDesktop);
637 if (!SUCCEEDED(hr)) return FALSE;
639 hr = IShellFolder_ParseDisplayName(pDesktop, NULL, NULL, wszUnixRootDisplayName, NULL,
640 &pidlUnixRoot, NULL);
641 if (!SUCCEEDED(hr)) {
642 IShellFolder_Release(pDesktop);
643 return FALSE;
646 bi.pidlRoot = pidlUnixRoot;
647 pidlSelectedPath = SHBrowseForFolderA(&bi);
648 SHFree(pidlUnixRoot);
650 if (pidlSelectedPath) {
651 STRRET strSelectedPath;
652 char *pszSelectedPath;
653 HRESULT hr;
655 hr = IShellFolder_GetDisplayNameOf(pDesktop, pidlSelectedPath, SHGDN_FORPARSING,
656 &strSelectedPath);
657 IShellFolder_Release(pDesktop);
658 if (!SUCCEEDED(hr)) {
659 SHFree(pidlSelectedPath);
660 return FALSE;
663 hr = StrRetToStr(&strSelectedPath, pidlSelectedPath, &pszSelectedPath);
664 SHFree(pidlSelectedPath);
665 if (!SUCCEEDED(hr)) return FALSE;
667 lstrcpy(pszPath, pszSelectedPath);
669 CoTaskMemFree(pszSelectedPath);
670 return TRUE;
672 return FALSE;
675 static void init_listview_columns(HWND dialog)
677 LVCOLUMNW listColumn;
678 RECT viewRect;
679 int width;
680 WCHAR column[64];
682 GetClientRect(GetDlgItem(dialog, IDC_LIST_DRIVES), &viewRect);
683 width = (viewRect.right - viewRect.left) / 6 - 5;
685 LoadStringW (GetModuleHandle (NULL), IDS_COL_DRIVELETTER, column,
686 sizeof(column)/sizeof(column[0]));
687 listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
688 listColumn.pszText = column;
689 listColumn.cchTextMax = lstrlenW (listColumn.pszText);
690 listColumn.cx = width;
692 SendDlgItemMessageW (dialog, IDC_LIST_DRIVES, LVM_INSERTCOLUMNW, 0, (LPARAM) &listColumn);
694 LoadStringW (GetModuleHandle (NULL), IDS_COL_DRIVEMAPPING, column,
695 sizeof(column)/sizeof(column[0]));
696 listColumn.cx = viewRect.right - viewRect.left - width;
697 listColumn.pszText = column;
698 listColumn.cchTextMax = lstrlenW (listColumn.pszText);
700 SendDlgItemMessageW (dialog, IDC_LIST_DRIVES, LVM_INSERTCOLUMNW, 1, (LPARAM) &listColumn);
703 static void load_drive_options(HWND dialog)
705 if (!strcmp(get_reg_key(config_key, "", "ShowDotFiles", "N"), "Y"))
706 CheckDlgButton(dialog, IDC_SHOW_DOT_FILES, BST_CHECKED);
709 INT_PTR CALLBACK
710 DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
712 int item;
713 struct drive *drive;
715 switch (msg)
717 case WM_INITDIALOG:
718 init_listview_columns(dialog);
719 load_drives();
720 load_drive_options(dialog);
722 if (!drives[2].in_use)
723 driveui_msgbox (dialog, IDS_NO_DRIVE_C, MB_OK | MB_ICONEXCLAMATION);
725 fill_drives_list(dialog);
726 update_controls(dialog);
727 /* put in non-advanced mode by default */
728 set_advanced(dialog);
729 break;
731 case WM_SHOWWINDOW:
732 set_window_title(dialog);
733 break;
735 case WM_PAINT:
736 paint(dialog);
737 break;
739 case WM_COMMAND:
740 switch (HIWORD(wParam))
742 case EN_CHANGE:
743 on_edit_changed(dialog, LOWORD(wParam));
744 break;
746 case BN_CLICKED:
747 switch (LOWORD(wParam))
749 case IDC_SHOW_DOT_FILES:
750 on_options_click(dialog);
751 break;
753 break;
755 case CBN_SELCHANGE:
756 SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
757 break;
760 switch (LOWORD(wParam))
762 case IDC_BUTTON_ADD:
763 if (HIWORD(wParam) != BN_CLICKED) break;
764 on_add_click(dialog);
765 break;
767 case IDC_BUTTON_REMOVE:
768 if (HIWORD(wParam) != BN_CLICKED) break;
769 on_remove_click(dialog);
770 break;
772 case IDC_BUTTON_EDIT:
773 if (HIWORD(wParam) != BN_CLICKED) break;
774 item = SendMessage(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_GETCURSEL, 0, 0);
775 drive = (struct drive *) SendMessage(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_GETITEMDATA, item, 0);
776 /*DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT), NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) drive); */
777 break;
779 case IDC_BUTTON_AUTODETECT:
780 autodetect_drives();
781 fill_drives_list(dialog);
782 SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
783 break;
785 case IDC_BUTTON_SHOW_HIDE_ADVANCED:
786 advanced = !advanced;
787 set_advanced(dialog);
788 break;
790 case IDC_BUTTON_BROWSE_PATH:
792 char szTargetPath[FILENAME_MAX];
793 if (browse_for_unix_folder(dialog, szTargetPath))
794 set_text(dialog, IDC_EDIT_PATH, szTargetPath);
795 break;
798 case IDC_RADIO_ASSIGN:
800 char *str;
802 str = get_text(dialog, IDC_EDIT_LABEL);
803 HeapFree(GetProcessHeap(), 0, current_drive->label);
804 current_drive->label = str ? str : strdupA("");
806 str = get_text(dialog, IDC_EDIT_SERIAL);
807 HeapFree(GetProcessHeap(), 0, current_drive->serial);
808 current_drive->serial = str ? str : strdupA("");
810 /* TODO: we don't have a device at this point */
812 enable_labelserial_box(dialog, BOX_MODE_CD_ASSIGN);
814 break;
818 case IDC_COMBO_TYPE:
820 int mode = BOX_MODE_NORMAL;
821 int selection;
823 if (HIWORD(wParam) != CBN_SELCHANGE) break;
825 selection = SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
827 if (selection >= 0 &&
828 (type_pairs[selection].sCode == DRIVE_CDROM ||
829 type_pairs[selection].sCode == DRIVE_REMOVABLE))
831 if (IsDlgButtonChecked(dialog, IDC_RADIO_AUTODETECT))
832 mode = BOX_MODE_CD_AUTODETECT;
833 else
834 mode = BOX_MODE_CD_ASSIGN;
837 enable_labelserial_box(dialog, mode);
839 current_drive->type = type_pairs[selection].sCode;
840 break;
844 break;
846 case WM_NOTIFY:
847 switch (((LPNMHDR)lParam)->code)
849 case PSN_KILLACTIVE:
850 WINE_TRACE("PSN_KILLACTIVE\n");
851 SetWindowLongPtr(dialog, DWLP_MSGRESULT, FALSE);
852 break;
853 case PSN_APPLY:
854 apply_drive_changes();
855 SetWindowLongPtr(dialog, DWLP_MSGRESULT, PSNRET_NOERROR);
856 break;
857 case PSN_SETACTIVE:
858 break;
859 case LVN_ITEMCHANGED:
861 LPNMLISTVIEW lpnm = (LPNMLISTVIEW)lParam;
862 if (!(lpnm->uOldState & LVIS_SELECTED) &&
863 (lpnm->uNewState & LVIS_SELECTED))
864 update_controls(dialog);
865 break;
868 break;
871 return FALSE;