Author: janderwald
Date: Fri Mar 7 17:48:07 2008
New Revision: 32602
URL:
http://svn.reactos.org/svn/reactos?rev=3D32602&view=3Drev
Log:
- load boot.ini into listbox
Modified:
trunk/reactos/base/applications/msconfig/freeldrpage.c
Modified: trunk/reactos/base/applications/msconfig/freeldrpage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/msc=
onfig/freeldrpage.c?rev=3D32602&r1=3D32601&r2=3D32602&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/base/applications/msconfig/freeldrpage.c (original)
+++ trunk/reactos/base/applications/msconfig/freeldrpage.c Fri Mar 7 17:48=
:07 2008
@@ -12,9 +12,103 @@
HWND hFreeLdrPage;
HWND hFreeLdrDialog;
=
+typedef struct
+{
+ ULONG TimeOut;
+ WCHAR szDefaultOS[512];
+ ULONG szDefaultPos;
+ ULONG OSConfigurationCount;
+ BOOL UseBootIni;
+}FREELDR_SETTINGS;
+
+static FREELDR_SETTINGS Settings =3D { 0, {0}, 0 };
+
+
+BOOL
+LoadBootIni(WCHAR * szDrive, HWND hDlg)
+{
+ WCHAR szBuffer[512];
+ HWND hDlgCtrl;
+ FILE * file;
+ UINT length;
+ LRESULT pos;
+
+ wcscpy(szBuffer, szDrive);
+ wcscat(szBuffer, L"boot.ini");
+ =
+ file =3D _wfopen(szBuffer, L"rt");
+ if (!file)
+ return FALSE;
+ =
+ hDlgCtrl =3D GetDlgItem(hDlg, IDC_LIST_BOX);
+
+ while(!feof(file))
+ {
+ if (fgetws(szBuffer, sizeof(szBuffer) / sizeof(WCHAR), file))
+ {
+ length =3D wcslen(szBuffer);
+ while(szBuffer[length] < 14) //FIXME remove line feeds
+ szBuffer[length--] =3D 0;
+
+ pos =3D SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)szBuff=
er);
+
+
+ if (szBuffer[0] =3D=3D L'[')
+ continue;
+
+ if (!wcsncmp(szBuffer, L"timeout=3D", 8))
+ {
+ Settings.TimeOut =3D _wtoi(&szBuffer[8]);
+ continue;
+ }
+
+ if (!wcsncmp(szBuffer, L"default=3D", 8))
+ {
+ wcscpy(Settings.szDefaultOS, &szBuffer[8]);
+ continue;
+ }
+ if (pos !=3D LB_ERR)
+ SendMessage(hDlgCtrl, LB_SETITEMDATA, pos, 1); // indicate=
that this item is an boot entry
+ Settings.OSConfigurationCount++;
+ }
+ }
+
+ fclose(file);
+ Settings.UseBootIni =3D TRUE;
+
+ pos =3D SendMessageW(hDlgCtrl, LB_FINDSTRING, 3, (LPARAM)Settings.szDef=
aultOS);
+ if (pos !=3D LB_ERR)
+ {
+ Settings.szDefaultPos =3D pos;
+ SendMessage(hDlgCtrl, LB_SETCURSEL, pos, 0);
+ }
+
+ SetDlgItemInt(hDlg, IDC_TXT_BOOT_TIMEOUT, Settings.TimeOut, FALSE);
+ if (Settings.OSConfigurationCount < 2)
+ {
+ EnableWindow(GetDlgItem(hDlg, IDC_BTN_SET_DEFAULT_BOOT), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_BTN_MOVE_UP_BOOT_OPTION), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_BTN_MOVE_DOWN_BOOT_OPTION), FALS=
E);
+ }
+ return TRUE;
+}
+
+
+BOOL
+InitializeDialog(HWND hDlg)
+{
+ // FIXME
+ // find real boot drive and handle freeldr configuration ini
+ return LoadBootIni(L"C:\\", hDlg);
+}
+
+
+
INT_PTR CALLBACK
FreeLdrPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
+ LRESULT pos;
+
UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam);
=
@@ -22,7 +116,25 @@
case WM_INITDIALOG:
hFreeLdrDialog =3D hDlg;
SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNE=
RZORDER | SWP_NOSIZE | SWP_NOZORDER);
+ InitializeDialog(hDlg);
return TRUE;
+ case WM_COMMAND:
+ switch(HIWORD(wParam))
+ {
+ case LBN_SELCHANGE:
+ pos =3D SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0);
+ if (pos !=3D LB_ERR)
+ {
+ LPARAM res =3D SendMessage((HWND)lParam, LB_GETITEMDAT=
A, pos, 0);
+ if (!res) //line is not a default one
+ SendMessage((HWND)lParam, LB_SETCURSEL, Settings.s=
zDefaultPos, 0);
+ else
+ Settings.szDefaultPos =3D pos;
+
+
+ }
+ break;
+ }
}
return 0;
}