Call some more Unicode APIs explicitly.

svn path=/trunk/; revision=25214
This commit is contained in:
Maarten Bosma 2006-12-23 18:59:10 +00:00
parent d7eb6d1ba4
commit 9e9286ab0d
2 changed files with 19 additions and 20 deletions

View file

@ -38,12 +38,12 @@ void ShowMessage (WCHAR* title, WCHAR* message)
void AddItems (HWND hwnd, struct Category* Category, struct Category* Parent) void AddItems (HWND hwnd, struct Category* Category, struct Category* Parent)
{ {
TV_INSERTSTRUCT Insert; TV_INSERTSTRUCTW Insert;
Insert.item.lParam = (UINT)Category; Insert.item.lParam = (UINT)Category;
Insert.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;; Insert.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;;
Insert.item.pszText = Category->Name; //that is okay Insert.item.pszText = Category->Name;
Insert.item.cchTextMax = lstrlen(Category->Name); Insert.item.cchTextMax = lstrlenW(Category->Name);
Insert.item.iImage = Category->Icon; Insert.item.iImage = Category->Icon;
Insert.item.iSelectedImage = Category->Icon; Insert.item.iSelectedImage = Category->Icon;
Insert.hInsertAfter = TVI_LAST; Insert.hInsertAfter = TVI_LAST;
@ -74,7 +74,7 @@ void CategoryChoosen (HWND hwnd, struct Category* Category)
(void)TreeView_DeleteItem(hwnd, TVI_ROOT); (void)TreeView_DeleteItem(hwnd, TVI_ROOT);
TV_INSERTSTRUCT Insert; TV_INSERTSTRUCTW Insert;
Insert.item.mask = TVIF_TEXT|TVIF_PARAM; Insert.item.mask = TVIF_TEXT|TVIF_PARAM;
Insert.hInsertAfter = TVI_LAST; Insert.hInsertAfter = TVI_LAST;
Insert.hParent = TVI_ROOT; Insert.hParent = TVI_ROOT;
@ -85,7 +85,7 @@ void CategoryChoosen (HWND hwnd, struct Category* Category)
{ {
Insert.item.lParam = (UINT)CurrentApplication; Insert.item.lParam = (UINT)CurrentApplication;
Insert.item.pszText = CurrentApplication->Name; Insert.item.pszText = CurrentApplication->Name;
Insert.item.cchTextMax = lstrlen(CurrentApplication->Name); Insert.item.cchTextMax = lstrlenW(CurrentApplication->Name);
SendMessage(hwnd, TVM_INSERTITEM, 0, (LPARAM)&Insert); SendMessage(hwnd, TVM_INSERTITEM, 0, (LPARAM)&Insert);
CurrentApplication = CurrentApplication->Next; CurrentApplication = CurrentApplication->Next;
} }
@ -100,10 +100,10 @@ BOOL SetupControls (HWND hwnd)
return FALSE; return FALSE;
// Set up the controls // Set up the controls
hCategories = CreateWindowExW(0, WC_TREEVIEW, L"Categories", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS, hCategories = CreateWindowExW(0, WC_TREEVIEWW, L"Categories", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
0, 0, 0, 0, hwnd, NULL, hInstance, NULL); 0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
hApps = CreateWindowExW(0, WC_TREEVIEW, L"Applications", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS, hApps = CreateWindowExW(0, WC_TREEVIEWW, L"Applications", WS_CHILD|WS_VISIBLE|WS_BORDER|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_SHOWSELALWAYS,
0, 0, 0, 0, hwnd, NULL, hInstance, NULL); 0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
hLogo = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_LOGO)); hLogo = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_LOGO));
@ -118,10 +118,10 @@ BOOL SetupControls (HWND hwnd)
SendMessageW(hDownloadButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_DOWNLOAD))); SendMessageW(hDownloadButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)(HANDLE)LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_DOWNLOAD)));
// Set deflaut entry for hApps // Set deflaut entry for hApps
TV_INSERTSTRUCT Insert = {0}; TV_INSERTSTRUCTW Insert = {0};
Insert.item.mask = TVIF_TEXT; Insert.item.mask = TVIF_TEXT;
Insert.item.pszText = Strings[IDS_CHOOSE_CATEGORY]; Insert.item.pszText = Strings[IDS_CHOOSE_CATEGORY];
Insert.item.cchTextMax = lstrlen(Strings[IDS_CHOOSE_CATEGORY]); Insert.item.cchTextMax = lstrlenW(Strings[IDS_CHOOSE_CATEGORY]);
SendMessage(hApps, TVM_INSERTITEM, 0, (LPARAM)&Insert); SendMessage(hApps, TVM_INSERTITEM, 0, (LPARAM)&Insert);
// Create Tree Icons // Create Tree Icons
@ -191,7 +191,7 @@ static void DrawDescription (HDC hdc, RECT DescriptionRect)
HFONT Font = GetFont(TRUE); HFONT Font = GetFont(TRUE);
SelectObject(hdc, Font); SelectObject(hdc, Font);
RECT Rect = {DescriptionRect.left+5, DescriptionRect.top+3, DescriptionRect.right-2, DescriptionRect.top+22}; RECT Rect = {DescriptionRect.left+5, DescriptionRect.top+3, DescriptionRect.right-2, DescriptionRect.top+22};
DrawTextW(hdc, DescriptionHeadline, lstrlen(DescriptionHeadline), &Rect, DT_SINGLELINE|DT_NOPREFIX); DrawTextW(hdc, DescriptionHeadline, lstrlenW(DescriptionHeadline), &Rect, DT_SINGLELINE|DT_NOPREFIX);
DeleteObject(Font); DeleteObject(Font);
// Description // Description
@ -199,7 +199,7 @@ static void DrawDescription (HDC hdc, RECT DescriptionRect)
SelectObject(hdc, Font); SelectObject(hdc, Font);
Rect.top += 40; Rect.top += 40;
Rect.bottom = DescriptionRect.bottom-2; Rect.bottom = DescriptionRect.bottom-2;
DrawTextW(hdc, DescriptionText, lstrlen(DescriptionText), &Rect, DT_WORDBREAK|DT_NOPREFIX); // ToDo: Call TabbedTextOut to draw a nice table DrawTextW(hdc, DescriptionText, lstrlenW(DescriptionText), &Rect, DT_WORDBREAK|DT_NOPREFIX); // ToDo: Call TabbedTextOut to draw a nice table
DeleteObject(Font); DeleteObject(Font);
} }
@ -244,7 +244,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
if (lParam == (LPARAM)hDownloadButton) if (lParam == (LPARAM)hDownloadButton)
{ {
if(SelectedApplication) if(SelectedApplication)
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_DOWNLOAD), 0, DownloadProc); DialogBoxW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_DOWNLOAD), 0, DownloadProc);
else else
ShowMessage(Strings[IDS_NO_APP_TITLE], Strings[IDS_NO_APP]); ShowMessage(Strings[IDS_NO_APP_TITLE], Strings[IDS_NO_APP]);
} }
@ -332,7 +332,6 @@ INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
HWND hwnd; HWND hwnd;
int i; int i;
LoadLibrary(L"riched20.dll");
InitCommonControls(); InitCommonControls();
// Load strings // Load strings
@ -348,7 +347,7 @@ INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst,
WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN)); WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
RegisterClassEx(&WndClass); RegisterClassExW(&WndClass);
hwnd = CreateWindowW(L"Downloader", hwnd = CreateWindowW(L"Downloader",
Strings[IDS_WINDOW_TITLE], Strings[IDS_WINDOW_TITLE],

View file

@ -95,7 +95,7 @@ void tag_opened (void* usrdata, const char* tag, const char** arg)
strncpy(CurrentTag, tag, 0x100); strncpy(CurrentTag, tag, 0x100);
} }
else else
MessageBox(0,Strings[IDS_XMLERROR_2],0,0); MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
} }
@ -107,17 +107,17 @@ void text (void* usrdata, const char* data, int len)
// FIXME: handle newlines e.g. in Description // FIXME: handle newlines e.g. in Description
if(!strcmp(CurrentTag, "maintainer")) if(!strcmp(CurrentTag, "maintainer"))
{ {
int currentlengt = lstrlen(CurrentApplication->Location); int currentlengt = lstrlenW(CurrentApplication->Location);
MultiByteToWideChar(CP_ACP, 0, data, len, &CurrentApplication->Maintainer[currentlengt], 0x100-currentlengt); MultiByteToWideChar(CP_ACP, 0, data, len, &CurrentApplication->Maintainer[currentlengt], 0x100-currentlengt);
} }
else if(!strcmp(CurrentTag, "description")) else if(!strcmp(CurrentTag, "description"))
{ {
int currentlengt = lstrlen(CurrentApplication->Description); int currentlengt = lstrlenW(CurrentApplication->Description);
MultiByteToWideChar(CP_ACP, 0, data, len, &CurrentApplication->Description[currentlengt], 0x400-currentlengt); MultiByteToWideChar(CP_ACP, 0, data, len, &CurrentApplication->Description[currentlengt], 0x400-currentlengt);
} }
else if(!strcmp(CurrentTag, "location")) else if(!strcmp(CurrentTag, "location"))
{ {
int currentlengt = lstrlen(CurrentApplication->Location); int currentlengt = lstrlenW(CurrentApplication->Location);
MultiByteToWideChar(CP_ACP, 0, data, len, &CurrentApplication->Location[currentlengt], 0x100-currentlengt); MultiByteToWideChar(CP_ACP, 0, data, len, &CurrentApplication->Location[currentlengt], 0x100-currentlengt);
} }
} }
@ -157,7 +157,7 @@ BOOL ProcessXML (const char* filename, struct Category* Root)
FILE* file = fopen(filename, "r"); FILE* file = fopen(filename, "r");
if(!file) if(!file)
{ {
MessageBox(0,Strings[IDS_XMLERROR_1],0,0); MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0);
return FALSE; return FALSE;
} }
@ -173,7 +173,7 @@ BOOL ProcessXML (const char* filename, struct Category* Root)
buffer[len] = 0; buffer[len] = 0;
if(!XML_Parse(parser, buffer, len, done)) if(!XML_Parse(parser, buffer, len, done))
{ {
MessageBox(0,Strings[IDS_XMLERROR_2],0,0); MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
return FALSE; return FALSE;
} }
} }