Outsource strings to resource.

svn path=/trunk/; revision=25182
This commit is contained in:
Maarten Bosma
2006-12-16 18:36:45 +00:00
parent 24dbaddea0
commit b5beda119d
4 changed files with 64 additions and 14 deletions
+25 -11
View File
@@ -22,6 +22,7 @@ struct Application* SelectedApplication;
INT_PTR CALLBACK DownloadProc (HWND, UINT, WPARAM, LPARAM);
BOOL ProcessXML (const char* filename, struct Category* Root);
void FreeTree (struct Category* Node);
WCHAR* Strings [STRING_COUNT];
void ShowMessage (WCHAR* title, WCHAR* message)
@@ -122,6 +123,7 @@ BOOL SetupControls (HWND hwnd)
// Fill the TreeViews
AddItems (hCategories, Root.Children, NULL);
return TRUE;
}
@@ -142,7 +144,6 @@ static void DrawBitmap (HWND hwnd, int x, int y, HBITMAP hBmp)
SelectObject(hdcMem, hBmp);
GetObject(hBmp, sizeof(bm), &bm);
//BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
TransparentBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, 0xFFFFFF);
DeleteDC(hdcMem);
@@ -157,7 +158,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
if(!SetupControls(hwnd))
return -1;
ShowMessage(L"ReactOS Downloader", L"Welcome to ReactOS's Downloader\nPlease choose a category on the right. This is version 0.8.");
ShowMessage(Strings[IDS_WELCOME_TITLE], Strings[IDS_WELCOME]);
}
break;
@@ -176,16 +177,15 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
if(SelectedApplication)
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_DOWNLOAD), 0, DownloadProc);
else
ShowMessage (L"No application selected", L"Please select a Application before you click the download button, if you need assistance please click on the question mark button on the top right corner.");
ShowMessage(Strings[IDS_NO_APP_TITLE], Strings[IDS_NO_APP]);
}
else if (lParam == (LPARAM)hBtnUpdate)
{
ShowMessage (L"Update", L"Feature not implemented yet.");
ShowMessage(Strings[IDS_UPDATE_TITLE], Strings[IDS_UPDATE]);
}
else if (lParam == (LPARAM)hBtnHelp)
{
ShowMessage (L"Help", L"Choose a category on the right, then choose a application and click the download button. To update the application information click the button next to the help button.");
ShowMessage(Strings[IDS_HELP_TITLE], Strings[IDS_HELP]);
}
}
}
@@ -203,13 +203,13 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
DisplayApps (hApps, Category);
if(Category->Children && !Category->Apps)
ShowMessage(Category->Name, L"Please choose a subcategory");
ShowMessage(Category->Name, Strings[IDS_SUBS]);
else if(!Category->Children && Category->Apps)
ShowMessage(Category->Name, L"Please choose a applcations");
ShowMessage(Category->Name, Strings[IDS_APPS]);
else if(Category->Children && Category->Apps)
ShowMessage(Category->Name, L"Please choose a application or a subcategory");
ShowMessage(Category->Name, Strings[IDS_BOTH]);
else
ShowMessage(Category->Name, L"Sorry, there no applications in this category yet. You can help and add more applications.");
ShowMessage(Category->Name, Strings[IDS_NO_APPS]);
}
else if(data->hwndFrom == hApps)
{
@@ -253,10 +253,20 @@ INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
LPSTR lpCmdLine, INT nCmdShow)
{
HWND hwnd;
int i;
LoadLibrary(L"riched20.dll");
InitCommonControls();
// Load strings
for(i=0; i<STRING_COUNT; i++)
{
int StringLenght = 255;
Strings[i] = malloc(StringLenght*sizeof(WCHAR));
LoadString(hInstance, i, Strings[i], StringLenght);
Strings[StringLenght]=0;
}
// Create the window
WNDCLASSEX WndClass = {0};
WndClass.cbSize = sizeof(WNDCLASSEX);
@@ -271,7 +281,7 @@ INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
RegisterClassEx(&WndClass);
hwnd = CreateWindow(L"Downloader",
L"Download ! - ReactOS Downloader",
Strings[IDS_WINDOW_TITLE],
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
@@ -291,6 +301,10 @@ INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Free strings
for(i=0; i<STRING_COUNT; i++)
free(Strings[i]);
return 0;
}
@@ -19,4 +19,20 @@
#define IDC_STATUS 0x1001
#define IDC_REMOVE 0x1002
#define IDS_WINDOW_TITLE 0x0
#define IDS_WELCOME_TITLE 0x1
#define IDS_WELCOME 0x2
#define IDS_NO_APP_TITLE 0x3
#define IDS_NO_APP 0x4
#define IDS_UPDATE_TITLE 0x5
#define IDS_UPDATE 0x6
#define IDS_HELP_TITLE 0x7
#define IDS_HELP 0x8
#define IDS_NO_APPS 0x9
#define IDS_APPS 0xA
#define IDS_SUBS 0xB
#define IDS_BOTH 0xC
#define IDS_XMLERROR_1 0xD
#define IDS_XMLERROR_2 0xE
#define STRING_COUNT 0xE
@@ -9,3 +9,22 @@ FONT 8, "MS Shell Dlg"
LTEXT "", IDC_STATUS, 10, 30, 200, 10, SS_CENTER
PUSHBUTTON "Cancel", IDCANCEL, 85, 58, 50, 15, WS_GROUP | WS_TABSTOP
}
STRINGTABLE DISCARDABLE
BEGIN
IDS_WINDOW_TITLE "Download ! - ReactOS Downloader"
IDS_WELCOME_TITLE "Welcome to the ReactOS Downloader"
IDS_WELCOME "Please choose a category on the right. This is version 0.8."
IDS_NO_APP_TITLE "No application selected"
IDS_NO_APP "Please select a Application before you click the download button, if you need assistance please click on the question mark button on the top right corner."
IDS_UPDATE_TITLE "Update"
IDS_UPDATE "Sorry this future is not implemented yet."
IDS_HELP_TITLE "Help"
IDS_HELP "Choose a category on the right, then choose a application and click the download button. To update the application information click the button next to the help button."
IDS_NO_APPS "Sorry, there no applications in this category yet. You can help and add more applications."
IDS_APPS "Please choose an application."
IDS_SUBS "Please choose a subcategory."
IDS_BOTH "Please choose a subcategory or an application."
IDS_XMLERROR_1 "Could not find the xml file !"
IDS_XMLERROR_2 "Could not parse the xml file !"
END
+4 -3
View File
@@ -16,6 +16,7 @@ BOOL TagOpen;
struct Category* Current;
struct Application* CurrentApplication;
char CurrentTag [0x100];
extern WCHAR* Strings [STRING_COUNT];
void tag_opened (void* usrdata, const char* tag, const char** arg)
{
@@ -93,7 +94,7 @@ void tag_opened (void* usrdata, const char* tag, const char** arg)
strncpy(CurrentTag, tag, 0x100);
}
else
MessageBox(0,L"Invaild XML File1",0,0);
MessageBox(0,Strings[IDS_XMLERROR_2],0,0);
}
@@ -155,7 +156,7 @@ BOOL ProcessXML (const char* filename, struct Category* Root)
FILE* file = fopen(filename, "r");
if(!file)
{
MessageBox(0,L"Could not find the xml file !",0,0);
MessageBox(0,Strings[IDS_XMLERROR_1],0,0);
return FALSE;
}
@@ -171,7 +172,7 @@ BOOL ProcessXML (const char* filename, struct Category* Root)
buffer[len] = 0;
if(!XML_Parse(parser, buffer, len, done))
{
MessageBox(0,L"Could not parse the xml file !",0,0);
MessageBox(0,Strings[IDS_XMLERROR_2],0,0);
return FALSE;
}
}