gdi32: Support the gamma correction for the subpixel rendering.
[wine.git] / programs / winecfg / driveui.c
blobc25e71df523ddcad3136c016dba32b0ae71fe0b7
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/unicode.h>
37 #include <wine/debug.h>
39 #include "winecfg.h"
40 #include "resource.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);
60 return result;
63 /**** listview helper functions ****/
65 /* clears the item at index in the listview */
66 static void lv_clear_curr_select(HWND dialog, int index)
68 LVITEMW item;
70 item.mask = LVIF_STATE;
71 item.state = 0;
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)
79 LVITEMW item;
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)
104 LVITEMW lvItem;
105 if (item < 0 || subItem < 0) return;
106 lvItem.mask = LVIF_TEXT;
107 lvItem.iItem = item;
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)
128 int state;
129 WCHAR text[256];
131 if (advanced)
133 state = SW_NORMAL;
134 LoadStringW(GetModuleHandleW(NULL), IDS_HIDE_ADVANCED, text, 256);
136 else
138 state = SW_HIDE;
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 {
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 enable_labelserial_box(HWND dialog, int mode)
173 WINE_TRACE("mode=%d\n", mode);
175 switch (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);
183 break;
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);
190 break;
194 static int fill_drives_list(HWND dialog)
196 int count = 0;
197 BOOL drivec_present = FALSE;
198 int i;
199 int prevsel = -1;
201 WINE_TRACE("\n");
203 updating_ui = TRUE;
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++)
212 LVITEMW item;
213 WCHAR *path;
214 char letter[4];
216 /* skip over any unused drives */
217 if (!drives[i].in_use)
218 continue;
220 if (drives[i].letter == 'C')
221 drivec_present = TRUE;
223 letter[0] = 'A' + i;
224 letter[1] = ':';
225 letter[2] = 0;
227 item.mask = LVIF_TEXT | LVIF_PARAM;
228 item.iItem = count;
229 item.iSubItem = 0;
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);
241 count++;
244 WINE_TRACE("loaded %d drives\n", count);
246 /* show the warning if there is no Drive C */
247 if (!drivec_present)
248 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_NORMAL);
249 else
250 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_HIDE);
252 lv_set_curr_select(dialog, prevsel == -1 ? 0 : prevsel);
254 updating_ui = FALSE;
255 return count;
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");
262 else
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)
270 static int i, sel;
271 char c;
272 char drive[] = "X:";
274 switch(uMsg)
276 case WM_INITDIALOG:
278 ULONG mask = ~drive_available_mask(0); /* the mask is now which drives aren't available */
279 for( c = 'A'; c<= 'Z'; c++){
280 drive[0] = c;
281 if(!( mask & (1 << (c - 'A'))))
282 SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_ADDSTRING, 0, (LPARAM) drive);
284 drive[0] = lParam;
285 SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_SELECTSTRING, 0, (LPARAM) drive);
286 return TRUE;
288 case WM_COMMAND:
289 if(HIWORD(wParam) != BN_CLICKED) break;
290 switch (LOWORD(wParam))
292 case IDOK:
293 i = SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_GETCURSEL, 0, 0);
294 if( i != CB_ERR){
295 SendDlgItemMessageA( hwndDlg, IDC_DRIVESA2Z, CB_GETLBTEXT, i, (LPARAM) drive);
296 sel = drive[0];
297 } else
298 sel = -1;
299 EndDialog(hwndDlg, sel);
300 return TRUE;
301 case IDCANCEL:
302 EndDialog(hwndDlg, -1);
303 return TRUE;
306 return FALSE;
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 */
319 int i, c;
320 INT_PTR ret;
322 while (mask & (1 << (new - 'A')))
324 new++;
325 if (new > 'Z')
327 driveui_msgbox (dialog, IDS_DRIVE_LETTERS_EXCEEDED, MB_OK | MB_ICONEXCLAMATION);
328 return;
333 ret = DialogBoxParamW(0, MAKEINTRESOURCEW(IDD_DRIVECHOOSE), dialog, drivechoose_dlgproc, new);
335 if( ret == -1) return;
336 new = ret;
338 WINE_TRACE("selected drive letter %c\n", new);
340 if (new == 'C')
342 WCHAR label[64];
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);
352 c = 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)
368 int itemIndex;
369 struct drive *drive;
370 LVITEMW item;
372 itemIndex = lv_get_curr_select(dialog);
373 if (itemIndex == -1) return; /* no selection */
375 item.mask = LVIF_PARAM;
376 item.iItem = itemIndex;
377 item.iSubItem = 0;
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;
391 delete_drive(drive);
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];
408 WCHAR *path;
409 unsigned int type;
410 char serial[16];
411 int i, selection = -1;
412 LVITEMW item;
414 updating_ui = TRUE;
416 i = lv_get_curr_select(dialog);
417 if (i == -1)
419 /* no selection? let's select something for the user. this will re-enter */
420 lv_set_curr_select(dialog, i);
421 return;
424 item.mask = LVIF_PARAM;
425 item.iItem = i;
426 item.iSubItem = 0;
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);
433 /* path */
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);
439 /* drive type */
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++)
445 WCHAR driveDesc[64];
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)
451 selection = i;
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);
474 else
475 enable_labelserial_box(dialog, BOX_MODE_NORMAL);
477 updating_ui = FALSE;
479 return;
482 static void on_edit_changed(HWND dialog, WORD id)
484 if (updating_ui) return;
486 WINE_TRACE("edit id %d changed\n", id);
488 switch (id)
490 case IDC_EDIT_LABEL:
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);
501 break;
504 case IDC_EDIT_PATH:
506 WCHAR *wpath;
507 char *path;
508 int lenW;
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);
516 else
518 path = 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,
529 wpath);
530 HeapFree(GetProcessHeap(), 0, wpath);
532 /* enable the apply button */
533 SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
534 break;
537 case IDC_EDIT_SERIAL:
539 char *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);
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 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];
569 BROWSEINFOW bi = {
570 dialog,
571 NULL,
572 NULL,
573 pszChoosePath,
575 NULL,
579 IShellFolder *pDesktop;
580 LPITEMIDLIST pidlUnixRoot, pidlSelectedPath;
581 HRESULT hr;
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);
590 if (FAILED(hr)) {
591 IShellFolder_Release(pDesktop);
592 return FALSE;
595 bi.pidlRoot = pidlUnixRoot;
596 pidlSelectedPath = SHBrowseForFolderW(&bi);
597 SHFree(pidlUnixRoot);
599 if (pidlSelectedPath) {
600 STRRET strSelectedPath;
601 WCHAR *pszSelectedPath;
602 HRESULT hr;
604 hr = IShellFolder_GetDisplayNameOf(pDesktop, pidlSelectedPath, SHGDN_FORPARSING,
605 &strSelectedPath);
606 IShellFolder_Release(pDesktop);
607 if (FAILED(hr)) {
608 SHFree(pidlSelectedPath);
609 return FALSE;
612 hr = StrRetToStrW(&strSelectedPath, pidlSelectedPath, &pszSelectedPath);
613 SHFree(pidlSelectedPath);
614 if (FAILED(hr)) return FALSE;
616 lstrcpyW(pszPath, pszSelectedPath);
618 CoTaskMemFree(pszSelectedPath);
619 return TRUE;
621 return FALSE;
624 static void init_listview_columns(HWND dialog)
626 LVCOLUMNW listColumn;
627 RECT viewRect;
628 int width;
629 WCHAR column[64];
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);
656 INT_PTR CALLBACK
657 DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
659 int item;
661 switch (msg)
663 case WM_INITDIALOG:
664 init_listview_columns(dialog);
665 if (!load_drives())
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);
678 break;
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);
690 break;
692 case WM_SHOWWINDOW:
693 set_window_title(dialog);
694 break;
696 case WM_COMMAND:
697 switch (HIWORD(wParam))
699 case EN_CHANGE:
700 on_edit_changed(dialog, LOWORD(wParam));
701 break;
703 case BN_CLICKED:
704 switch (LOWORD(wParam))
706 case IDC_SHOW_DOT_FILES:
707 on_options_click(dialog);
708 break;
710 break;
712 case CBN_SELCHANGE:
713 SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
714 break;
717 switch (LOWORD(wParam))
719 case IDC_BUTTON_ADD:
720 if (HIWORD(wParam) != BN_CLICKED) break;
721 on_add_click(dialog);
722 break;
724 case IDC_BUTTON_REMOVE:
725 if (HIWORD(wParam) != BN_CLICKED) break;
726 on_remove_click(dialog);
727 break;
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);
733 break;
735 case IDC_BUTTON_AUTODETECT:
736 autodetect_drives();
737 fill_drives_list(dialog);
738 SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
739 break;
741 case IDC_BUTTON_SHOW_HIDE_ADVANCED:
742 advanced = !advanced;
743 set_advanced(dialog);
744 break;
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);
751 break;
754 case IDC_COMBO_TYPE:
756 int mode = BOX_MODE_NORMAL;
757 int selection;
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;
767 else
768 mode = BOX_MODE_NORMAL;
770 enable_labelserial_box(dialog, mode);
772 current_drive->type = type_pairs[selection].sCode;
773 current_drive->modified = TRUE;
774 break;
778 break;
780 case WM_NOTIFY:
781 switch (((LPNMHDR)lParam)->code)
783 case PSN_KILLACTIVE:
784 WINE_TRACE("PSN_KILLACTIVE\n");
785 SetWindowLongPtrW(dialog, DWLP_MSGRESULT, FALSE);
786 break;
787 case PSN_APPLY:
788 apply_drive_changes();
789 SetWindowLongPtrW(dialog, DWLP_MSGRESULT, PSNRET_NOERROR);
790 break;
791 case PSN_SETACTIVE:
792 break;
793 case LVN_ITEMCHANGED:
795 LPNMLISTVIEW lpnm = (LPNMLISTVIEW)lParam;
796 if (!(lpnm->uOldState & LVIS_SELECTED) &&
797 (lpnm->uNewState & LVIS_SELECTED))
798 update_controls(dialog);
799 break;
802 break;
805 return FALSE;