2 * PROJECT: ReactOS Applications
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/freeldrpage.c
5 * PURPOSE: Freeloader configuration page message handler
6 * COPYRIGHT: Copyright 2005-2006 Christoph von Wittich <Christoph@ApiViewer.de>
18 WCHAR szDefaultOS
[512];
20 ULONG OSConfigurationCount
;
24 static FREELDR_SETTINGS Settings
= { 0, { 0, }, 0, 0, FALSE
};
28 LoadBootIni(WCHAR
* szDrive
, HWND hDlg
)
36 wcscpy(szBuffer
, szDrive
);
37 wcscat(szBuffer
, L
"boot.ini");
39 file
= _wfopen(szBuffer
, L
"rt");
43 hDlgCtrl
= GetDlgItem(hDlg
, IDC_LIST_BOX
);
47 if (fgetws(szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
), file
))
49 length
= wcslen(szBuffer
);
50 while(szBuffer
[length
] < 14) //FIXME remove line feeds
51 szBuffer
[length
--] = 0;
53 pos
= SendMessageW(hDlgCtrl
, LB_ADDSTRING
, 0, (LPARAM
)szBuffer
);
56 if (szBuffer
[0] == L
'[')
59 if (!wcsncmp(szBuffer
, L
"timeout=", 8))
61 Settings
.TimeOut
= _wtoi(&szBuffer
[8]);
65 if (!wcsncmp(szBuffer
, L
"default=", 8))
67 wcscpy(Settings
.szDefaultOS
, &szBuffer
[8]);
71 SendMessage(hDlgCtrl
, LB_SETITEMDATA
, pos
, 1); // indicate that this item is an boot entry
72 Settings
.OSConfigurationCount
++;
77 Settings
.UseBootIni
= TRUE
;
79 pos
= SendMessageW(hDlgCtrl
, LB_FINDSTRING
, 3, (LPARAM
)Settings
.szDefaultOS
);
82 Settings
.szDefaultPos
= pos
;
83 SendMessage(hDlgCtrl
, LB_SETCURSEL
, pos
, 0);
86 SetDlgItemInt(hDlg
, IDC_TXT_BOOT_TIMEOUT
, Settings
.TimeOut
, FALSE
);
87 if (Settings
.OSConfigurationCount
< 2)
89 EnableWindow(GetDlgItem(hDlg
, IDC_BTN_SET_DEFAULT_BOOT
), FALSE
);
90 EnableWindow(GetDlgItem(hDlg
, IDC_BTN_MOVE_UP_BOOT_OPTION
), FALSE
);
91 EnableWindow(GetDlgItem(hDlg
, IDC_BTN_MOVE_DOWN_BOOT_OPTION
), FALSE
);
98 InitializeDialog(HWND hDlg
)
101 // find real boot drive and handle freeldr configuration ini
102 return LoadBootIni(L
"C:\\", hDlg
);
108 FreeLdrPageWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
112 UNREFERENCED_PARAMETER(lParam
);
113 UNREFERENCED_PARAMETER(wParam
);
117 hFreeLdrDialog
= hDlg
;
118 SetWindowPos(hDlg
, NULL
, 10, 32, 0, 0, SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
119 InitializeDialog(hDlg
);
122 switch(HIWORD(wParam
))
125 pos
= SendMessage((HWND
)lParam
, LB_GETCURSEL
, 0, 0);
128 LPARAM res
= SendMessage((HWND
)lParam
, LB_GETITEMDATA
, pos
, 0);
129 if (!res
) //line is not a default one
130 SendMessage((HWND
)lParam
, LB_SETCURSEL
, Settings
.szDefaultPos
, 0);
132 Settings
.szDefaultPos
= pos
;