Avoid importing _strlwr/_strupr from ntdll.
[wine/multimedia.git] / programs / winecfg / driveui.c
blob5f407b5512e624a9f15042a02fb7749936183c60
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #define WIN32_LEAN_AND_MEAN
25 #define COBJMACROS
27 #include <windows.h>
28 #include <shellapi.h>
29 #include <objbase.h>
30 #include <shlguid.h>
31 #include <shlwapi.h>
32 #include <shlobj.h>
34 #include <wine/debug.h>
36 #include "winecfg.h"
37 #include "resource.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
41 #define BOX_MODE_CD_ASSIGN 1
42 #define BOX_MODE_CD_AUTODETECT 2
43 #define BOX_MODE_NONE 3
44 #define BOX_MODE_NORMAL 4
46 static BOOL advanced = FALSE;
47 static BOOL updating_ui = FALSE;
48 static struct drive* current_drive;
50 static void get_etched_rect(HWND dialog, RECT *rect);
51 static void update_controls(HWND dialog);
53 /**** listview helper functions ****/
55 /* clears the item at index in the listview */
56 static void lv_clear_curr_select(HWND dialog, int index)
58 ListView_SetItemState(GetDlgItem(dialog, IDC_LIST_DRIVES), index, 0, LVIS_SELECTED);
61 /* selects the item at index in the listview */
62 static void lv_set_curr_select(HWND dialog, int index)
64 /* no more than one item can be selected in our listview */
65 lv_clear_curr_select(dialog, -1);
66 ListView_SetItemState(GetDlgItem(dialog, IDC_LIST_DRIVES), index, LVIS_SELECTED, LVIS_SELECTED);
69 /* returns the currently selected item in the listview */
70 static int lv_get_curr_select(HWND dialog)
72 return SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
75 /* sets the item in the listview at item->iIndex */
76 static void lv_set_item(HWND dialog, LVITEM *item)
78 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_SETITEM, 0, (LPARAM) item);
81 /* sets specified item's text */
82 static void lv_set_item_text(HWND dialog, int item, int subItem, char *text)
84 LVITEM lvItem;
85 if (item < 0 || subItem < 0) return;
86 lvItem.mask = LVIF_TEXT;
87 lvItem.iItem = item;
88 lvItem.iSubItem = subItem;
89 lvItem.pszText = text;
90 lvItem.cchTextMax = lstrlen(lvItem.pszText);
91 lv_set_item(dialog, &lvItem);
94 /* inserts an item into the listview */
95 static void lv_insert_item(HWND dialog, LVITEM *item)
97 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_INSERTITEM, 0, (LPARAM) item);
100 /* retrieve the item at index item->iIndex */
101 static void lv_get_item(HWND dialog, LVITEM *item)
103 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_GETITEM, 0, (LPARAM) item);
106 static void set_advanced(HWND dialog)
108 int state;
109 char text[256];
110 RECT rect;
112 if (advanced)
114 state = SW_NORMAL;
115 LoadString(GetModuleHandle(NULL), IDS_HIDE_ADVANCED, text, 256);
117 else
119 state = SW_HIDE;
120 LoadString(GetModuleHandle(NULL), IDS_SHOW_ADVANCED, text, 256);
123 ShowWindow(GetDlgItem(dialog, IDC_RADIO_AUTODETECT), state);
124 ShowWindow(GetDlgItem(dialog, IDC_RADIO_ASSIGN), state);
125 ShowWindow(GetDlgItem(dialog, IDC_EDIT_LABEL), state);
126 ShowWindow(GetDlgItem(dialog, IDC_EDIT_DEVICE), state);
127 ShowWindow(GetDlgItem(dialog, IDC_STATIC_LABEL), state);
128 ShowWindow(GetDlgItem(dialog, IDC_BUTTON_BROWSE_DEVICE), state);
129 ShowWindow(GetDlgItem(dialog, IDC_EDIT_SERIAL), state);
130 ShowWindow(GetDlgItem(dialog, IDC_STATIC_SERIAL), state);
131 ShowWindow(GetDlgItem(dialog, IDC_LABELSERIAL_STATIC), state);
132 ShowWindow(GetDlgItem(dialog, IDC_COMBO_TYPE), state);
133 ShowWindow(GetDlgItem(dialog, IDC_STATIC_TYPE), state);
135 /* update the button text based on the state */
136 SetWindowText(GetDlgItem(dialog, IDC_BUTTON_SHOW_HIDE_ADVANCED), text);
138 /* redraw for the etched line */
139 get_etched_rect(dialog, &rect);
140 InflateRect(&rect, 5, 5);
141 InvalidateRect(dialog, &rect, TRUE);
144 struct drive_typemap {
145 unsigned int sCode;
146 const char *sDesc;
149 static const struct drive_typemap type_pairs[] = {
150 { DRIVE_UNKNOWN, "Autodetect" },
151 { DRIVE_FIXED, "Local hard disk" },
152 { DRIVE_REMOTE, "Network share" },
153 { DRIVE_REMOVABLE, "Floppy disk" },
154 { DRIVE_CDROM, "CD-ROM" }
157 #define DRIVE_TYPE_DEFAULT 0
159 static void fill_drive_droplist(long mask, char curletter, HWND dialog)
161 int i;
162 int selection;
163 int count;
164 int next_letter;
165 char sName[4];
167 strcpy(sName, "A:");
168 for (i = 0, count = 0, selection = -1, next_letter = -1; i <= 'Z'-'A'; ++i)
170 if (mask & DRIVE_MASK_BIT('A' + i))
172 int index;
174 sName[0] = 'A' + i;
175 index = SendDlgItemMessage(dialog, IDC_COMBO_LETTER, CB_ADDSTRING, 0, (LPARAM) sName);
177 if (toupper(curletter) == 'A' + i)
179 selection = count;
182 if (i >= 2 && next_letter == -1)
184 /* default drive is first one of C-Z */
185 next_letter = count;
188 count++;
192 if (selection == -1)
194 selection = next_letter;
197 SendDlgItemMessage(dialog, IDC_COMBO_LETTER, CB_SETCURSEL, selection, 0);
201 static void enable_labelserial_box(HWND dialog, int mode)
203 WINE_TRACE("mode=%d\n", mode);
205 switch (mode)
207 case BOX_MODE_CD_ASSIGN:
208 enable(IDC_RADIO_ASSIGN);
209 disable(IDC_EDIT_DEVICE);
210 disable(IDC_BUTTON_BROWSE_DEVICE);
211 enable(IDC_EDIT_SERIAL);
212 enable(IDC_EDIT_LABEL);
213 enable(IDC_STATIC_SERIAL);
214 enable(IDC_STATIC_LABEL);
215 break;
217 case BOX_MODE_CD_AUTODETECT:
218 enable(IDC_RADIO_ASSIGN);
219 enable(IDC_EDIT_DEVICE);
220 enable(IDC_BUTTON_BROWSE_DEVICE);
221 disable(IDC_EDIT_SERIAL);
222 disable(IDC_EDIT_LABEL);
223 disable(IDC_STATIC_SERIAL);
224 disable(IDC_STATIC_LABEL);
225 break;
227 case BOX_MODE_NONE:
228 disable(IDC_RADIO_ASSIGN);
229 disable(IDC_EDIT_DEVICE);
230 disable(IDC_BUTTON_BROWSE_DEVICE);
231 disable(IDC_EDIT_SERIAL);
232 disable(IDC_EDIT_LABEL);
233 disable(IDC_STATIC_SERIAL);
234 disable(IDC_STATIC_LABEL);
235 break;
237 case BOX_MODE_NORMAL:
238 enable(IDC_RADIO_ASSIGN);
239 disable(IDC_EDIT_DEVICE);
240 disable(IDC_BUTTON_BROWSE_DEVICE);
241 enable(IDC_EDIT_SERIAL);
242 enable(IDC_EDIT_LABEL);
243 enable(IDC_STATIC_SERIAL);
244 enable(IDC_STATIC_LABEL);
245 break;
249 static int fill_drives_list(HWND dialog)
251 int count = 0;
252 BOOL drivec_present = FALSE;
253 int i;
254 int prevsel = -1;
256 WINE_TRACE("\n");
258 updating_ui = TRUE;
260 prevsel = lv_get_curr_select(dialog);
262 /* Clear the listbox */
263 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_DELETEALLITEMS, 0, 0);
265 for(i = 0; i < 26; i++)
267 LVITEM item;
268 char letter[4];
270 /* skip over any unused drives */
271 if (!drives[i].in_use)
272 continue;
274 if (drives[i].letter == 'C')
275 drivec_present = TRUE;
277 letter[0] = 'A' + i;
278 letter[1] = ':';
279 letter[2] = 0;
281 memset(&item, 0, sizeof(item));
282 item.mask = LVIF_TEXT | LVIF_PARAM;
283 item.iItem = count;
284 item.iSubItem = 0;
285 item.pszText = letter;
286 item.cchTextMax = lstrlen(item.pszText);
287 item.lParam = (LPARAM) &drives[i];
289 lv_insert_item(dialog, &item);
290 lv_set_item_text(dialog, count, 1, drives[i].unixpath);
292 count++;
295 WINE_TRACE("loaded %d drives\n", count);
297 /* show the warning if there is no Drive C */
298 if (!drivec_present)
299 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_NORMAL);
300 else
301 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_HIDE);
303 lv_set_curr_select(dialog, prevsel == -1 ? 0 : prevsel);
305 updating_ui = FALSE;
306 return count;
309 static void on_options_click(HWND dialog)
311 if (IsDlgButtonChecked(dialog, IDC_SHOW_DOT_FILES) == BST_CHECKED)
312 set_reg_key(config_key, "", "ShowDotFiles", "Y");
313 else
314 set_reg_key(config_key, "", "ShowDotFiles", "N");
316 SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
319 static void on_add_click(HWND dialog)
321 /* we should allocate a drive letter automatically. We also need
322 some way to let the user choose the mapping point, for now we
323 will just force them to enter a path automatically, with / being
324 the default. In future we should be able to temporarily map /
325 then invoke the directory chooser dialog. */
327 char new = 'C'; /* we skip A and B, they are historically floppy drives */
328 long mask = ~drive_available_mask(0); /* the mask is now which drives aren't available */
329 int i, c;
331 while (mask & (1 << (new - 'A')))
333 new++;
334 if (new > 'Z')
336 MessageBox(dialog, "You cannot add any more drives.\n\nEach drive must have a letter, from A to Z, so you cannot have more than 26", "", MB_OK | MB_ICONEXCLAMATION);
337 return;
341 WINE_TRACE("allocating drive letter %c\n", new);
343 if (new == 'C') add_drive(new, "../drive_c", "System Drive", "", DRIVE_FIXED);
344 else add_drive(new, "/", "", "", DRIVE_UNKNOWN);
346 fill_drives_list(dialog);
348 /* select the newly created drive */
349 mask = ~drive_available_mask(0);
350 c = 0;
351 for (i = 0; i < 26; i++)
353 if ('A' + i == new) break;
354 if ((1 << i) & mask) c++;
356 lv_set_curr_select(dialog, c);
358 SetFocus(GetDlgItem(dialog, IDC_LIST_DRIVES));
360 update_controls(dialog);
363 static void on_remove_click(HWND dialog)
365 int itemIndex;
366 struct drive *drive;
367 LVITEM item;
369 itemIndex = lv_get_curr_select(dialog);
370 if (itemIndex == -1) return; /* no selection */
372 memset(&item, 0, sizeof(item));
373 item.mask = LVIF_PARAM;
374 item.iItem = itemIndex;
375 item.iSubItem = 0;
377 lv_get_item(dialog, &item);
379 drive = (struct drive *) item.lParam;
381 WINE_ERR("unixpath: %s\n", drive->unixpath);
383 if (drive->letter == 'C')
385 DWORD result = MessageBox(dialog, "Are you sure you want to delete drive C?\n\nMost Windows applications expect drive C to exist, and will die messily if it doesn't. If you proceed remember to recreate it!", "", MB_YESNO | MB_ICONEXCLAMATION);
386 if (result == IDNO) return;
389 delete_drive(drive);
391 fill_drives_list(dialog);
393 itemIndex = itemIndex - 1;
394 if (itemIndex < 0) itemIndex = 0;
395 lv_set_curr_select(dialog, itemIndex); /* previous item */
397 SetFocus(GetDlgItem(dialog, IDC_LIST_DRIVES));
399 update_controls(dialog);
402 static void update_controls(HWND dialog)
404 char *path;
405 unsigned int type;
406 char *label;
407 char *serial;
408 const char *device;
409 int i, selection = -1;
410 LVITEM item;
412 updating_ui = TRUE;
414 i = lv_get_curr_select(dialog);
415 if (i == -1)
417 /* no selection? let's select something for the user. this will re-enter */
418 lv_set_curr_select(dialog, i);
419 return;
422 memset(&item, 0, sizeof(item));
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 /* Drive letters */
433 fill_drive_droplist(drive_available_mask(current_drive->letter), current_drive->letter, dialog);
435 /* path */
436 path = current_drive->unixpath;
437 WINE_TRACE("set path control text to '%s'\n", path);
438 set_text(dialog, IDC_EDIT_PATH, path);
440 /* drive type */
441 type = current_drive->type;
442 SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_RESETCONTENT, 0, 0);
444 for (i = 0; i < sizeof(type_pairs) / sizeof(struct drive_typemap); i++)
446 SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM) type_pairs[i].sDesc);
448 if (type_pairs[i].sCode == type)
450 selection = i;
454 if (selection == -1) selection = DRIVE_TYPE_DEFAULT;
455 SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
457 /* removeable media properties */
458 label = current_drive->label;
459 set_text(dialog, IDC_EDIT_LABEL, label);
461 /* set serial edit text */
462 serial = current_drive->serial;
463 set_text(dialog, IDC_EDIT_SERIAL, serial);
465 /* TODO: get the device here to put into the edit box */
466 device = "Not implemented yet";
467 set_text(dialog, IDC_EDIT_DEVICE, device);
468 device = NULL;
470 selection = IDC_RADIO_ASSIGN;
471 if ((type == DRIVE_CDROM) || (type == DRIVE_REMOVABLE))
473 if (device)
475 selection = IDC_RADIO_AUTODETECT;
476 enable_labelserial_box(dialog, BOX_MODE_CD_AUTODETECT);
478 else
480 selection = IDC_RADIO_ASSIGN;
481 enable_labelserial_box(dialog, BOX_MODE_CD_ASSIGN);
484 else
486 enable_labelserial_box(dialog, BOX_MODE_NORMAL);
487 selection = IDC_RADIO_ASSIGN;
490 CheckRadioButton(dialog, IDC_RADIO_AUTODETECT, IDC_RADIO_ASSIGN, selection);
492 updating_ui = FALSE;
494 return;
497 static void on_edit_changed(HWND dialog, WORD id)
499 if (updating_ui) return;
501 WINE_TRACE("edit id %d changed\n", id);
503 switch (id)
505 case IDC_EDIT_LABEL:
507 char *label;
509 label = get_text(dialog, id);
510 HeapFree(GetProcessHeap(), 0, current_drive->label);
511 current_drive->label = label ? label : strdupA("");
513 WINE_TRACE("set label to %s\n", current_drive->label);
515 /* enable the apply button */
516 SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
517 break;
520 case IDC_EDIT_PATH:
522 char *path;
524 path = get_text(dialog, id);
525 HeapFree(GetProcessHeap(), 0, current_drive->unixpath);
526 current_drive->unixpath = path ? path : strdupA("drive_c");
528 WINE_TRACE("set path to %s\n", current_drive->unixpath);
530 lv_set_item_text(dialog, lv_get_curr_select(dialog), 1,
531 current_drive->unixpath);
533 /* enable the apply button */
534 SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
535 break;
538 case IDC_EDIT_SERIAL:
540 char *serial;
542 serial = get_text(dialog, id);
543 HeapFree(GetProcessHeap(), 0, current_drive->serial);
544 current_drive->serial = serial ? serial : strdupA("");
546 WINE_TRACE("set serial to %s", current_drive->serial);
548 /* enable the apply button */
549 SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
550 break;
553 case IDC_EDIT_DEVICE:
555 char *device = get_text(dialog, id);
556 /* TODO: handle device if/when it makes sense to do so.... */
557 HeapFree(GetProcessHeap(), 0, device);
558 break;
563 static void get_etched_rect(HWND dialog, RECT *rect)
565 GetClientRect(dialog, rect);
567 /* these dimensions from the labelserial static in En.rc */
568 rect->top = 265;
569 rect->bottom = 265;
570 rect->left += 25;
571 rect->right -= 25;
574 /* this just draws a nice line to separate the advanced gui from the n00b gui :) */
575 static void paint(HWND dialog)
577 PAINTSTRUCT ps;
579 BeginPaint(dialog, &ps);
581 if (advanced)
583 RECT rect;
585 get_etched_rect(dialog, &rect);
587 DrawEdge(ps.hdc, &rect, EDGE_ETCHED, BF_TOP);
590 EndPaint(dialog, &ps);
593 static void browse_for_folder(HWND dialog)
595 static WCHAR wszUnixRootDisplayName[] =
596 { ':',':','{','C','C','7','0','2','E','B','2','-','7','D','C','5','-','1','1','D','9','-',
597 'C','6','8','7','-','0','0','0','4','2','3','8','A','0','1','C','D','}', 0 };
598 char pszChoosePath[256];
599 BROWSEINFOA bi = {
600 dialog,
601 NULL,
602 NULL,
603 pszChoosePath,
605 NULL,
609 IShellFolder *pDesktop;
610 LPITEMIDLIST pidlUnixRoot, pidlSelectedPath;
611 HRESULT hr;
613 LoadString(GetModuleHandle(NULL), IDS_CHOOSE_PATH, pszChoosePath, 256);
615 hr = SHGetDesktopFolder(&pDesktop);
616 if (!SUCCEEDED(hr)) return;
618 hr = IShellFolder_ParseDisplayName(pDesktop, NULL, NULL, wszUnixRootDisplayName, NULL,
619 &pidlUnixRoot, NULL);
620 if (!SUCCEEDED(hr)) {
621 IShellFolder_Release(pDesktop);
622 return;
625 bi.pidlRoot = pidlUnixRoot;
626 pidlSelectedPath = SHBrowseForFolderA(&bi);
627 SHFree(pidlUnixRoot);
629 if (pidlSelectedPath) {
630 STRRET strSelectedPath;
631 char *pszSelectedPath;
632 HRESULT hr;
634 hr = IShellFolder_GetDisplayNameOf(pDesktop, pidlSelectedPath, SHGDN_FORPARSING,
635 &strSelectedPath);
636 IShellFolder_Release(pDesktop);
637 if (!SUCCEEDED(hr)) {
638 SHFree(pidlSelectedPath);
639 return;
642 hr = StrRetToStr(&strSelectedPath, pidlSelectedPath, &pszSelectedPath);
643 SHFree(pidlSelectedPath);
644 if (!SUCCEEDED(hr)) return;
646 set_text(dialog, IDC_EDIT_PATH, pszSelectedPath);
648 CoTaskMemFree(pszSelectedPath);
652 static void init_listview_columns(HWND dialog)
654 LVCOLUMN listColumn;
655 RECT viewRect;
656 int width;
658 GetClientRect(GetDlgItem(dialog, IDC_LIST_DRIVES), &viewRect);
659 width = (viewRect.right - viewRect.left) / 6 - 5;
661 listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
662 listColumn.pszText = (char*) "Letter";
663 listColumn.cchTextMax = lstrlen(listColumn.pszText);
664 listColumn.cx = width;
666 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_INSERTCOLUMN, 0, (LPARAM) &listColumn);
668 listColumn.cx = viewRect.right - viewRect.left - width;
669 listColumn.pszText = (char*) "Drive Mapping";
670 listColumn.cchTextMax = lstrlen(listColumn.pszText);
672 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_INSERTCOLUMN, 1, (LPARAM) &listColumn);
675 static void load_drive_options(HWND dialog)
677 if (!strcmp(get_reg_key(config_key, "", "ShowDotFiles", "N"), "Y"))
678 CheckDlgButton(dialog, IDC_SHOW_DOT_FILES, BST_CHECKED);
681 INT_PTR CALLBACK
682 DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
684 int item;
685 struct drive *drive;
687 switch (msg)
689 case WM_INITDIALOG:
690 init_listview_columns(dialog);
691 load_drives();
692 load_drive_options(dialog);
694 if (!drives[2].in_use)
695 MessageBox(dialog, "You don't have a drive C. This is not so great.\n\nRemember to click 'Add' in the Drives tab to create one!\n", "", MB_OK | MB_ICONEXCLAMATION);
697 fill_drives_list(dialog);
698 update_controls(dialog);
699 /* put in non-advanced mode by default */
700 set_advanced(dialog);
701 break;
703 case WM_SHOWWINDOW:
704 set_window_title(dialog);
705 break;
707 case WM_PAINT:
708 paint(dialog);
709 break;
711 case WM_COMMAND:
712 switch (HIWORD(wParam))
714 case EN_CHANGE:
715 on_edit_changed(dialog, LOWORD(wParam));
716 break;
718 case BN_CLICKED:
719 switch (LOWORD(wParam))
721 case IDC_SHOW_DOT_FILES:
722 on_options_click(dialog);
723 break;
725 break;
727 case CBN_SELCHANGE:
728 SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
729 break;
732 switch (LOWORD(wParam))
734 case IDC_BUTTON_ADD:
735 if (HIWORD(wParam) != BN_CLICKED) break;
736 on_add_click(dialog);
737 break;
739 case IDC_BUTTON_REMOVE:
740 if (HIWORD(wParam) != BN_CLICKED) break;
741 on_remove_click(dialog);
742 break;
744 case IDC_BUTTON_EDIT:
745 if (HIWORD(wParam) != BN_CLICKED) break;
746 item = SendMessage(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_GETCURSEL, 0, 0);
747 drive = (struct drive *) SendMessage(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_GETITEMDATA, item, 0);
748 /*DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT), NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) drive); */
749 break;
751 case IDC_BUTTON_AUTODETECT:
752 autodetect_drives();
753 fill_drives_list(dialog);
754 SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
755 break;
757 case IDC_BUTTON_SHOW_HIDE_ADVANCED:
758 advanced = !advanced;
759 set_advanced(dialog);
760 break;
762 case IDC_BUTTON_BROWSE_PATH:
763 browse_for_folder(dialog);
764 break;
766 case IDC_RADIO_ASSIGN:
768 char *str;
770 str = get_text(dialog, IDC_EDIT_LABEL);
771 HeapFree(GetProcessHeap(), 0, current_drive->label);
772 current_drive->label = str ? str : strdupA("");
774 str = get_text(dialog, IDC_EDIT_SERIAL);
775 HeapFree(GetProcessHeap(), 0, current_drive->serial);
776 current_drive->serial = str ? str : strdupA("");
778 /* TODO: we don't have a device at this point */
780 enable_labelserial_box(dialog, BOX_MODE_CD_ASSIGN);
782 break;
786 case IDC_COMBO_TYPE:
788 int mode = BOX_MODE_NORMAL;
789 int selection;
791 if (HIWORD(wParam) != CBN_SELCHANGE) break;
793 selection = SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
795 if (selection >= 0 &&
796 (type_pairs[selection].sCode == DRIVE_CDROM ||
797 type_pairs[selection].sCode == DRIVE_REMOVABLE))
799 if (IsDlgButtonChecked(dialog, IDC_RADIO_AUTODETECT))
800 mode = BOX_MODE_CD_AUTODETECT;
801 else
802 mode = BOX_MODE_CD_ASSIGN;
805 enable_labelserial_box(dialog, mode);
807 current_drive->type = type_pairs[selection].sCode;
808 break;
812 break;
814 case WM_NOTIFY:
815 switch (((LPNMHDR)lParam)->code)
817 case PSN_KILLACTIVE:
818 WINE_TRACE("PSN_KILLACTIVE\n");
819 SetWindowLongPtr(dialog, DWLP_MSGRESULT, FALSE);
820 break;
821 case PSN_APPLY:
822 apply_drive_changes();
823 SetWindowLongPtr(dialog, DWLP_MSGRESULT, PSNRET_NOERROR);
824 break;
825 case PSN_SETACTIVE:
826 break;
827 case LVN_ITEMCHANGED:
829 LPNMLISTVIEW lpnm = (LPNMLISTVIEW)lParam;
830 if (!(lpnm->uOldState & LVIS_SELECTED) &&
831 (lpnm->uNewState & LVIS_SELECTED))
832 update_controls(dialog);
833 break;
836 break;
839 return FALSE;