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
39 #include <wine/debug.h>
44 WINE_DEFAULT_DEBUG_CHANNEL(winecfg
);
46 #define BOX_MODE_CD_ASSIGN 1
47 #define BOX_MODE_CD_AUTODETECT 2
48 #define BOX_MODE_NONE 3
49 #define BOX_MODE_NORMAL 4
51 static BOOL advanced
= FALSE
;
52 static BOOL updating_ui
= FALSE
;
53 static struct drive
* current_drive
;
55 static void get_etched_rect(HWND dialog
, RECT
*rect
);
56 static void update_controls(HWND dialog
);
58 /**** listview helper functions ****/
60 /* clears the item at index in the listview */
61 static void lv_clear_curr_select(HWND dialog
, int index
)
63 ListView_SetItemState(GetDlgItem(dialog
, IDC_LIST_DRIVES
), index
, 0, LVIS_SELECTED
);
66 /* selects the item at index in the listview */
67 static void lv_set_curr_select(HWND dialog
, int index
)
69 /* no more than one item can be selected in our listview */
70 lv_clear_curr_select(dialog
, -1);
71 ListView_SetItemState(GetDlgItem(dialog
, IDC_LIST_DRIVES
), index
, LVIS_SELECTED
, LVIS_SELECTED
);
74 /* returns the currently selected item in the listview */
75 static int lv_get_curr_select(HWND dialog
)
77 return SendDlgItemMessage(dialog
, IDC_LIST_DRIVES
, LVM_GETNEXTITEM
, -1, LVNI_SELECTED
);
80 /* sets the item in the listview at item->iIndex */
81 static void lv_set_item(HWND dialog
, LVITEM
*item
)
83 SendDlgItemMessage(dialog
, IDC_LIST_DRIVES
, LVM_SETITEM
, 0, (LPARAM
) item
);
86 /* sets specified item's text */
87 static void lv_set_item_text(HWND dialog
, int item
, int subItem
, char *text
)
90 if (item
< 0 || subItem
< 0) return;
91 lvItem
.mask
= LVIF_TEXT
;
93 lvItem
.iSubItem
= subItem
;
94 lvItem
.pszText
= text
;
95 lvItem
.cchTextMax
= lstrlen(lvItem
.pszText
);
96 lv_set_item(dialog
, &lvItem
);
99 /* inserts an item into the listview */
100 static void lv_insert_item(HWND dialog
, LVITEM
*item
)
102 SendDlgItemMessage(dialog
, IDC_LIST_DRIVES
, LVM_INSERTITEM
, 0, (LPARAM
) item
);
105 /* retrieve the item at index item->iIndex */
106 static void lv_get_item(HWND dialog
, LVITEM
*item
)
108 SendDlgItemMessage(dialog
, IDC_LIST_DRIVES
, LVM_GETITEM
, 0, (LPARAM
) item
);
111 static void set_advanced(HWND dialog
)
120 LoadString(GetModuleHandle(NULL
), IDS_HIDE_ADVANCED
, text
, 256);
125 LoadString(GetModuleHandle(NULL
), IDS_SHOW_ADVANCED
, text
, 256);
128 ShowWindow(GetDlgItem(dialog
, IDC_RADIO_AUTODETECT
), state
);
129 ShowWindow(GetDlgItem(dialog
, IDC_RADIO_ASSIGN
), state
);
130 ShowWindow(GetDlgItem(dialog
, IDC_EDIT_LABEL
), state
);
131 ShowWindow(GetDlgItem(dialog
, IDC_EDIT_DEVICE
), state
);
132 ShowWindow(GetDlgItem(dialog
, IDC_STATIC_LABEL
), state
);
133 ShowWindow(GetDlgItem(dialog
, IDC_BUTTON_BROWSE_DEVICE
), state
);
134 ShowWindow(GetDlgItem(dialog
, IDC_EDIT_SERIAL
), state
);
135 ShowWindow(GetDlgItem(dialog
, IDC_STATIC_SERIAL
), state
);
136 ShowWindow(GetDlgItem(dialog
, IDC_LABELSERIAL_STATIC
), state
);
137 ShowWindow(GetDlgItem(dialog
, IDC_COMBO_TYPE
), state
);
138 ShowWindow(GetDlgItem(dialog
, IDC_STATIC_TYPE
), state
);
140 /* update the button text based on the state */
141 SetWindowText(GetDlgItem(dialog
, IDC_BUTTON_SHOW_HIDE_ADVANCED
), text
);
143 /* redraw for the etched line */
144 get_etched_rect(dialog
, &rect
);
145 InflateRect(&rect
, 5, 5);
146 InvalidateRect(dialog
, &rect
, TRUE
);
149 struct drive_typemap
{
154 static const struct drive_typemap type_pairs
[] = {
155 { DRIVE_UNKNOWN
, "Autodetect" },
156 { DRIVE_FIXED
, "Local hard disk" },
157 { DRIVE_REMOTE
, "Network share" },
158 { DRIVE_REMOVABLE
, "Floppy disk" },
159 { DRIVE_CDROM
, "CD-ROM" }
162 #define DRIVE_TYPE_DEFAULT 0
164 static void fill_drive_droplist(long mask
, char curletter
, HWND dialog
)
173 for (i
= 0, count
= 0, selection
= -1, next_letter
= -1; i
<= 'Z'-'A'; ++i
)
175 if (mask
& DRIVE_MASK_BIT('A' + i
))
180 index
= SendDlgItemMessage(dialog
, IDC_COMBO_LETTER
, CB_ADDSTRING
, 0, (LPARAM
) sName
);
182 if (toupper(curletter
) == 'A' + i
)
187 if (i
>= 2 && next_letter
== -1)
189 /* default drive is first one of C-Z */
199 selection
= next_letter
;
202 SendDlgItemMessage(dialog
, IDC_COMBO_LETTER
, CB_SETCURSEL
, selection
, 0);
206 static void enable_labelserial_box(HWND dialog
, int mode
)
208 WINE_TRACE("mode=%d\n", mode
);
212 case BOX_MODE_CD_ASSIGN
:
213 enable(IDC_RADIO_ASSIGN
);
214 disable(IDC_EDIT_DEVICE
);
215 disable(IDC_BUTTON_BROWSE_DEVICE
);
216 enable(IDC_EDIT_SERIAL
);
217 enable(IDC_EDIT_LABEL
);
218 enable(IDC_STATIC_SERIAL
);
219 enable(IDC_STATIC_LABEL
);
222 case BOX_MODE_CD_AUTODETECT
:
223 enable(IDC_RADIO_ASSIGN
);
224 enable(IDC_EDIT_DEVICE
);
225 enable(IDC_BUTTON_BROWSE_DEVICE
);
226 disable(IDC_EDIT_SERIAL
);
227 disable(IDC_EDIT_LABEL
);
228 disable(IDC_STATIC_SERIAL
);
229 disable(IDC_STATIC_LABEL
);
233 disable(IDC_RADIO_ASSIGN
);
234 disable(IDC_EDIT_DEVICE
);
235 disable(IDC_BUTTON_BROWSE_DEVICE
);
236 disable(IDC_EDIT_SERIAL
);
237 disable(IDC_EDIT_LABEL
);
238 disable(IDC_STATIC_SERIAL
);
239 disable(IDC_STATIC_LABEL
);
242 case BOX_MODE_NORMAL
:
243 enable(IDC_RADIO_ASSIGN
);
244 disable(IDC_EDIT_DEVICE
);
245 disable(IDC_BUTTON_BROWSE_DEVICE
);
246 enable(IDC_EDIT_SERIAL
);
247 enable(IDC_EDIT_LABEL
);
248 enable(IDC_STATIC_SERIAL
);
249 enable(IDC_STATIC_LABEL
);
254 static int fill_drives_list(HWND dialog
)
257 BOOL drivec_present
= FALSE
;
265 prevsel
= lv_get_curr_select(dialog
);
267 /* Clear the listbox */
268 SendDlgItemMessage(dialog
, IDC_LIST_DRIVES
, LVM_DELETEALLITEMS
, 0, 0);
270 for(i
= 0; i
< 26; i
++)
276 /* skip over any unused drives */
277 if (!drives
[i
].in_use
)
280 if (drives
[i
].letter
== 'C')
281 drivec_present
= TRUE
;
283 len
= snprintf(letter
, 0, "%c:", 'A' + i
);
284 len
++; /* add a byte for the trailing null */
286 letter
= HeapAlloc(GetProcessHeap(), 0, len
);
287 snprintf(letter
, len
, "%c:", 'A' + i
);
289 memset(&item
, 0, sizeof(item
));
290 item
.mask
= LVIF_TEXT
;
293 item
.pszText
= letter
;
294 item
.cchTextMax
= lstrlen(item
.pszText
);
296 lv_insert_item(dialog
, &item
);
299 item
.pszText
= drives
[i
].unixpath
;
300 item
.cchTextMax
= lstrlen(item
.pszText
);
302 lv_set_item(dialog
, &item
);
304 item
.mask
= LVIF_PARAM
;
306 item
.lParam
= (LPARAM
) &drives
[i
];
308 lv_set_item(dialog
, &item
);
310 HeapFree(GetProcessHeap(), 0, letter
);
314 WINE_TRACE("loaded %d drives\n", count
);
316 /* show the warning if there is no Drive C */
318 ShowWindow(GetDlgItem(dialog
, IDS_DRIVE_NO_C
), SW_NORMAL
);
320 ShowWindow(GetDlgItem(dialog
, IDS_DRIVE_NO_C
), SW_HIDE
);
322 lv_set_curr_select(dialog
, prevsel
== -1 ? 0 : prevsel
);
328 static void on_options_click(HWND dialog
)
330 if (IsDlgButtonChecked(dialog
, IDC_SHOW_DOT_FILES
) == BST_CHECKED
)
331 set_reg_key(config_key
, "", "ShowDotFiles", "Y");
333 set_reg_key(config_key
, "", "ShowDotFiles", "N");
336 static void on_add_click(HWND dialog
)
338 /* we should allocate a drive letter automatically. We also need
339 some way to let the user choose the mapping point, for now we
340 will just force them to enter a path automatically, with / being
341 the default. In future we should be able to temporarily map /
342 then invoke the directory chooser dialog. */
344 char new = 'C'; /* we skip A and B, they are historically floppy drives */
345 long mask
= ~drive_available_mask(0); /* the mask is now which drives aren't available */
348 while (mask
& (1 << (new - 'A')))
353 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
);
358 WINE_TRACE("allocating drive letter %c\n", new);
360 if (new == 'C') add_drive(new, "../drive_c", "System Drive", "", DRIVE_FIXED
);
361 else add_drive(new, "/", "", "", DRIVE_UNKNOWN
);
363 fill_drives_list(dialog
);
365 /* select the newly created drive */
366 mask
= ~drive_available_mask(0);
368 for (i
= 0; i
< 26; i
++)
370 if ('A' + i
== new) break;
371 if ((1 << i
) & mask
) c
++;
373 lv_set_curr_select(dialog
, c
);
375 SetFocus(GetDlgItem(dialog
, IDC_LIST_DRIVES
));
377 update_controls(dialog
);
380 static void on_remove_click(HWND dialog
)
386 itemIndex
= lv_get_curr_select(dialog
);
387 if (itemIndex
== -1) return; /* no selection */
389 memset(&item
, 0, sizeof(item
));
390 item
.mask
= LVIF_PARAM
;
391 item
.iItem
= itemIndex
;
394 lv_get_item(dialog
, &item
);
396 drive
= (struct drive
*) item
.lParam
;
398 WINE_ERR("unixpath: %s\n", drive
->unixpath
);
400 if (drive
->letter
== 'C')
402 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
);
403 if (result
== IDNO
) return;
408 fill_drives_list(dialog
);
410 itemIndex
= itemIndex
- 1;
411 if (itemIndex
< 0) itemIndex
= 0;
412 lv_set_curr_select(dialog
, itemIndex
); /* previous item */
414 SetFocus(GetDlgItem(dialog
, IDC_LIST_DRIVES
));
416 update_controls(dialog
);
419 static void update_controls(HWND dialog
)
426 int i
, selection
= -1;
431 i
= lv_get_curr_select(dialog
);
434 /* no selection? let's select something for the user. this will re-enter */
435 lv_set_curr_select(dialog
, i
);
439 memset(&item
, 0, sizeof(item
));
440 item
.mask
= LVIF_PARAM
;
444 lv_get_item(dialog
, &item
);
445 current_drive
= (struct drive
*) item
.lParam
;
447 WINE_TRACE("Updating sheet for drive %c\n", current_drive
->letter
);
450 fill_drive_droplist(drive_available_mask(current_drive
->letter
), current_drive
->letter
, dialog
);
453 path
= current_drive
->unixpath
;
454 WINE_TRACE("set path control text to '%s'\n", path
);
455 set_text(dialog
, IDC_EDIT_PATH
, path
);
458 type
= current_drive
->type
;
459 SendDlgItemMessage(dialog
, IDC_COMBO_TYPE
, CB_RESETCONTENT
, 0, 0);
461 for (i
= 0; i
< sizeof(type_pairs
) / sizeof(struct drive_typemap
); i
++)
463 SendDlgItemMessage(dialog
, IDC_COMBO_TYPE
, CB_ADDSTRING
, 0, (LPARAM
) type_pairs
[i
].sDesc
);
465 if (type_pairs
[i
].sCode
== type
)
471 if (selection
== -1) selection
= DRIVE_TYPE_DEFAULT
;
472 SendDlgItemMessage(dialog
, IDC_COMBO_TYPE
, CB_SETCURSEL
, selection
, 0);
474 /* removeable media properties */
475 label
= current_drive
->label
;
476 set_text(dialog
, IDC_EDIT_LABEL
, label
);
478 /* set serial edit text */
479 serial
= current_drive
->serial
;
480 set_text(dialog
, IDC_EDIT_SERIAL
, serial
);
482 /* TODO: get the device here to put into the edit box */
483 device
= "Not implemented yet";
484 set_text(dialog
, IDC_EDIT_DEVICE
, device
);
487 selection
= IDC_RADIO_ASSIGN
;
488 if ((type
== DRIVE_CDROM
) || (type
== DRIVE_REMOVABLE
))
492 selection
= IDC_RADIO_AUTODETECT
;
493 enable_labelserial_box(dialog
, BOX_MODE_CD_AUTODETECT
);
497 selection
= IDC_RADIO_ASSIGN
;
498 enable_labelserial_box(dialog
, BOX_MODE_CD_ASSIGN
);
503 enable_labelserial_box(dialog
, BOX_MODE_NORMAL
);
504 selection
= IDC_RADIO_ASSIGN
;
507 CheckRadioButton(dialog
, IDC_RADIO_AUTODETECT
, IDC_RADIO_ASSIGN
, selection
);
514 static void on_edit_changed(HWND dialog
, WORD id
)
516 if (updating_ui
) return;
518 WINE_TRACE("edit id %d changed\n", id
);
526 label
= get_text(dialog
, id
);
527 HeapFree(GetProcessHeap(), 0, current_drive
->label
);
528 current_drive
->label
= label
? label
: strdupA("");
530 WINE_TRACE("set label to %s\n", current_drive
->label
);
532 /* enable the apply button */
533 SendMessage(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
541 path
= get_text(dialog
, id
);
542 HeapFree(GetProcessHeap(), 0, current_drive
->unixpath
);
543 current_drive
->unixpath
= path
? path
: strdupA("drive_c");
545 WINE_TRACE("set path to %s\n", current_drive
->unixpath
);
547 lv_set_item_text(dialog
, lv_get_curr_select(dialog
), 1,
548 current_drive
->unixpath
);
550 /* enable the apply button */
551 SendMessage(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
555 case IDC_EDIT_SERIAL
:
559 serial
= get_text(dialog
, id
);
560 HeapFree(GetProcessHeap(), 0, current_drive
->serial
);
561 current_drive
->serial
= serial
? serial
: strdupA("");
563 WINE_TRACE("set serial to %s", current_drive
->serial
);
565 /* enable the apply button */
566 SendMessage(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
570 case IDC_EDIT_DEVICE
:
572 char *device
= get_text(dialog
, id
);
573 /* TODO: handle device if/when it makes sense to do so.... */
574 HeapFree(GetProcessHeap(), 0, device
);
580 static void get_etched_rect(HWND dialog
, RECT
*rect
)
582 GetClientRect(dialog
, rect
);
584 /* these dimensions from the labelserial static in En.rc */
591 /* this just draws a nice line to separate the advanced gui from the n00b gui :) */
592 static void paint(HWND dialog
)
596 BeginPaint(dialog
, &ps
);
602 get_etched_rect(dialog
, &rect
);
604 DrawEdge(ps
.hdc
, &rect
, EDGE_ETCHED
, BF_TOP
);
607 EndPaint(dialog
, &ps
);
610 static void browse_for_folder(HWND dialog
)
612 static WCHAR wszUnixRootDisplayName
[] =
613 { ':',':','{','C','C','7','0','2','E','B','2','-','7','D','C','5','-','1','1','D','9','-',
614 'C','6','8','7','-','0','0','0','4','2','3','8','A','0','1','C','D','}', 0 };
615 char pszChoosePath
[256];
626 IShellFolder
*pDesktop
;
627 LPITEMIDLIST pidlUnixRoot
, pidlSelectedPath
;
630 LoadString(GetModuleHandle(NULL
), IDS_CHOOSE_PATH
, pszChoosePath
, 256);
632 hr
= SHGetDesktopFolder(&pDesktop
);
633 if (!SUCCEEDED(hr
)) return;
635 hr
= IShellFolder_ParseDisplayName(pDesktop
, NULL
, NULL
, wszUnixRootDisplayName
, NULL
,
636 &pidlUnixRoot
, NULL
);
637 if (!SUCCEEDED(hr
)) {
638 IShellFolder_Release(pDesktop
);
642 bi
.pidlRoot
= pidlUnixRoot
;
643 pidlSelectedPath
= SHBrowseForFolderA(&bi
);
644 SHFree(pidlUnixRoot
);
646 if (pidlSelectedPath
) {
647 STRRET strSelectedPath
;
648 char *pszSelectedPath
;
651 hr
= IShellFolder_GetDisplayNameOf(pDesktop
, pidlSelectedPath
, SHGDN_FORPARSING
,
653 IShellFolder_Release(pDesktop
);
654 if (!SUCCEEDED(hr
)) {
655 SHFree(pidlSelectedPath
);
659 hr
= StrRetToStr(&strSelectedPath
, pidlSelectedPath
, &pszSelectedPath
);
660 SHFree(pidlSelectedPath
);
661 if (!SUCCEEDED(hr
)) return;
663 HeapFree(GetProcessHeap(), 0, current_drive
->unixpath
);
664 current_drive
->unixpath
= strdupA(pszSelectedPath
);
665 fill_drives_list(dialog
);
666 update_controls(dialog
);
668 CoTaskMemFree(pszSelectedPath
);
672 static void init_listview_columns(HWND dialog
)
678 GetClientRect(GetDlgItem(dialog
, IDC_LIST_DRIVES
), &viewRect
);
679 width
= (viewRect
.right
- viewRect
.left
) / 6 - 5;
681 listColumn
.mask
= LVCF_TEXT
| LVCF_WIDTH
| LVCF_SUBITEM
;
682 listColumn
.pszText
= (char*) "Letter";
683 listColumn
.cchTextMax
= lstrlen(listColumn
.pszText
);
684 listColumn
.cx
= width
;
686 SendDlgItemMessage(dialog
, IDC_LIST_DRIVES
, LVM_INSERTCOLUMN
, 0, (LPARAM
) &listColumn
);
688 listColumn
.cx
= viewRect
.right
- viewRect
.left
- width
;
689 listColumn
.pszText
= (char*) "Drive Mapping";
690 listColumn
.cchTextMax
= lstrlen(listColumn
.pszText
);
692 SendDlgItemMessage(dialog
, IDC_LIST_DRIVES
, LVM_INSERTCOLUMN
, 1, (LPARAM
) &listColumn
);
695 static void load_drive_options(HWND dialog
)
697 if (!strcmp(get_reg_key(config_key
, "", "ShowDotFiles", "N"), "Y"))
698 CheckDlgButton(dialog
, IDC_SHOW_DOT_FILES
, BST_CHECKED
);
702 DriveDlgProc (HWND dialog
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
710 init_listview_columns(dialog
);
712 load_drive_options(dialog
);
714 if (!drives
[2].in_use
)
715 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
);
717 fill_drives_list(dialog
);
718 update_controls(dialog
);
719 /* put in non-advanced mode by default */
720 set_advanced(dialog
);
724 set_window_title(dialog
);
732 switch (HIWORD(wParam
))
735 on_edit_changed(dialog
, LOWORD(wParam
));
739 SendMessage(GetParent(dialog
), PSM_CHANGED
, 0, 0);
741 switch (LOWORD(wParam
))
743 case IDC_SHOW_DOT_FILES
:
744 on_options_click(dialog
);
750 SendMessage(GetParent(dialog
), PSM_CHANGED
, 0, 0);
754 switch (LOWORD(wParam
))
757 if (HIWORD(wParam
) != BN_CLICKED
) break;
758 on_add_click(dialog
);
761 case IDC_BUTTON_REMOVE
:
762 if (HIWORD(wParam
) != BN_CLICKED
) break;
763 on_remove_click(dialog
);
766 case IDC_BUTTON_EDIT
:
767 if (HIWORD(wParam
) != BN_CLICKED
) break;
768 item
= SendMessage(GetDlgItem(dialog
, IDC_LIST_DRIVES
), LB_GETCURSEL
, 0, 0);
769 drive
= (struct drive
*) SendMessage(GetDlgItem(dialog
, IDC_LIST_DRIVES
), LB_GETITEMDATA
, item
, 0);
770 /*DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT), NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) drive); */
773 case IDC_BUTTON_AUTODETECT
:
775 fill_drives_list(dialog
);
778 case IDC_BUTTON_SHOW_HIDE_ADVANCED
:
779 advanced
= !advanced
;
780 set_advanced(dialog
);
783 case IDC_BUTTON_BROWSE_PATH
:
784 browse_for_folder(dialog
);
787 case IDC_RADIO_ASSIGN
:
791 str
= get_text(dialog
, IDC_EDIT_LABEL
);
792 HeapFree(GetProcessHeap(), 0, current_drive
->label
);
793 current_drive
->label
= str
? str
: strdupA("");
795 str
= get_text(dialog
, IDC_EDIT_SERIAL
);
796 HeapFree(GetProcessHeap(), 0, current_drive
->serial
);
797 current_drive
->serial
= str
? str
: strdupA("");
799 /* TODO: we don't have a device at this point */
801 enable_labelserial_box(dialog
, BOX_MODE_CD_ASSIGN
);
809 int mode
= BOX_MODE_NORMAL
;
812 if (HIWORD(wParam
) != CBN_SELCHANGE
) break;
814 selection
= SendDlgItemMessage(dialog
, IDC_COMBO_TYPE
, CB_GETCURSEL
, 0, 0);
816 if (selection
>= 0 &&
817 (type_pairs
[selection
].sCode
== DRIVE_CDROM
||
818 type_pairs
[selection
].sCode
== DRIVE_REMOVABLE
))
820 if (IsDlgButtonChecked(dialog
, IDC_RADIO_AUTODETECT
))
821 mode
= BOX_MODE_CD_AUTODETECT
;
823 mode
= BOX_MODE_CD_ASSIGN
;
826 enable_labelserial_box(dialog
, mode
);
828 current_drive
->type
= type_pairs
[selection
].sCode
;
836 switch (((LPNMHDR
)lParam
)->code
)
839 WINE_TRACE("PSN_KILLACTIVE\n");
840 SetWindowLongPtr(dialog
, DWLP_MSGRESULT
, FALSE
);
843 apply_drive_changes();
844 SetWindowLongPtr(dialog
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
848 case LVN_ITEMCHANGED
:
850 LPNMLISTVIEW lpnm
= (LPNMLISTVIEW
)lParam
;
851 if (!(lpnm
->uOldState
& LVIS_SELECTED
) &&
852 (lpnm
->uNewState
& LVIS_SELECTED
))
853 update_controls(dialog
);