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
, ARRAY_SIZE(label
));
344 add_drive(new, "../drive_c", NULL
, label
, 0, DRIVE_FIXED
);
346 else add_drive(new, "/", NULL
, NULL
, 0, DRIVE_UNKNOWN
);
348 fill_drives_list(dialog
);
350 /* select the newly created drive */
351 mask
= ~drive_available_mask(0);
353 for (i
= 0; i
< 26; i
++)
355 if ('A' + i
== new) break;
356 if ((1 << i
) & mask
) c
++;
358 lv_set_curr_select(dialog
, c
);
360 SetFocus(GetDlgItem(dialog
, IDC_LIST_DRIVES
));
362 update_controls(dialog
);
363 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
366 static void on_remove_click(HWND dialog
)
372 itemIndex
= lv_get_curr_select(dialog
);
373 if (itemIndex
== -1) return; /* no selection */
375 item
.mask
= LVIF_PARAM
;
376 item
.iItem
= itemIndex
;
379 lv_get_item(dialog
, &item
);
381 drive
= (struct drive
*) item
.lParam
;
383 WINE_TRACE("unixpath: %s\n", drive
->unixpath
);
385 if (drive
->letter
== 'C')
387 DWORD result
= driveui_msgbox (dialog
, IDS_CONFIRM_DELETE_C
, MB_YESNO
| MB_ICONEXCLAMATION
);
388 if (result
== IDNO
) return;
393 fill_drives_list(dialog
);
395 itemIndex
= itemIndex
- 1;
396 if (itemIndex
< 0) itemIndex
= 0;
397 lv_set_curr_select(dialog
, itemIndex
); /* previous item */
399 SetFocus(GetDlgItem(dialog
, IDC_LIST_DRIVES
));
401 update_controls(dialog
);
402 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
405 static void update_controls(HWND dialog
)
407 static const WCHAR emptyW
[1];
411 int i
, selection
= -1;
416 i
= lv_get_curr_select(dialog
);
419 /* no selection? let's select something for the user. this will re-enter */
420 lv_set_curr_select(dialog
, i
);
424 item
.mask
= LVIF_PARAM
;
428 lv_get_item(dialog
, &item
);
429 current_drive
= (struct drive
*) item
.lParam
;
431 WINE_TRACE("Updating sheet for drive %c\n", current_drive
->letter
);
434 WINE_TRACE("set path control text to '%s'\n", current_drive
->unixpath
);
435 path
= strdupU2W(current_drive
->unixpath
);
436 set_textW(dialog
, IDC_EDIT_PATH
, path
);
437 HeapFree(GetProcessHeap(), 0, path
);
440 type
= current_drive
->type
;
441 SendDlgItemMessageW(dialog
, IDC_COMBO_TYPE
, CB_RESETCONTENT
, 0, 0);
443 for (i
= 0; i
< sizeof(type_pairs
) / sizeof(struct drive_typemap
); i
++)
446 LoadStringW(GetModuleHandleW(NULL
), type_pairs
[i
].idDesc
, driveDesc
, ARRAY_SIZE(driveDesc
));
447 SendDlgItemMessageW (dialog
, IDC_COMBO_TYPE
, CB_ADDSTRING
, 0, (LPARAM
)driveDesc
);
449 if (type_pairs
[i
].sCode
== type
)
455 if (selection
== -1) selection
= DRIVE_TYPE_DEFAULT
;
456 SendDlgItemMessageW(dialog
, IDC_COMBO_TYPE
, CB_SETCURSEL
, selection
, 0);
458 EnableWindow( GetDlgItem( dialog
, IDC_BUTTON_REMOVE
), (current_drive
->letter
!= 'C') );
459 EnableWindow( GetDlgItem( dialog
, IDC_EDIT_PATH
), (current_drive
->letter
!= 'C') );
460 EnableWindow( GetDlgItem( dialog
, IDC_BUTTON_BROWSE_PATH
), (current_drive
->letter
!= 'C') );
461 EnableWindow( GetDlgItem( dialog
, IDC_COMBO_TYPE
), (current_drive
->letter
!= 'C') );
463 /* removable media properties */
464 set_textW(dialog
, IDC_EDIT_LABEL
, current_drive
->label
? current_drive
->label
: emptyW
);
466 /* set serial edit text */
467 sprintf( serial
, "%X", current_drive
->serial
);
468 set_text(dialog
, IDC_EDIT_SERIAL
, serial
);
470 set_text(dialog
, IDC_EDIT_DEVICE
, current_drive
->device
);
472 if ((type
== DRIVE_CDROM
) || (type
== DRIVE_REMOVABLE
))
473 enable_labelserial_box(dialog
, BOX_MODE_DEVICE
);
475 enable_labelserial_box(dialog
, BOX_MODE_NORMAL
);
482 static void on_edit_changed(HWND dialog
, WORD id
)
484 if (updating_ui
) return;
486 WINE_TRACE("edit id %d changed\n", id
);
492 WCHAR
*label
= get_textW(dialog
, id
);
493 HeapFree(GetProcessHeap(), 0, current_drive
->label
);
494 current_drive
->label
= label
;
495 current_drive
->modified
= TRUE
;
497 WINE_TRACE("set label to %s\n", wine_dbgstr_w(current_drive
->label
));
499 /* enable the apply button */
500 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
510 wpath
= get_textW(dialog
, id
);
511 if( (lenW
= WideCharToMultiByte(CP_UNIXCP
, 0, wpath
, -1, NULL
, 0, NULL
, NULL
)) )
513 path
= HeapAlloc(GetProcessHeap(), 0, lenW
);
514 WideCharToMultiByte(CP_UNIXCP
, 0, wpath
, -1, path
, lenW
, NULL
, NULL
);
519 wpath
= strdupU2W("drive_c");
522 HeapFree(GetProcessHeap(), 0, current_drive
->unixpath
);
523 current_drive
->unixpath
= path
? path
: strdupA("drive_c");
524 current_drive
->modified
= TRUE
;
526 WINE_TRACE("set path to %s\n", current_drive
->unixpath
);
528 lv_set_item_text(dialog
, lv_get_curr_select(dialog
), 1,
530 HeapFree(GetProcessHeap(), 0, wpath
);
532 /* enable the apply button */
533 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
537 case IDC_EDIT_SERIAL
:
541 serial
= get_text(dialog
, id
);
542 current_drive
->serial
= serial
? strtoul( serial
, NULL
, 16 ) : 0;
543 HeapFree(GetProcessHeap(), 0, serial
);
544 current_drive
->modified
= TRUE
;
546 WINE_TRACE("set serial to %08X\n", current_drive
->serial
);
548 /* enable the apply button */
549 SendMessageW(GetParent(dialog
), PSM_CHANGED
, (WPARAM
) dialog
, 0);
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
);
563 BOOL
browse_for_unix_folder(HWND dialog
, WCHAR
*pszPath
)
565 static WCHAR wszUnixRootDisplayName
[] =
566 { ':',':','{','C','C','7','0','2','E','B','2','-','7','D','C','5','-','1','1','D','9','-',
567 'C','6','8','7','-','0','0','0','4','2','3','8','A','0','1','C','D','}', 0 };
568 WCHAR pszChoosePath
[FILENAME_MAX
];
579 IShellFolder
*pDesktop
;
580 LPITEMIDLIST pidlUnixRoot
, pidlSelectedPath
;
583 LoadStringW(GetModuleHandleW(NULL
), IDS_CHOOSE_PATH
, pszChoosePath
, FILENAME_MAX
);
585 hr
= SHGetDesktopFolder(&pDesktop
);
586 if (FAILED(hr
)) return FALSE
;
588 hr
= IShellFolder_ParseDisplayName(pDesktop
, NULL
, NULL
, wszUnixRootDisplayName
, NULL
,
589 &pidlUnixRoot
, NULL
);
591 IShellFolder_Release(pDesktop
);
595 bi
.pidlRoot
= pidlUnixRoot
;
596 pidlSelectedPath
= SHBrowseForFolderW(&bi
);
597 SHFree(pidlUnixRoot
);
599 if (pidlSelectedPath
) {
600 STRRET strSelectedPath
;
601 WCHAR
*pszSelectedPath
;
604 hr
= IShellFolder_GetDisplayNameOf(pDesktop
, pidlSelectedPath
, SHGDN_FORPARSING
,
606 IShellFolder_Release(pDesktop
);
608 SHFree(pidlSelectedPath
);
612 hr
= StrRetToStrW(&strSelectedPath
, pidlSelectedPath
, &pszSelectedPath
);
613 SHFree(pidlSelectedPath
);
614 if (FAILED(hr
)) return FALSE
;
616 lstrcpyW(pszPath
, pszSelectedPath
);
618 CoTaskMemFree(pszSelectedPath
);
624 static void init_listview_columns(HWND dialog
)
626 LVCOLUMNW listColumn
;
631 GetClientRect(GetDlgItem(dialog
, IDC_LIST_DRIVES
), &viewRect
);
632 width
= (viewRect
.right
- viewRect
.left
) / 6 - 5;
634 LoadStringW(GetModuleHandleW(NULL
), IDS_COL_DRIVELETTER
, column
, ARRAY_SIZE(column
));
635 listColumn
.mask
= LVCF_TEXT
| LVCF_WIDTH
| LVCF_SUBITEM
;
636 listColumn
.pszText
= column
;
637 listColumn
.cchTextMax
= lstrlenW (listColumn
.pszText
);
638 listColumn
.cx
= width
;
640 SendDlgItemMessageW (dialog
, IDC_LIST_DRIVES
, LVM_INSERTCOLUMNW
, 0, (LPARAM
) &listColumn
);
642 LoadStringW(GetModuleHandleW(NULL
), IDS_COL_DRIVEMAPPING
, column
, ARRAY_SIZE(column
));
643 listColumn
.cx
= viewRect
.right
- viewRect
.left
- width
;
644 listColumn
.pszText
= column
;
645 listColumn
.cchTextMax
= lstrlenW (listColumn
.pszText
);
647 SendDlgItemMessageW (dialog
, IDC_LIST_DRIVES
, LVM_INSERTCOLUMNW
, 1, (LPARAM
) &listColumn
);
650 static void load_drive_options(HWND dialog
)
652 if (!strcmp(get_reg_key(config_key
, "", "ShowDotFiles", "N"), "Y"))
653 CheckDlgButton(dialog
, IDC_SHOW_DOT_FILES
, BST_CHECKED
);
657 DriveDlgProc (HWND dialog
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
664 init_listview_columns(dialog
);
667 ShowWindow( GetDlgItem( dialog
, IDC_STATIC_MOUNTMGR_ERROR
), SW_SHOW
);
668 ShowWindow( GetDlgItem( dialog
, IDC_LIST_DRIVES
), SW_HIDE
);
669 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_ADD
), SW_HIDE
);
670 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_REMOVE
), SW_HIDE
);
671 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_AUTODETECT
), SW_HIDE
);
672 ShowWindow( GetDlgItem( dialog
, IDC_STATIC_PATH
), SW_HIDE
);
673 ShowWindow( GetDlgItem( dialog
, IDC_EDIT_PATH
), SW_HIDE
);
674 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_BROWSE_PATH
), SW_HIDE
);
675 ShowWindow( GetDlgItem( dialog
, IDC_COMBO_TYPE
), SW_HIDE
);
676 ShowWindow( GetDlgItem( dialog
, IDC_BUTTON_SHOW_HIDE_ADVANCED
), SW_HIDE
);
677 set_advanced(dialog
);
680 ShowWindow( GetDlgItem( dialog
, IDC_STATIC_MOUNTMGR_ERROR
), SW_HIDE
);
681 load_drive_options(dialog
);
683 if (!drives
[2].in_use
)
684 driveui_msgbox (dialog
, IDS_NO_DRIVE_C
, MB_OK
| MB_ICONEXCLAMATION
);
686 fill_drives_list(dialog
);
687 update_controls(dialog
);
688 /* put in non-advanced mode by default */
689 set_advanced(dialog
);
693 set_window_title(dialog
);
697 switch (HIWORD(wParam
))
700 on_edit_changed(dialog
, LOWORD(wParam
));
704 switch (LOWORD(wParam
))
706 case IDC_SHOW_DOT_FILES
:
707 on_options_click(dialog
);
713 SendMessageW(GetParent(dialog
), PSM_CHANGED
, 0, 0);
717 switch (LOWORD(wParam
))
720 if (HIWORD(wParam
) != BN_CLICKED
) break;
721 on_add_click(dialog
);
724 case IDC_BUTTON_REMOVE
:
725 if (HIWORD(wParam
) != BN_CLICKED
) break;
726 on_remove_click(dialog
);
729 case IDC_BUTTON_EDIT
:
730 if (HIWORD(wParam
) != BN_CLICKED
) break;
731 item
= SendMessageW(GetDlgItem(dialog
, IDC_LIST_DRIVES
), LB_GETCURSEL
, 0, 0);
732 SendMessageW(GetDlgItem(dialog
, IDC_LIST_DRIVES
), LB_GETITEMDATA
, item
, 0);
735 case IDC_BUTTON_AUTODETECT
:
737 fill_drives_list(dialog
);
738 SendMessageW(GetParent(dialog
), PSM_CHANGED
, 0, 0);
741 case IDC_BUTTON_SHOW_HIDE_ADVANCED
:
742 advanced
= !advanced
;
743 set_advanced(dialog
);
746 case IDC_BUTTON_BROWSE_PATH
:
748 WCHAR szTargetPath
[FILENAME_MAX
];
749 if (browse_for_unix_folder(dialog
, szTargetPath
))
750 set_textW(dialog
, IDC_EDIT_PATH
, szTargetPath
);
756 int mode
= BOX_MODE_NORMAL
;
759 if (HIWORD(wParam
) != CBN_SELCHANGE
) break;
761 selection
= SendDlgItemMessageW(dialog
, IDC_COMBO_TYPE
, CB_GETCURSEL
, 0, 0);
763 if (selection
>= 0 &&
764 (type_pairs
[selection
].sCode
== DRIVE_CDROM
||
765 type_pairs
[selection
].sCode
== DRIVE_REMOVABLE
))
766 mode
= BOX_MODE_DEVICE
;
768 mode
= BOX_MODE_NORMAL
;
770 enable_labelserial_box(dialog
, mode
);
772 current_drive
->type
= type_pairs
[selection
].sCode
;
773 current_drive
->modified
= TRUE
;
781 switch (((LPNMHDR
)lParam
)->code
)
784 WINE_TRACE("PSN_KILLACTIVE\n");
785 SetWindowLongPtrW(dialog
, DWLP_MSGRESULT
, FALSE
);
788 apply_drive_changes();
789 SetWindowLongPtrW(dialog
, DWLP_MSGRESULT
, PSNRET_NOERROR
);
793 case LVN_ITEMCHANGED
:
795 LPNMLISTVIEW lpnm
= (LPNMLISTVIEW
)lParam
;
796 if (!(lpnm
->uOldState
& LVIS_SELECTED
) &&
797 (lpnm
->uNewState
& LVIS_SELECTED
))
798 update_controls(dialog
);