Always reset AUTO_RESIZE flag on exit from REBAR_ForceResize.
[wine/multimedia.git] / programs / winecfg / drive.c
blob3f0d38b813ce5ae1d2888f1e9251f23127a84410
1 /*
2 * Drive management UI code
4 * Copyright 2003 Mark Westcott
5 * Copyright 2003 Mike Hearn
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <assert.h>
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <string.h>
29 #include <windef.h>
30 #include <winbase.h>
31 #include <winreg.h>
32 #include <wine/debug.h>
33 #include <shellapi.h>
34 #include <objbase.h>
35 #include <shlguid.h>
36 #include <shlwapi.h>
37 #include <shlobj.h>
39 #include "winecfg.h"
40 #include "resource.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
44 static BOOL updatingUI = FALSE;
45 static char editWindowLetter; /* drive letter of the drive we are currently editing */
46 static int lastSel = 0; /* the last drive selected in the property sheet */
49 /* returns NULL on failure. caller is responsible for freeing result */
50 char *getDriveValue(char letter, const char *valueName) {
51 HKEY hkDrive = 0;
52 char *subKeyName;
53 char *result = NULL;
54 HRESULT hr;
55 DWORD bufferSize;
57 WINE_TRACE("letter=%c, valueName=%s\n", letter, valueName);
59 subKeyName = malloc(strlen("Drive X")+1);
60 sprintf(subKeyName, "Drive %c", letter);
62 hr = RegOpenKeyEx(configKey, subKeyName, 0, KEY_READ, &hkDrive);
63 if (hr != ERROR_SUCCESS) goto end;
65 hr = RegQueryValueEx(hkDrive, valueName, NULL, NULL, NULL, &bufferSize);
66 if (hr != ERROR_SUCCESS) goto end;
68 result = malloc(bufferSize);
69 hr = RegQueryValueEx(hkDrive, valueName, NULL, NULL, result, &bufferSize);
70 if (hr != ERROR_SUCCESS) goto end;
72 end:
73 if (hkDrive) RegCloseKey(hkDrive);
74 free(subKeyName);
75 return result;
78 /* call with newValue == NULL to remove a value */
79 void setDriveValue(char letter, const char *valueName, const char *newValue) {
80 char *driveSection = malloc(strlen("Drive X")+1);
81 sprintf(driveSection, "Drive %c", letter);
82 if (newValue)
83 addTransaction(driveSection, valueName, ACTION_SET, newValue);
84 else
85 addTransaction(driveSection, valueName, ACTION_REMOVE, NULL);
86 free(driveSection);
89 /* copies a drive configuration branch */
90 void copyDrive(char srcLetter, char destLetter) {
91 char driveSection[sizeof("Drive X") + 1];
92 char *path, *label, *type, *serial;
94 WINE_TRACE("srcLetter=%c, destLetter=%c\n", srcLetter, destLetter);
96 sprintf(driveSection, "Drive %c", srcLetter);
97 path = getDriveValue(srcLetter, "Path");
98 label = getDriveValue(srcLetter, "Label");
99 type = getDriveValue(srcLetter, "Type");
100 serial = getDriveValue(srcLetter, "Serial");
102 sprintf(driveSection, "Drive %c", destLetter);
103 if (path) addTransaction(driveSection, "Path", ACTION_SET, path);
104 if (label) addTransaction(driveSection, "Label", ACTION_SET, label);
105 if (type) addTransaction(driveSection, "Type", ACTION_SET, type);
106 if (serial) addTransaction(driveSection, "Serial", ACTION_SET, serial);
108 if (path) free(path);
109 if (label) free(label);
110 if (type) free(type);
111 if (serial) free(serial);
114 void removeDrive(char letter) {
115 char driveSection[sizeof("Drive X") + 1];
116 sprintf(driveSection, "Drive %c", letter);
117 addTransaction(driveSection, NULL, ACTION_REMOVE, NULL);
120 int refreshDriveDlg (HWND dialog)
122 int i;
123 char *subKeyName = malloc(MAX_NAME_LENGTH);
124 int driveCount = 0;
125 DWORD sizeOfSubKeyName = MAX_NAME_LENGTH;
126 int doesDriveCExist = FALSE;
128 WINE_TRACE("\n");
130 updatingUI = TRUE;
132 /* Clear the listbox */
133 SendMessageA(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_RESETCONTENT, 0, 0);
134 for (i = 0;
135 RegEnumKeyExA(configKey, i, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS;
136 ++i, sizeOfSubKeyName = MAX_NAME_LENGTH) {
138 HKEY hkDrive;
139 char returnBuffer[MAX_NAME_LENGTH];
140 DWORD sizeOfReturnBuffer = sizeof(returnBuffer);
141 LONG r;
142 WINE_TRACE("%s\n", subKeyName);
144 if (!strncmp("Drive ", subKeyName, 5)) {
145 char driveLetter = '\0';
146 char *label;
147 char *title;
148 char *device;
149 int titleLen;
150 const char *itemLabel = "Drive %s (%s)";
151 int itemIndex;
153 if (RegOpenKeyExA (configKey, subKeyName, 0, KEY_READ, &hkDrive) != ERROR_SUCCESS) {
154 WINE_ERR("unable to open drive registry key");
155 RegCloseKey(configKey);
156 return -1;
159 /* extract the drive letter, force to upper case */
160 driveLetter = subKeyName[strlen(subKeyName)-1];
161 if (driveLetter) driveLetter = toupper(driveLetter);
162 if (driveLetter == 'C') doesDriveCExist = TRUE;
164 ZeroMemory(returnBuffer, sizeof(*returnBuffer));
165 sizeOfReturnBuffer = sizeof(returnBuffer);
166 r = RegQueryValueExA(hkDrive, "Label", NULL, NULL, returnBuffer, &sizeOfReturnBuffer);
167 if (r == ERROR_SUCCESS) {
168 label = malloc(sizeOfReturnBuffer);
169 strncpy(label, returnBuffer, sizeOfReturnBuffer);
170 } else {
171 WINE_WARN("label not loaded: %ld\n", r);
172 label = NULL;
175 device = getDriveValue(driveLetter, "Device");
177 /* We now know the label and drive letter, so we can add to the list. The list items will have the letter associated
178 * with them, which acts as the key. We can then use that letter to get/set the properties of the drive. */
179 WINE_TRACE("Adding %c: label=%s to the listbox, device=%s\n", driveLetter, label, device);
181 /* fixup label */
182 if (!label && device) {
183 label = malloc(strlen("[label read from device ]")+1+strlen(device));
184 sprintf(label, "[label read from device %s]", device);
186 if (!label) label = strdup("(no label)");
188 titleLen = strlen(itemLabel) - 1 + strlen(label) - 2 + 1;
189 title = malloc(titleLen);
190 /* the %s in the item label will be replaced by the drive letter, so -1, then
191 -2 for the second %s which will be expanded to the label, finally + 1 for terminating #0 */
192 snprintf(title, titleLen, "Drive %c: %s", driveLetter, label);
194 /* the first SendMessage call adds the string and returns the index, the second associates that index with it */
195 itemIndex = SendMessageA(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_ADDSTRING ,(WPARAM) -1, (LPARAM) title);
196 SendMessageA(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_SETITEMDATA, itemIndex, (LPARAM) driveLetter);
198 free(title);
199 free(label);
201 driveCount++;
206 WINE_TRACE("loaded %d drives\n", driveCount);
207 SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LB_SETSEL, TRUE, lastSel);
209 /* show the warning if there is no Drive C */
210 if (!doesDriveCExist)
211 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_NORMAL);
212 else
213 ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_HIDE);
215 free(subKeyName);
217 /* disable or enable controls depending on whether we are editing global vs app specific config */
218 if (appSettings == EDITING_GLOBAL) {
219 WINE_TRACE("enabling controls\n");
220 enable(IDC_LIST_DRIVES);
221 enable(IDC_BUTTON_ADD);
222 enable(IDC_BUTTON_REMOVE);
223 enable(IDC_BUTTON_EDIT);
224 enable(IDC_BUTTON_AUTODETECT);
226 } else {
227 WINE_TRACE("disabling controls\n");
228 disable(IDC_LIST_DRIVES);
229 disable(IDC_BUTTON_ADD);
230 disable(IDC_BUTTON_REMOVE);
231 disable(IDC_BUTTON_EDIT);
232 disable(IDC_BUTTON_AUTODETECT);
236 updatingUI = FALSE;
237 return driveCount;
240 /******************************************************************************/
241 /* The Drive Editing Dialog */
242 /******************************************************************************/
243 #define DRIVE_MASK_BIT(B) 1<<(toupper(B)-'A')
245 typedef struct {
246 const char *sCode;
247 const char *sDesc;
248 } code_desc_pair;
250 static code_desc_pair type_pairs[] = {
251 {"hd", "Local hard disk"},
252 {"network", "Network share" },
253 {"floppy", "Floppy disk"},
254 {"cdrom", "CD-ROM"}
256 #define DRIVE_TYPE_DEFAULT 1
259 void fill_drive_droplist(long mask, char currentLetter, HWND hDlg)
261 int i;
262 int selection;
263 int count;
264 int next_letter;
265 char sName[4] = "A:";
267 for( i=0, count=0, selection=-1, next_letter=-1; i <= 'Z'-'A'; ++i ) {
268 if( mask & DRIVE_MASK_BIT('A'+i) ) {
269 int index;
271 sName[0] = 'A' + i;
272 index = SendDlgItemMessage( hDlg, IDC_COMBO_LETTER, CB_ADDSTRING, 0, (LPARAM) sName );
274 if( toupper(currentLetter) == 'A' + i ) {
275 selection = count;
278 if( i >= 2 && next_letter == -1){ /*default drive is first one of C-Z */
279 next_letter = count;
282 count++;
286 if( selection == -1 ) {
287 selection = next_letter;
290 SendDlgItemMessage( hDlg, IDC_COMBO_LETTER, CB_SETCURSEL, selection, 0 );
293 #define BOX_MODE_CD_ASSIGN 1
294 #define BOX_MODE_CD_AUTODETECT 2
295 #define BOX_MODE_NONE 3
296 #define BOX_MODE_NORMAL 4
297 void enable_labelserial_box(HWND dialog, int mode)
299 WINE_TRACE("mode=%d\n", mode);
300 switch (mode) {
301 case BOX_MODE_CD_ASSIGN:
302 enable(IDC_RADIO_AUTODETECT);
303 enable(IDC_RADIO_ASSIGN);
304 disable(IDC_EDIT_DEVICE);
305 disable(IDC_BUTTON_BROWSE_DEVICE);
306 enable(IDC_EDIT_SERIAL);
307 enable(IDC_EDIT_LABEL);
308 enable(IDC_STATIC_SERIAL);
309 enable(IDC_STATIC_LABEL);
310 break;
312 case BOX_MODE_CD_AUTODETECT:
313 enable(IDC_RADIO_AUTODETECT);
314 enable(IDC_RADIO_ASSIGN);
315 enable(IDC_EDIT_DEVICE);
316 enable(IDC_BUTTON_BROWSE_DEVICE);
317 disable(IDC_EDIT_SERIAL);
318 disable(IDC_EDIT_LABEL);
319 disable(IDC_STATIC_SERIAL);
320 disable(IDC_STATIC_LABEL);
321 break;
323 case BOX_MODE_NONE:
324 disable(IDC_RADIO_AUTODETECT);
325 disable(IDC_RADIO_ASSIGN);
326 disable(IDC_EDIT_DEVICE);
327 disable(IDC_BUTTON_BROWSE_DEVICE);
328 disable(IDC_EDIT_SERIAL);
329 disable(IDC_EDIT_LABEL);
330 disable(IDC_STATIC_SERIAL);
331 disable(IDC_STATIC_LABEL);
332 break;
334 case BOX_MODE_NORMAL:
335 disable(IDC_RADIO_AUTODETECT);
336 enable(IDC_RADIO_ASSIGN);
337 disable(IDC_EDIT_DEVICE);
338 disable(IDC_BUTTON_BROWSE_DEVICE);
339 enable(IDC_EDIT_SERIAL);
340 enable(IDC_EDIT_LABEL);
341 enable(IDC_STATIC_SERIAL);
342 enable(IDC_STATIC_LABEL);
343 break;
347 /* This function produces a mask for each drive letter that isn't currently used. Each bit of the long result
348 * represents a letter, with A being the least significant bit, and Z being the most significant.
350 * To calculate this, we loop over each letter, and see if we can get a drive entry for it. If so, we
351 * set the appropriate bit. At the end, we flip each bit, to give the desired result.
353 * The letter parameter is always marked as being available. This is so the edit dialog can display the
354 * currently used drive letter alongside the available ones.
356 long drive_available_mask(char letter)
358 long result = 0;
359 char curLetter;
360 char *slop;
362 WINE_TRACE("\n");
364 for (curLetter = 'A'; curLetter < 'Z'; curLetter++) {
365 slop = getDriveValue(curLetter, "Path");
366 if (slop != NULL) {
367 result |= DRIVE_MASK_BIT(curLetter);
368 free(slop);
372 result = ~result;
373 if (letter) result |= DRIVE_MASK_BIT(letter);
375 WINE_TRACE( "finished drive letter loop with %lx\n", result );
376 return result;
380 void refreshDriveEditDialog(HWND dialog) {
381 char *path;
382 char *type;
383 char *serial;
384 char *label;
385 char *device;
386 int i, selection;
388 updatingUI = TRUE;
390 /* Drive letters */
391 fill_drive_droplist( drive_available_mask( editWindowLetter ), editWindowLetter, dialog );
393 /* path */
394 path = getDriveValue(editWindowLetter, "Path");
395 if (path) {
396 SetWindowText(GetDlgItem(dialog, IDC_EDIT_PATH), path);
397 } else WINE_WARN("no Path field?\n");
399 /* drive type */
400 type = getDriveValue(editWindowLetter, "Type");
401 if (type) {
402 for(i = 0, selection = -1; i < sizeof(type_pairs)/sizeof(code_desc_pair); i++) {
403 SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0,
404 (LPARAM) type_pairs[i].sDesc);
405 if(strcasecmp(type_pairs[i].sCode, type) == 0){
406 selection = i;
410 if( selection == -1 ) selection = DRIVE_TYPE_DEFAULT;
411 SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
412 } else WINE_WARN("no Type field?\n");
415 /* removeable media properties */
416 serial = getDriveValue(editWindowLetter, "Serial");
417 if (serial) {
418 SendDlgItemMessage(dialog, IDC_EDIT_SERIAL, WM_SETTEXT, 0,(LPARAM)serial);
419 } else WINE_WARN("no Serial field?\n");
421 label = getDriveValue(editWindowLetter, "Label");
422 if (label) {
423 SendDlgItemMessage(dialog, IDC_EDIT_LABEL, WM_SETTEXT, 0,(LPARAM)label);
424 } else WINE_WARN("no Label field?\n");
426 device = getDriveValue(editWindowLetter, "Device");
427 if (device) {
428 SendDlgItemMessage(dialog, IDC_EDIT_DEVICE, WM_SETTEXT, 0,(LPARAM)device);
429 } else WINE_WARN("no Device field?\n");
431 selection = IDC_RADIO_ASSIGN;
432 if ((type && strcmp("cdrom", type) == 0) || (type && strcmp("floppy", type) == 0)) {
433 if (device) {
434 selection = IDC_RADIO_AUTODETECT;
435 enable_labelserial_box(dialog, BOX_MODE_CD_AUTODETECT);
436 } else {
437 selection = IDC_RADIO_ASSIGN;
438 enable_labelserial_box(dialog, BOX_MODE_CD_ASSIGN);
440 } else {
441 enable_labelserial_box(dialog, BOX_MODE_NORMAL);
442 selection = IDC_RADIO_ASSIGN;
445 CheckRadioButton( dialog, IDC_RADIO_AUTODETECT, IDC_RADIO_ASSIGN, selection );
446 if (path) SendDlgItemMessage(dialog, IDC_EDIT_PATH, WM_SETTEXT, 0,(LPARAM)path);
448 if (path) free(path);
449 if (type) free(type);
450 if (serial) free(serial);
451 if (label) free(label);
452 if (device) free(device);
455 updatingUI = FALSE;
457 return;
460 /* storing the drive propsheet HWND here is a bit ugly, but the simplest solution for now */
461 static HWND driveDlgHandle;
463 void onEditChanged(HWND hDlg, WORD controlID) {
464 WINE_TRACE("controlID=%d\n", controlID);
465 switch (controlID) {
466 case IDC_EDIT_LABEL: {
467 char *label = getDialogItemText(hDlg, controlID);
468 setDriveValue(editWindowLetter, "Label", label);
469 refreshDriveDlg(driveDlgHandle);
470 if (label) free(label);
471 break;
473 case IDC_EDIT_PATH: {
474 char *path = getDialogItemText(hDlg, controlID);
475 if (!path) path = strdup("fake_windows"); /* default to assuming fake_windows in the .wine directory */
476 setDriveValue(editWindowLetter, "Path", path);
477 free(path);
478 break;
480 case IDC_EDIT_SERIAL: {
481 char *serial = getDialogItemText(hDlg, controlID);
482 setDriveValue(editWindowLetter, "Serial", serial);
483 if (serial) free (serial);
484 break;
486 case IDC_EDIT_DEVICE: {
487 char *device = getDialogItemText(hDlg,controlID);
488 setDriveValue(editWindowLetter, "Device", device);
489 if (device) free(device);
490 refreshDriveDlg(driveDlgHandle);
491 break;
496 INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
498 int selection;
500 switch (uMsg) {
501 case WM_INITDIALOG: {
502 editWindowLetter = (char) lParam;
503 refreshDriveEditDialog(hDlg);
506 case WM_COMMAND:
507 switch (LOWORD(wParam)) {
508 case IDC_COMBO_TYPE:
509 if (HIWORD(wParam) != CBN_SELCHANGE) break;
510 selection = SendDlgItemMessage( hDlg, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
511 if( selection == 2 || selection == 3 ) { /* cdrom or floppy */
512 if (IsDlgButtonChecked(hDlg, IDC_RADIO_AUTODETECT))
513 enable_labelserial_box(hDlg, BOX_MODE_CD_AUTODETECT);
514 else
515 enable_labelserial_box(hDlg, BOX_MODE_CD_ASSIGN);
517 else {
518 enable_labelserial_box( hDlg, BOX_MODE_NORMAL );
520 setDriveValue(editWindowLetter, "Type", type_pairs[selection].sCode);
521 break;
523 case IDC_COMBO_LETTER: {
524 int item = SendDlgItemMessage(hDlg, IDC_COMBO_LETTER, CB_GETCURSEL, 0, 0);
525 char newLetter;
526 SendDlgItemMessage(hDlg, IDC_COMBO_LETTER, CB_GETLBTEXT, item, (LPARAM) &newLetter);
528 if (HIWORD(wParam) != CBN_SELCHANGE) break;
529 if (newLetter == editWindowLetter) break;
531 WINE_TRACE("changing drive letter to %c\n", newLetter);
532 copyDrive(editWindowLetter, newLetter);
533 removeDrive(editWindowLetter);
534 editWindowLetter = newLetter;
535 refreshDriveDlg(driveDlgHandle);
536 break;
539 case IDC_BUTTON_BROWSE_PATH:
540 WRITEME(hDlg);
541 break;
543 case IDC_RADIO_AUTODETECT: {
544 setDriveValue(editWindowLetter, "Label", NULL);
545 setDriveValue(editWindowLetter, "Serial", NULL);
546 setDriveValue(editWindowLetter, "Device", getDialogItemText(hDlg, IDC_EDIT_DEVICE));
547 enable_labelserial_box(hDlg, BOX_MODE_CD_AUTODETECT);
548 refreshDriveDlg(driveDlgHandle);
549 break;
552 case IDC_RADIO_ASSIGN:
553 setDriveValue(editWindowLetter, "Device", NULL);
554 setDriveValue(editWindowLetter, "Label", getDialogItemText(hDlg, IDC_EDIT_LABEL));
555 setDriveValue(editWindowLetter, "Serial", getDialogItemText(hDlg, IDC_EDIT_SERIAL));
556 enable_labelserial_box(hDlg, BOX_MODE_CD_ASSIGN);
557 refreshDriveDlg(driveDlgHandle);
558 break;
560 case ID_BUTTON_OK:
561 EndDialog(hDlg, wParam);
562 return TRUE;
564 if (HIWORD(wParam) == EN_CHANGE) onEditChanged(hDlg, LOWORD(wParam));
565 break;
567 return FALSE;
570 void onAddDriveClicked(HWND hDlg) {
571 /* we should allocate a drive letter automatically. We also need some way to let the user choose the mapping point,
572 for now we will just force them to enter a path automatically, with / being the default. In future we should
573 be able to temporarily map / then invoke the directory chooser dialog. */
575 char newLetter = 'C'; /* we skip A and B, they are historically floppy drives */
576 long mask = ~drive_available_mask(0); /* the mask is now which drives aren't available */
577 char *sectionName;
579 while (mask & (1 << (newLetter - 'A'))) {
580 newLetter++;
581 if (newLetter > 'Z') {
582 MessageBox(NULL, "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);
583 return;
586 WINE_TRACE("allocating drive letter %c\n", newLetter);
588 sectionName = malloc(strlen("Drive X") + 1);
589 sprintf(sectionName, "Drive %c", newLetter);
590 if (newLetter == 'C') {
591 addTransaction(sectionName, "Path", ACTION_SET, "fake_windows");
592 addTransaction(sectionName, "Label", ACTION_SET, "System Drive");
593 } else
594 addTransaction(sectionName, "Path", ACTION_SET, "/"); /* default to root path */
595 addTransaction(sectionName, "Type", ACTION_SET, "hd");
596 processTransQueue(); /* make sure the drive has been added, even if we are not in instant apply mode */
597 free(sectionName);
599 refreshDriveDlg(driveDlgHandle);
601 DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT), NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) newLetter);
605 INT_PTR CALLBACK
606 DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
608 int nItem;
609 char letter;
611 switch (uMsg) {
612 case WM_COMMAND:
613 switch (LOWORD(wParam)) {
614 case IDC_LIST_DRIVES:
615 /* double click should open the edit window for the chosen drive */
616 if (HIWORD(wParam) == LBN_DBLCLK)
617 SendMessageA(hDlg, WM_COMMAND, IDC_BUTTON_EDIT, 0);
619 if (HIWORD(wParam) == LBN_SELCHANGE) lastSel = SendDlgItemMessage(hDlg, IDC_LIST_DRIVES, LB_GETCURSEL, 0, 0);
620 break;
622 case IDC_BUTTON_ADD:
623 onAddDriveClicked(hDlg);
624 break;
626 case IDC_BUTTON_REMOVE:
627 if (HIWORD(wParam) != BN_CLICKED) break;
628 nItem = SendDlgItemMessage(hDlg, IDC_LIST_DRIVES, LB_GETCURSEL, 0, 0);
629 letter = SendDlgItemMessage(hDlg, IDC_LIST_DRIVES, LB_GETITEMDATA, nItem, 0);
630 removeDrive(letter);
631 refreshDriveDlg(driveDlgHandle);
632 break;
634 case IDC_BUTTON_EDIT:
635 if (HIWORD(wParam) != BN_CLICKED) break;
636 nItem = SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_GETCURSEL, 0, 0);
637 letter = SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_GETITEMDATA, nItem, 0);
638 DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT), NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) letter);
639 break;
641 case IDC_BUTTON_AUTODETECT:
642 WRITEME(hDlg);
643 break;
645 break;
647 case WM_NOTIFY: switch(((LPNMHDR)lParam)->code) {
648 case PSN_KILLACTIVE:
649 SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
650 break;
651 case PSN_APPLY:
652 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
653 break;
654 case PSN_SETACTIVE:
655 driveDlgHandle = hDlg;
656 refreshDriveDlg (driveDlgHandle);
657 break;
659 break;
662 return FALSE;