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
26 #define WIN32_LEAN_AND_MEAN
36 #include <wine/unicode.h>
37 #include <wine/debug.h>
42 WINE_DEFAULT_DEBUG_CHANNEL(winecfg
);
44 #define BOX_MODE_DEVICE 1
45 #define BOX_MODE_NORMAL 2
47 static BOOL advanced
= FALSE
;
48 static BOOL updating_ui
= FALSE
;
49 static struct drive
* current_drive
;
51 static void update_controls(HWND dialog
);
53 static DWORD
driveui_msgbox (HWND parent
, UINT messageId
, DWORD flags
)
55 WCHAR
* caption
= load_string (IDS_WINECFG_TITLE
);
56 WCHAR
* text
= load_string (messageId
);
57 DWORD result
= MessageBoxW (parent
, text
, caption
, flags
);
58 HeapFree (GetProcessHeap(), 0, caption
);
59 HeapFree (GetProcessHeap(), 0, text
);
63 /**** listview helper functions ****/
65 /* clears the item at index in the listview */
66 static void lv_clear_curr_select(HWND dialog
, int index
)
70 item
.mask
= LVIF_STATE
;
72 item
.stateMask
= LVIS_SELECTED
;
73 SendDlgItemMessageW( dialog
, IDC_LIST_DRIVES
, LVM_SETITEMSTATE
, index
, (LPARAM
)&item
);
76 /* selects the item at index in the listview */
77 static void lv_set_curr_select(HWND dialog
, int index
)
81 /* no more than one item can be selected in our listview */
82 lv_clear_curr_select(dialog
, -1);
83 item
.mask
= LVIF_STATE
;
84 item
.state
= LVIS_SELECTED
;
85 item
.stateMask
= LVIS_SELECTED
;
86 SendDlgItemMessageW( dialog
, IDC_LIST_DRIVES
, LVM_SETITEMSTATE
, index
, (LPARAM
)&item
);
89 /* returns the currently selected item in the listview */
90 static int lv_get_curr_select(HWND dialog
)
92 return SendDlgItemMessageW(dialog
, IDC_LIST_DRIVES
, LVM_GETNEXTITEM
, -1, LVNI_SELECTED
);
95 /* sets the item in the listview at item->iIndex */
96 static void lv_set_item(HWND dialog
, LVITEMW
*item
)
98 SendDlgItemMessageW(dialog
, IDC_LIST_DRIVES
, LVM_SETITEMW
, 0, (LPARAM
) item
);
101 /* sets specified item's text */
102 static void lv_set_item_text(HWND dialog
, int item
, int subItem
, WCHAR
*text
)
105 if (item
< 0 || subItem
< 0) return;
106 lvItem
.mask
= LVIF_TEXT
;
108 lvItem
.iSubItem
= subItem
;
109 lvItem
.pszText
= text
;
110 lvItem
.cchTextMax
= lstrlenW(lvItem
.pszText
);
111 lv_set_item(dialog
, &lvItem
);
114 /* inserts an item into the listview */
115 static void lv_insert_item(HWND dialog
, LVITEMW
*item
)
117 SendDlgItemMessageW(dialog
, IDC_LIST_DRIVES
, LVM_INSERTITEMW
, 0, (LPARAM
) item
);
120 /* retrieve the item at index item->iIndex */
121 static void lv_get_item(HWND dialog
, LVITEMW
*item
)
123 SendDlgItemMessageW(dialog
, IDC_LIST_DRIVES
, LVM_GETITEMW
, 0, (LPARAM
) item
);
126 static void set_advanced(HWND dialog
)
134 LoadStringW(GetModuleHandleW(NULL
), IDS_HIDE_ADVANCED
, text
, 256);
139 LoadStringW(GetModuleHandleW(NULL
), IDS_SHOW_ADVANCED
, text
, 256);
142 ShowWindow(GetDlgItem(dialog
, IDC_EDIT_DEVICE
), state
);
143 ShowWindow(GetDlgItem(dialog
, IDC_STATIC_DEVICE
), state
);
144 ShowWindow(GetDlgItem(dialog
, IDC_EDIT_LABEL
), state
);
145 ShowWindow(GetDlgItem(dialog
, IDC_STATIC_LABEL
), state
);
146 ShowWindow(GetDlgItem(dialog
, IDC_BUTTON_BROWSE_DEVICE
), state
);
147 ShowWindow(GetDlgItem(dialog
, IDC_EDIT_SERIAL
), state
);
148 ShowWindow(GetDlgItem(dialog
, IDC_STATIC_SERIAL
), state
);
149 ShowWindow(GetDlgItem(dialog
, IDC_COMBO_TYPE
), state
);
150 ShowWindow(GetDlgItem(dialog
, IDC_STATIC_TYPE
), state
);
152 /* update the button text based on the state */
153 SetWindowTextW(GetDlgItem(dialog
, IDC_BUTTON_SHOW_HIDE_ADVANCED
), text
);
156 struct drive_typemap
{
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 enable_labelserial_box(HWND dialog
, int mode
)
173 WINE_TRACE("mode=%d\n", mode
);
177 case BOX_MODE_DEVICE
:
178 /* FIXME: enable device editing */
179 disable(IDC_EDIT_DEVICE
);
180 disable(IDC_BUTTON_BROWSE_DEVICE
);
181 disable(IDC_EDIT_SERIAL
);
182 disable(IDC_EDIT_LABEL
);
185 case BOX_MODE_NORMAL
:
186 disable(IDC_EDIT_DEVICE
);
187 disable(IDC_BUTTON_BROWSE_DEVICE
);
188 enable(IDC_EDIT_SERIAL
);
189 enable(IDC_EDIT_LABEL
);
194 static int fill_drives_list(HWND dialog
)
197 BOOL drivec_present
= FALSE
;
205 prevsel
= lv_get_curr_select(dialog
);
207 /* Clear the listbox */
208 SendDlgItemMessageW(dialog
, IDC_LIST_DRIVES
, LVM_DELETEALLITEMS
, 0, 0);
210 for(i
= 0; i
< 26; i
++)
216 /* skip over any unused drives */
217 if (!drives
[i
].in_use
)
220 if (drives
[i
].letter
== 'C')
221 drivec_present
= TRUE
;
227 item
.mask
= LVIF_TEXT
| LVIF_PARAM
;
230 item
.pszText
= strdupU2W(letter
);
231 item
.cchTextMax
= lstrlenW(item
.pszText
);
232 item
.lParam
= (LPARAM
) &drives
[i
];
234 lv_insert_item(dialog
, &item
);
235 HeapFree(GetProcessHeap(), 0, item
.pszText
);
237 path
= strdupU2W(drives
[i
].unixpath
);
238 lv_set_item_text(dialog
, count
, 1, path
);
239 HeapFree(GetProcessHeap(), 0, path
);
244 WINE_TRACE("loaded %d drives\n", count
);
246 /* show the warning if there is no Drive C */
248 ShowWindow(GetDlgItem(dialog
, IDS_DRIVE_NO_C
), SW_NORMAL
);
250 ShowWindow(GetDlgItem(dialog
, IDS_DRIVE_NO_C
), SW_HIDE
);
252 lv_set_curr_select(dialog
, prevsel
== -1 ? 0 : prevsel
);
258 static void on_options_click(HWND dialog
)
260 if (IsDlgButtonChecked(dialog
, IDC_SHOW_DOT_FILES
) == BST_CHECKED
)
261 set_reg_key(config_key
, "", "ShowDotFiles", "Y");
263 set_reg_key(config_key
, "", "ShowDotFiles", "N");
265 SendMessageW(GetParent(dialog
), PSM_CHANGED
, 0, 0);
268 static INT_PTR CALLBACK
drivechoose_dlgproc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
278 ULONG mask
= ~drive_available_mask(0); /* the mask is now which drives aren't available */
279 for( c
= 'A'; c
<= 'Z'; c
++){
281 if(!( mask
& (1 << (c
- 'A'))))
282 SendDlgItemMessageA( hwndDlg
, IDC_DRIVESA2Z
, CB_ADDSTRING
, 0, (LPARAM
) drive
);
285 SendDlgItemMessageA( hwndDlg
, IDC_DRIVESA2Z
, CB_SELECTSTRING
, 0, (LPARAM
) drive
);
289 if(HIWORD(wParam
) != BN_CLICKED
) break;
290 switch (LOWORD(wParam
))
293 i
= SendDlgItemMessageA( hwndDlg
, IDC_DRIVESA2Z
, CB_GETCURSEL
, 0, 0);
295 SendDlgItemMessageA( hwndDlg
, IDC_DRIVESA2Z
, CB_GETLBTEXT
, i
, (LPARAM
) drive
);
299 EndDialog(hwndDlg
, sel
);
302 EndDialog(hwndDlg
, -1);
309 static void on_add_click(HWND dialog
)
311 /* we should allocate a drive letter automatically. We also need
312 some way to let the user choose the mapping point, for now we
313 will just force them to enter a path automatically, with / being
314 the default. In future we should be able to temporarily map /
315 then invoke the directory chooser dialog. */
317 char new = 'C'; /* we skip A and B, they are historically floppy drives */
318 ULONG mask
= ~drive_available_mask(0); /* the mask is now which drives aren't available */
322 while (mask
& (1 << (new - 'A')))
327 driveui_msgbox (dialog
, IDS_DRIVE_LETTERS_EXCEEDED
, MB_OK
| MB_ICONEXCLAMATION
);
333 ret
= DialogBoxParamW(0, MAKEINTRESOURCEW(IDD_DRIVECHOOSE
), dialog
, drivechoose_dlgproc
, new);
335 if( ret
== -1) return;
338 WINE_TRACE("selected drive letter %c\n", new);
343 LoadStringW (GetModuleHandleW(NULL
), IDS_SYSTEM_DRIVE_LABEL
, label
,
344 sizeof(label
)/sizeof(label
[0]));
345 add_drive(new, "../drive_c", NULL
, label
, 0, DRIVE_FIXED
);
347 else add_drive(new, "/", NULL
, NULL
, 0, DRIVE_UNKNOWN
);
349 fill_drives_list(dialog
);
351 /* select the newly created drive */
352 mask
= ~drive_available_mask(0);
354 for (i
= 0; i
< 26; i
++)
356 if ('A' + i
== new) break;
357 if ((1 << i
) & mask
) c
++;
359 lv_set_curr_select(dialog
, c
);
361 SetFocus(GetDlgItem(dialog
, IDC_LIST_DRIVES
));
363 update_controls(dialog
);
364 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
367 static void on_remove_click(HWND dialog
)
373 itemIndex
= lv_get_curr_select(dialog
);
374 if (itemIndex
== -1) return; /* no selection */
376 item
.mask
= LVIF_PARAM
;
377 item
.iItem
= itemIndex
;
380 lv_get_item(dialog
, &item
);
382 drive
= (struct drive
*) item
.lParam
;
384 WINE_TRACE("unixpath: %s\n", drive
->unixpath
);
386 if (drive
->letter
== 'C')
388 DWORD result
= driveui_msgbox (dialog
, IDS_CONFIRM_DELETE_C
, MB_YESNO
| MB_ICONEXCLAMATION
);
389 if (result
== IDNO
) return;
394 fill_drives_list(dialog
);
396 itemIndex
= itemIndex
- 1;
397 if (itemIndex
< 0) itemIndex
= 0;
398 lv_set_curr_select(dialog
, itemIndex
); /* previous item */
400 SetFocus(GetDlgItem(dialog
, IDC_LIST_DRIVES
));
402 update_controls(dialog
);
403 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
406 static void update_controls(HWND dialog
)
408 static const WCHAR emptyW
[1];
412 int i
, selection
= -1;
417 i
= lv_get_curr_select(dialog
);
420 /* no selection? let's select something for the user. this will re-enter */
421 lv_set_curr_select(dialog
, i
);
425 item
.mask
= LVIF_PARAM
;
429 lv_get_item(dialog
, &item
);
430 current_drive
= (struct drive
*) item
.lParam
;
432 WINE_TRACE("Updating sheet for drive %c\n", current_drive
->letter
);
435 WINE_TRACE("set path control text to '%s'\n", current_drive
->unixpath
);
436 path
= strdupU2W(current_drive
->unixpath
);
437 set_textW(dialog
, IDC_EDIT_PATH
, path
);
438 HeapFree(GetProcessHeap(), 0, path
);
441 type
= current_drive
->type
;
442 SendDlgItemMessageW(dialog
, IDC_COMBO_TYPE
, CB_RESETCONTENT
, 0, 0);
444 for (i
= 0; i
< sizeof(type_pairs
) / sizeof(struct drive_typemap
); i
++)
447 LoadStringW (GetModuleHandleW(NULL
), type_pairs
[i
].idDesc
, driveDesc
,
448 sizeof(driveDesc
)/sizeof(driveDesc
[0]));
449 SendDlgItemMessageW (dialog
, IDC_COMBO_TYPE
, CB_ADDSTRING
, 0, (LPARAM
)driveDesc
);
451 if (type_pairs
[i
].sCode
== type
)
457 if (selection
== -1) selection
= DRIVE_TYPE_DEFAULT
;
458 SendDlgItemMessageW(dialog
, IDC_COMBO_TYPE
, CB_SETCURSEL
, selection
, 0);
460 EnableWindow( GetDlgItem( dialog
, IDC_BUTTON_REMOVE
), (current_drive
->letter
!= 'C') );
461 EnableWindow( GetDlgItem( dialog
, IDC_EDIT_PATH
), (current_drive
->letter
!= 'C') );
462 EnableWindow( GetDlgItem( dialog
, IDC_BUTTON_BROWSE_PATH
), (current_drive
->letter
!= 'C') );
463 EnableWindow( GetDlgItem( dialog
, IDC_COMBO_TYPE
), (current_drive
->letter
!= 'C') );
465 /* removable media properties */
466 set_textW(dialog
, IDC_EDIT_LABEL
, current_drive
->label
? current_drive
->label
: emptyW
);
468 /* set serial edit text */
469 sprintf( serial
, "%X", current_drive
->serial
);
470 set_text(dialog
, IDC_EDIT_SERIAL
, serial
);
472 set_text(dialog
, IDC_EDIT_DEVICE
, current_drive
->device
);
474 if ((type
== DRIVE_CDROM
) || (type
== DRIVE_REMOVABLE
))
475 enable_labelserial_box(dialog
, BOX_MODE_DEVICE
);
477 enable_labelserial_box(dialog
, BOX_MODE_NORMAL
);
484 static void on_edit_changed(HWND dialog
, WORD id
)
486 if (updating_ui
) return;
488 WINE_TRACE("edit id %d changed\n", id
);
494 WCHAR
*label
= get_textW(dialog
, id
);
495 HeapFree(GetProcessHeap(), 0, current_drive
->label
);
496 current_drive
->label
= label
;
497 current_drive
->modified
= TRUE
;
499 WINE_TRACE("set label to %s\n", wine_dbgstr_w(current_drive
->label
));
501 /* enable the apply button */
502 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
512 wpath
= get_textW(dialog
, id
);
513 if( (lenW
= WideCharToMultiByte(CP_UNIXCP
, 0, wpath
, -1, NULL
, 0, NULL
, NULL
)) )
515 path
= HeapAlloc(GetProcessHeap(), 0, lenW
);
516 WideCharToMultiByte(CP_UNIXCP
, 0, wpath
, -1, path
, lenW
, NULL
, NULL
);
521 wpath
= strdupU2W("drive_c");
524 HeapFree(GetProcessHeap(), 0, current_drive
->unixpath
);
525 current_drive
->unixpath
= path
? path
: strdupA("drive_c");
526 current_drive
->modified
= TRUE
;
528 WINE_TRACE("set path to %s\n", current_drive
->unixpath
);
530 lv_set_item_text(dialog
, lv_get_curr_select(dialog
), 1,
532 HeapFree(GetProcessHeap(), 0, wpath
);
534 /* enable the apply button */
535 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
539 case IDC_EDIT_SERIAL
:
543 serial
= get_text(dialog
, id
);
544 current_drive
->serial
= serial
? strtoul( serial
, NULL
, 16 ) : 0;
545 HeapFree(GetProcessHeap(), 0, serial
);
546 current_drive
->modified
= TRUE
;
548 WINE_TRACE("set serial to %08X\n", current_drive
->serial
);
550 /* enable the apply button */
551 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
555 case IDC_EDIT_DEVICE
:
557 char *device
= get_text(dialog
, id
);
558 /* TODO: handle device if/when it makes sense to do so.... */
559 HeapFree(GetProcessHeap(), 0, device
);
565 BOOL
browse_for_unix_folder(HWND dialog
, WCHAR
*pszPath
)
567 static WCHAR wszUnixRootDisplayName
[] =
568 { ':',':','{','C','C','7','0','2','E','B','2','-','7','D','C','5','-','1','1','D','9','-',
569 'C','6','8','7','-','0','0','0','4','2','3','8','A','0','1','C','D','}', 0 };
570 WCHAR pszChoosePath
[FILENAME_MAX
];
581 IShellFolder
*pDesktop
;
582 LPITEMIDLIST pidlUnixRoot
, pidlSelectedPath
;
585 LoadStringW(GetModuleHandleW(NULL
), IDS_CHOOSE_PATH
, pszChoosePath
, FILENAME_MAX
);
587 hr
= SHGetDesktopFolder(&pDesktop
);
588 if (FAILED(hr
)) return FALSE
;
590 hr
= IShellFolder_ParseDisplayName(pDesktop
, NULL
, NULL
, wszUnixRootDisplayName
, NULL
,
591 &pidlUnixRoot
, NULL
);
593 IShellFolder_Release(pDesktop
);
597 bi
.pidlRoot
= pidlUnixRoot
;
598 pidlSelectedPath
= SHBrowseForFolderW(&bi
);
599 SHFree(pidlUnixRoot
);
601 if (pidlSelectedPath
) {
602 STRRET strSelectedPath
;
603 WCHAR
*pszSelectedPath
;
606 hr
= IShellFolder_GetDisplayNameOf(pDesktop
, pidlSelectedPath
, SHGDN_FORPARSING
,
608 IShellFolder_Release(pDesktop
);
610 SHFree(pidlSelectedPath
);
614 hr
= StrRetToStrW(&strSelectedPath
, pidlSelectedPath
, &pszSelectedPath
);
615 SHFree(pidlSelectedPath
);
616 if (FAILED(hr
)) return FALSE
;
618 lstrcpyW(pszPath
, pszSelectedPath
);
620 CoTaskMemFree(pszSelectedPath
);
626 static void init_listview_columns(HWND dialog
)
628 LVCOLUMNW listColumn
;
633 GetClientRect(GetDlgItem(dialog
, IDC_LIST_DRIVES
), &viewRect
);
634 width
= (viewRect
.right
- viewRect
.left
) / 6 - 5;
636 LoadStringW (GetModuleHandleW(NULL
), IDS_COL_DRIVELETTER
, column
,
637 sizeof(column
)/sizeof(column
[0]));
638 listColumn
.mask
= LVCF_TEXT
| LVCF_WIDTH
| LVCF_SUBITEM
;
639 listColumn
.pszText
= column
;
640 listColumn
.cchTextMax
= lstrlenW (listColumn
.pszText
);
641 listColumn
.cx
= width
;
643 SendDlgItemMessageW (dialog
, IDC_LIST_DRIVES
, LVM_INSERTCOLUMNW
, 0, (LPARAM
) &listColumn
);
645 LoadStringW (GetModuleHandleW(NULL
), IDS_COL_DRIVEMAPPING
, column
,
646 sizeof(column
)/sizeof(column
[0]));
647 listColumn
.cx
= viewRect
.right
- viewRect
.left
- width
;
648 listColumn
.pszText
= column
;
649 listColumn
.cchTextMax
= lstrlenW (listColumn
.pszText
);
651 SendDlgItemMessageW (dialog
, IDC_LIST_DRIVES
, LVM_INSERTCOLUMNW
, 1, (LPARAM
) &listColumn
);
654 static void load_drive_options(HWND dialog
)
656 if (!strcmp(get_reg_key(config_key
, "", "ShowDotFiles", "N"), "Y"))
657 CheckDlgButton(dialog
, IDC_SHOW_DOT_FILES
, BST_CHECKED
);
661 DriveDlgProc (HWND dialog
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
668 init_listview_columns(dialog
);
671 ShowWindow( GetDlgItem( dialog
, IDC_STATIC_MOUNTMGR_ERROR
), SW_SHOW
);
672 ShowWindow( GetDlgItem( dialog
, IDC_LIST_DRIVES
), SW_HIDE
);
673 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_ADD
), SW_HIDE
);
674 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_REMOVE
), SW_HIDE
);
675 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_AUTODETECT
), SW_HIDE
);
676 ShowWindow( GetDlgItem( dialog
, IDC_STATIC_PATH
), SW_HIDE
);
677 ShowWindow( GetDlgItem( dialog
, IDC_EDIT_PATH
), SW_HIDE
);
678 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_BROWSE_PATH
), SW_HIDE
);
679 ShowWindow( GetDlgItem( dialog
, IDC_COMBO_TYPE
), SW_HIDE
);
680 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_SHOW_HIDE_ADVANCED
), SW_HIDE
);
681 set_advanced(dialog
);
684 ShowWindow( GetDlgItem( dialog
, IDC_STATIC_MOUNTMGR_ERROR
), SW_HIDE
);
685 load_drive_options(dialog
);
687 if (!drives
[2].in_use
)
688 driveui_msgbox (dialog
, IDS_NO_DRIVE_C
, MB_OK
| MB_ICONEXCLAMATION
);
690 fill_drives_list(dialog
);
691 update_controls(dialog
);
692 /* put in non-advanced mode by default */
693 set_advanced(dialog
);
697 set_window_title(dialog
);
701 switch (HIWORD(wParam
))
704 on_edit_changed(dialog
, LOWORD(wParam
));
708 switch (LOWORD(wParam
))
710 case IDC_SHOW_DOT_FILES
:
711 on_options_click(dialog
);
717 SendMessageW(GetParent(dialog
), PSM_CHANGED
, 0, 0);
721 switch (LOWORD(wParam
))
724 if (HIWORD(wParam
) != BN_CLICKED
) break;
725 on_add_click(dialog
);
728 case IDC_BUTTON_REMOVE
:
729 if (HIWORD(wParam
) != BN_CLICKED
) break;
730 on_remove_click(dialog
);
733 case IDC_BUTTON_EDIT
:
734 if (HIWORD(wParam
) != BN_CLICKED
) break;
735 item
= SendMessageW(GetDlgItem(dialog
, IDC_LIST_DRIVES
), LB_GETCURSEL
, 0, 0);
736 SendMessageW(GetDlgItem(dialog
, IDC_LIST_DRIVES
), LB_GETITEMDATA
, item
, 0);
739 case IDC_BUTTON_AUTODETECT
:
741 fill_drives_list(dialog
);
742 SendMessageW(GetParent(dialog
), PSM_CHANGED
, 0, 0);
745 case IDC_BUTTON_SHOW_HIDE_ADVANCED
:
746 advanced
= !advanced
;
747 set_advanced(dialog
);
750 case IDC_BUTTON_BROWSE_PATH
:
752 WCHAR szTargetPath
[FILENAME_MAX
];
753 if (browse_for_unix_folder(dialog
, szTargetPath
))
754 set_textW(dialog
, IDC_EDIT_PATH
, szTargetPath
);
760 int mode
= BOX_MODE_NORMAL
;
763 if (HIWORD(wParam
) != CBN_SELCHANGE
) break;
765 selection
= SendDlgItemMessageW(dialog
, IDC_COMBO_TYPE
, CB_GETCURSEL
, 0, 0);
767 if (selection
>= 0 &&
768 (type_pairs
[selection
].sCode
== DRIVE_CDROM
||
769 type_pairs
[selection
].sCode
== DRIVE_REMOVABLE
))
770 mode
= BOX_MODE_DEVICE
;
772 mode
= BOX_MODE_NORMAL
;
774 enable_labelserial_box(dialog
, mode
);
776 current_drive
->type
= type_pairs
[selection
].sCode
;
777 current_drive
->modified
= TRUE
;
785 switch (((LPNMHDR
)lParam
)->code
)
788 WINE_TRACE("PSN_KILLACTIVE\n");
789 SetWindowLongPtrW(dialog
, DWLP_MSGRESULT
, FALSE
);
792 apply_drive_changes();
793 SetWindowLongPtrW(dialog
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
797 case LVN_ITEMCHANGED
:
799 LPNMLISTVIEW lpnm
= (LPNMLISTVIEW
)lParam
;
800 if (!(lpnm
->uOldState
& LVIS_SELECTED
) &&
801 (lpnm
->uNewState
& LVIS_SELECTED
))
802 update_controls(dialog
);