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: Eric Kohl
25 * Dmitry Chapyshev (dmitry@reactos.org)
31 /* GLOBALS ******************************************************************/
33 #define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
34 static const int default_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
->InstallDir
);
65 switch(LOWORD(wParam
))
68 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
70 (WPARAM
)sizeof(pSetupData
->InstallDir
) / sizeof(TCHAR
),
71 (LPARAM
)pSetupData
->InstallDir
);
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
);
115 CreateListViewColumns(
123 /* Create columns. */
124 lvC
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
| LVCF_SUBITEM
;
125 lvC
.pszText
= szText
;
127 /* Load the column labels from the resource file. */
128 for (index
= 0; index
< MAX_LIST_COLUMNS
; index
++)
130 lvC
.iSubItem
= index
;
131 lvC
.cx
= default_column_widths
[index
];
132 lvC
.fmt
= column_alignment
[index
];
134 LoadStringW(hInstance
, IDS_LIST_COLUMN_FIRST
+ index
, szText
, 50);
136 if (ListView_InsertColumn(hWndListView
, index
, &lvC
) == -1)
151 PSETUPDATA pSetupData
;
155 SP_DEVINFO_DATA DevInfoData
;
159 /* Retrieve pointer to the global setup data */
160 pSetupData
= (PSETUPDATA
)GetWindowLongPtr(hwndDlg
, GWLP_USERDATA
);
166 /* Save pointer to the global setup data */
167 pSetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
168 SetWindowLongPtr(hwndDlg
, GWLP_USERDATA
, (DWORD_PTR
)pSetupData
);
170 CreateListViewColumns(pSetupData
->hInstance
,
171 GetDlgItem(hwndDlg
, IDC_PARTITION
));
174 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
175 if (h
!= INVALID_HANDLE_VALUE
)
177 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
178 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
179 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
182 LPTSTR buffer
= NULL
;
183 DWORD buffersize
= 0;
185 while (!SetupDiGetDeviceRegistryProperty(h
,
193 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
195 if (buffer
) LocalFree(buffer
);
196 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
203 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
207 SetupDiDestroyDeviceInfoList(h
);
215 switch(LOWORD(wParam
))
217 case IDC_PARTMOREOPTS
:
218 DialogBoxParam(pSetupData
->hInstance
,
219 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
225 DialogBox(pSetupData
->hInstance
,
226 MAKEINTRESOURCE(IDD_PARTITION
),
238 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
243 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
246 case PSN_QUERYCANCEL
:
247 SetWindowLongPtr(hwndDlg
,
249 MessageBox(GetParent(hwndDlg
),
250 pSetupData
->szAbortMessage
,
251 pSetupData
->szAbortTitle
,
252 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);