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 UINT column_ids
[MAX_LIST_COLUMNS
] = {IDS_LIST_COLUMN_FIRST
, IDS_LIST_COLUMN_FIRST
+ 1, IDS_LIST_COLUMN_FIRST
+ 2};
34 static const INT column_widths
[MAX_LIST_COLUMNS
] = {200, 150, 150};
35 static const INT column_alignment
[MAX_LIST_COLUMNS
] = {LVCFMT_LEFT
, LVCFMT_LEFT
, LVCFMT_LEFT
};
37 /* FUNCTIONS ****************************************************************/
39 static INT_PTR CALLBACK
40 MoreOptDlgProc(HWND hwndDlg
,
45 PSETUPDATA pSetupData
;
47 /* Retrieve pointer to the global setup data */
48 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
53 /* Save pointer to the global setup data */
54 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
55 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)pSetupData
);
57 CheckDlgButton(hwndDlg
, IDC_INSTFREELDR
, BST_CHECKED
);
58 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
61 (LPARAM
)pSetupData
->USetupData
.InstallationDirectory
);
65 switch(LOWORD(wParam
))
68 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
70 (WPARAM
)sizeof(pSetupData
->USetupData
.InstallationDirectory
) / sizeof(TCHAR
),
71 (LPARAM
)pSetupData
->USetupData
.InstallationDirectory
);
73 EndDialog(hwndDlg
, IDOK
);
77 EndDialog(hwndDlg
, IDCANCEL
);
86 static INT_PTR CALLBACK
87 PartitionDlgProc(HWND hwndDlg
,
98 switch(LOWORD(wParam
))
101 EndDialog(hwndDlg
, IDOK
);
104 EndDialog(hwndDlg
, IDCANCEL
);
114 CreateListViewColumns(
115 IN HINSTANCE hInstance
,
116 IN HWND hWndListView
,
118 IN
const INT
* pColsWidth
,
119 IN
const INT
* pColsAlign
,
120 IN UINT nNumOfColumns
)
126 /* Create the columns */
127 lvC
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
| LVCF_SUBITEM
;
128 lvC
.pszText
= szText
;
130 /* Load the column labels from the resource file */
131 for (i
= 0; i
< nNumOfColumns
; i
++)
134 lvC
.cx
= pColsWidth
[i
];
135 lvC
.fmt
= pColsAlign
[i
];
137 LoadStringW(hInstance
, pIDs
[i
], szText
, ARRAYSIZE(szText
));
139 if (ListView_InsertColumn(hWndListView
, i
, &lvC
) == -1)
155 PSETUPDATA pSetupData
;
159 SP_DEVINFO_DATA DevInfoData
;
163 /* Retrieve pointer to the global setup data */
164 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
170 /* Save pointer to the global setup data */
171 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
172 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)pSetupData
);
174 CreateListViewColumns(pSetupData
->hInstance
,
175 GetDlgItem(hwndDlg
, IDC_PARTITION
),
182 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
183 if (h
!= INVALID_HANDLE_VALUE
)
185 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
186 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
187 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
190 LPTSTR buffer
= NULL
;
191 DWORD buffersize
= 0;
193 while (!SetupDiGetDeviceRegistryProperty(h
,
201 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
203 if (buffer
) LocalFree(buffer
);
204 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
211 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
215 SetupDiDestroyDeviceInfoList(h
);
223 switch(LOWORD(wParam
))
225 case IDC_PARTMOREOPTS
:
226 DialogBoxParam(pSetupData
->hInstance
,
227 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
233 DialogBox(pSetupData
->hInstance
,
234 MAKEINTRESOURCE(IDD_PARTITION
),
246 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
251 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
254 case PSN_QUERYCANCEL
:
255 SetWindowLongPtr(hwndDlg
,
257 MessageBox(GetParent(hwndDlg
),
258 pSetupData
->szAbortMessage
,
259 pSetupData
->szAbortTitle
,
260 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);