3 * Copyright (C) 2004-2008 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS GUI first stage setup application
22 * FILE: base/setup/reactos/drivepage.c
23 * PROGRAMMERS: Matthias Kupfer
24 * Dmitry Chapyshev (dmitry@reactos.org)
30 /* GLOBALS ******************************************************************/
32 #define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
33 static const int default_column_widths
[MAX_LIST_COLUMNS
] = {200, 150, 150};
34 static const int column_alignment
[MAX_LIST_COLUMNS
] = {LVCFMT_LEFT
, LVCFMT_LEFT
, LVCFMT_LEFT
};
36 /* FUNCTIONS ****************************************************************/
38 static INT_PTR CALLBACK
39 MoreOptDlgProc(HWND hwndDlg
,
44 PSETUPDATA pSetupData
;
46 /* Retrieve pointer to the global setup data */
47 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
52 /* Save pointer to the global setup data */
53 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
54 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)pSetupData
);
56 CheckDlgButton(hwndDlg
, IDC_INSTFREELDR
, BST_CHECKED
);
57 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
60 (LPARAM
)pSetupData
->USetupData
.InstallationDirectory
);
64 switch(LOWORD(wParam
))
67 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
69 (WPARAM
)sizeof(pSetupData
->USetupData
.InstallationDirectory
) / sizeof(TCHAR
),
70 (LPARAM
)pSetupData
->USetupData
.InstallationDirectory
);
72 EndDialog(hwndDlg
, IDOK
);
76 EndDialog(hwndDlg
, IDCANCEL
);
85 static INT_PTR CALLBACK
86 PartitionDlgProc(HWND hwndDlg
,
97 switch(LOWORD(wParam
))
100 EndDialog(hwndDlg
, IDOK
);
103 EndDialog(hwndDlg
, IDCANCEL
);
114 CreateListViewColumns(
122 /* Create columns. */
123 lvC
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
| LVCF_SUBITEM
;
124 lvC
.pszText
= szText
;
126 /* Load the column labels from the resource file. */
127 for (index
= 0; index
< MAX_LIST_COLUMNS
; index
++)
129 lvC
.iSubItem
= index
;
130 lvC
.cx
= default_column_widths
[index
];
131 lvC
.fmt
= column_alignment
[index
];
133 LoadStringW(hInstance
, IDS_LIST_COLUMN_FIRST
+ index
, szText
, 50);
135 if (ListView_InsertColumn(hWndListView
, index
, &lvC
) == -1)
150 PSETUPDATA pSetupData
;
154 SP_DEVINFO_DATA DevInfoData
;
158 /* Retrieve pointer to the global setup data */
159 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
165 /* Save pointer to the global setup data */
166 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
167 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)pSetupData
);
169 CreateListViewColumns(pSetupData
->hInstance
,
170 GetDlgItem(hwndDlg
, IDC_PARTITION
));
173 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
174 if (h
!= INVALID_HANDLE_VALUE
)
176 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
177 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
178 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
181 LPTSTR buffer
= NULL
;
182 DWORD buffersize
= 0;
184 while (!SetupDiGetDeviceRegistryProperty(h
,
192 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
194 if (buffer
) LocalFree(buffer
);
195 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
202 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
206 SetupDiDestroyDeviceInfoList(h
);
214 switch(LOWORD(wParam
))
216 case IDC_PARTMOREOPTS
:
217 DialogBoxParam(pSetupData
->hInstance
,
218 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
224 DialogBox(pSetupData
->hInstance
,
225 MAKEINTRESOURCE(IDD_PARTITION
),
237 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
242 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
245 case PSN_QUERYCANCEL
:
246 SetWindowLongPtr(hwndDlg
,
248 MessageBox(GetParent(hwndDlg
),
249 pSetupData
->szAbortMessage
,
250 pSetupData
->szAbortTitle
,
251 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);