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 IDS_LIST_COLUMN_FIRST IDS_PARTITION_NAME
33 #define IDS_LIST_COLUMN_LAST IDS_PARTITION_TYPE
35 #define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
36 static const UINT column_ids
[MAX_LIST_COLUMNS
] = {IDS_LIST_COLUMN_FIRST
, IDS_LIST_COLUMN_FIRST
+ 1, IDS_LIST_COLUMN_FIRST
+ 2};
37 static const INT column_widths
[MAX_LIST_COLUMNS
] = {200, 150, 150};
38 static const INT column_alignment
[MAX_LIST_COLUMNS
] = {LVCFMT_LEFT
, LVCFMT_LEFT
, LVCFMT_LEFT
};
40 /* FUNCTIONS ****************************************************************/
42 static INT_PTR CALLBACK
43 MoreOptDlgProc(HWND hwndDlg
,
48 PSETUPDATA pSetupData
;
50 /* Retrieve pointer to the global setup data */
51 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
56 /* Save pointer to the global setup data */
57 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
58 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)pSetupData
);
60 CheckDlgButton(hwndDlg
, IDC_INSTFREELDR
, BST_CHECKED
);
61 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
64 (LPARAM
)pSetupData
->USetupData
.InstallationDirectory
);
68 switch(LOWORD(wParam
))
71 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
73 (WPARAM
)sizeof(pSetupData
->USetupData
.InstallationDirectory
) / sizeof(TCHAR
),
74 (LPARAM
)pSetupData
->USetupData
.InstallationDirectory
);
76 EndDialog(hwndDlg
, IDOK
);
80 EndDialog(hwndDlg
, IDCANCEL
);
89 static INT_PTR CALLBACK
90 PartitionDlgProc(HWND hwndDlg
,
101 switch(LOWORD(wParam
))
104 EndDialog(hwndDlg
, IDOK
);
107 EndDialog(hwndDlg
, IDCANCEL
);
117 CreateListViewColumns(
118 IN HINSTANCE hInstance
,
119 IN HWND hWndListView
,
121 IN
const INT
* pColsWidth
,
122 IN
const INT
* pColsAlign
,
123 IN UINT nNumOfColumns
)
129 /* Create the columns */
130 lvC
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
| LVCF_SUBITEM
;
131 lvC
.pszText
= szText
;
133 /* Load the column labels from the resource file */
134 for (i
= 0; i
< nNumOfColumns
; i
++)
137 lvC
.cx
= pColsWidth
[i
];
138 lvC
.fmt
= pColsAlign
[i
];
140 LoadStringW(hInstance
, pIDs
[i
], szText
, ARRAYSIZE(szText
));
142 if (ListView_InsertColumn(hWndListView
, i
, &lvC
) == -1)
158 PSETUPDATA pSetupData
;
162 SP_DEVINFO_DATA DevInfoData
;
166 /* Retrieve pointer to the global setup data */
167 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
173 /* Save pointer to the global setup data */
174 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
175 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)pSetupData
);
177 CreateListViewColumns(pSetupData
->hInstance
,
178 GetDlgItem(hwndDlg
, IDC_PARTITION
),
185 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
186 if (h
!= INVALID_HANDLE_VALUE
)
188 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
189 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
190 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
193 LPTSTR buffer
= NULL
;
194 DWORD buffersize
= 0;
196 while (!SetupDiGetDeviceRegistryProperty(h
,
204 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
206 if (buffer
) LocalFree(buffer
);
207 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
214 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
218 SetupDiDestroyDeviceInfoList(h
);
226 switch(LOWORD(wParam
))
228 case IDC_PARTMOREOPTS
:
229 DialogBoxParam(pSetupData
->hInstance
,
230 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
236 DialogBox(pSetupData
->hInstance
,
237 MAKEINTRESOURCE(IDD_PARTITION
),
249 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
254 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
257 case PSN_QUERYCANCEL
:
258 SetWindowLongPtr(hwndDlg
,
260 MessageBox(GetParent(hwndDlg
),
261 pSetupData
->szAbortMessage
,
262 pSetupData
->szAbortTitle
,
263 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);