HWND hWndCloseButton = NULL;
HWND hWndCheckButton = NULL;
-/* TODO: Retrieve the preferences from a configuration file */
-BOOL bDisplayCheckBox = FALSE; // FIXME!
+BOOL bDisplayCheckBox = FALSE; // FIXME: We should also repaint the OS version correctly!
BOOL bDisplayExitBtn = TRUE;
#define BUFFER_SIZE 1024
/* FUNCTIONS ****************************************************************/
-INT GetLocaleName(LCID Locale, LPTSTR lpLCData, SIZE_T cchData)
+INT GetLocaleName(IN LCID Locale, OUT LPTSTR lpLCData, IN SIZE_T cchData)
{
INT ret, ret2;
}
}
-BOOL LoadTopicsFromINI(LCID Locale)
+static BOOL
+LoadLocalizedResourcesFromINI(LCID Locale, LPTSTR lpResPath)
{
DWORD dwRet;
DWORD dwSize;
}
/* Build the INI file name */
- GetCurrentDirectory(ARRAYSIZE(szIniPath), szIniPath);
+ StringCchCopy(szIniPath, ARRAYSIZE(szIniPath), lpResPath);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT("\\"));
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), szBuffer);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT(".ini"));
{
StringCchCopy(szBuffer, ARRAYSIZE(szBuffer), TEXT("en-US"));
- GetCurrentDirectory(ARRAYSIZE(szIniPath), szIniPath);
+ StringCchCopy(szIniPath, ARRAYSIZE(szIniPath), lpResPath);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT("\\"));
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), szBuffer);
StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT(".ini"));
return FALSE; // TODO: For localized resource, see the general function.
/* Try to load the default localized strings */
+ GetPrivateProfileString(TEXT("Defaults"), TEXT("AppTitle"), TEXT("ReactOS Welcome") /* default */,
+ szAppTitle, ARRAYSIZE(szAppTitle), szIniPath);
if (!GetPrivateProfileString(TEXT("Defaults"), TEXT("DefaultTopicTitle"), NULL /* default */,
szDefaultTitle, ARRAYSIZE(szDefaultTitle), szIniPath))
{
return TRUE;
}
-BOOL LoadTopics(VOID)
+static BOOL
+LoadLocalizedResources(LPTSTR lpResPath)
{
#define MAX_NUMBER_INTERNAL_TOPICS 3
* First, try to load the default internal (localized) strings.
* They can be redefined by the localized INI files.
*/
+ if (!LoadString(hInstance, IDS_APPTITLE, szAppTitle, ARRAYSIZE(szAppTitle)))
+ StringCchCopy(szAppTitle, ARRAYSIZE(szAppTitle), TEXT("ReactOS Welcome"));
if (!LoadString(hInstance, IDS_DEFAULTTOPICTITLE, szDefaultTitle, ARRAYSIZE(szDefaultTitle)))
*szDefaultTitle = 0;
if (!LoadString(hInstance, IDS_DEFAULTTOPICDESC, szDefaultDesc, ARRAYSIZE(szDefaultDesc)))
*szDefaultDesc = 0;
- /* Try to load the topics from INI file */
- if (LoadTopicsFromINI(LOCALE_USER_DEFAULT))
+ /* Try to load the resources from INI file */
+ if (*lpResPath && LoadLocalizedResourcesFromINI(LOCALE_USER_DEFAULT, lpResPath))
return TRUE;
/* We failed, fall back to internal (localized) resource */
return TRUE;
}
-VOID FreeTopics(VOID)
+static VOID
+FreeResources(VOID)
{
if (!pTopics)
return;
dwNumberTopics = 0;
}
+static BOOL
+LoadConfiguration(VOID)
+{
+ TCHAR szAppPath[MAX_PATH];
+ TCHAR szIniPath[MAX_PATH];
+ TCHAR szResPath[MAX_PATH];
+
+ /* Retrieve the full path to this application */
+ GetModuleFileName(NULL, szAppPath, ARRAYSIZE(szAppPath));
+ if (*szAppPath)
+ {
+ LPTSTR lpFileName = _tcsrchr(szAppPath, _T('\\'));
+ if (lpFileName)
+ *lpFileName = 0;
+ else
+ *szAppPath = 0;
+ }
+
+ /* Build the full INI file path name */
+ StringCchCopy(szIniPath, ARRAYSIZE(szIniPath), szAppPath);
+ StringCchCat(szIniPath, ARRAYSIZE(szIniPath), TEXT("\\welcome.ini"));
+
+ /* Verify that the file exists, otherwise use the default configuration */
+ if (GetFileAttributes(szIniPath) == INVALID_FILE_ATTRIBUTES)
+ {
+ /* Use the default configuration and retrieve the default resources */
+ return LoadLocalizedResources(TEXT(""));
+ }
+
+ /* Load the settings from the INI configuration file */
+ bDisplayCheckBox = !!GetPrivateProfileInt(TEXT("Welcome"), TEXT("DisplayCheckBox"), FALSE /* default */, szIniPath);
+ bDisplayExitBtn = !!GetPrivateProfileInt(TEXT("Welcome"), TEXT("DisplayExitButton"), TRUE /* default */, szIniPath);
+
+ if (!GetPrivateProfileString(TEXT("Welcome"), TEXT("ResourceDir"), NULL /* default */,
+ szResPath, ARRAYSIZE(szResPath), szIniPath))
+ {
+ *szResPath = 0;
+ }
+
+ /* Set the current directory to the one of this application, and retrieve the resources */
+ SetCurrentDirectory(szAppPath);
+ return LoadLocalizedResources(szResPath);
+}
+
#if 0
static VOID
ShowLastWin32Error(HWND hWnd)
rcRightPanel.left = rcLeftPanel.right;
rcRightPanel.right = ulInnerWidth - 1;
- if (!LoadString(hInstance, IDS_APPTITLE, szAppTitle, ARRAYSIZE(szAppTitle)))
- StringCchCopy(szAppTitle, ARRAYSIZE(szAppTitle), TEXT("ReactOS Welcome"));
-
- LoadTopics();
+ /* Load the configuration and the resources */
+ LoadConfiguration();
/* Create main window */
hWndMain = CreateWindow(szFrameClass,
DispatchMessage(&msg);
}
- FreeTopics();
+ /* Cleanup */
+ FreeResources();
return msg.wParam;
}