From 1781d9334bb8090df3115f51ca813ae4cf273523 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Fri, 30 Nov 2012 20:48:31 +0000 Subject: minor unicode stuff git-svn-id: http://svn.miranda-ng.org/main/trunk@2570 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MetaContacts/src/addto.cpp | 66 +++++++++----------------------------- plugins/MetaContacts/src/icons.cpp | 22 ++++++------- 2 files changed, 27 insertions(+), 61 deletions(-) (limited to 'plugins/MetaContacts/src') diff --git a/plugins/MetaContacts/src/addto.cpp b/plugins/MetaContacts/src/addto.cpp index bfe3098bf4..e99b4cb166 100644 --- a/plugins/MetaContacts/src/addto.cpp +++ b/plugins/MetaContacts/src/addto.cpp @@ -70,56 +70,22 @@ int FillList(HWND list, BOOL sort) { // get contact display name from clist - char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hMetaUser, 0); - - if (os_unicode_enabled) { - wchar_t *ptszCDN = (wchar_t *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hMetaUser, GCDNF_UNICODE), - *swzContactDisplayName; - - // detect if the clist provided unicode display name by comparing with non-unicode - if (szCDN && ptszCDN && strncmp(szCDN, (char *)ptszCDN, strlen(szCDN)) != 0) { - swzContactDisplayName = ptszCDN; - } else { - // no? convert to unicode - if (szCDN) { - swzContactDisplayName = (wchar_t *) _alloca(sizeof(wchar_t) * (strlen(szCDN) + 1)); - MultiByteToWideChar(CP_ACP, 0, (char *) szCDN, -1, swzContactDisplayName, (int)strlen((char *)szCDN) + 1); - } else { - swzContactDisplayName = TranslateW(L"(Unknown Contact)"); - } - } - - // don't insert huge strings that we have to compare with later - if (wcslen(swzContactDisplayName) > 1023) - swzContactDisplayName[1024] = 0; - - if (sort) { - int j; - wchar_t buff[1024]; - for (j = 0; j < i; j++) { - SendMessageW(list, LB_GETTEXT, j, (LPARAM)buff); - if (wcscmp(buff, swzContactDisplayName) > 0) break; + TCHAR *swzContactDisplayName = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hMetaUser, GCDNF_TCHAR); + // don't insert huge strings that we have to compare with later + if (_tcslen(swzContactDisplayName) > 1023) + swzContactDisplayName[1024] = 0; + + if (sort) { + TCHAR buff[1024]; + for (int j = 0; j < i; j++) { + SendMessage(list, LB_GETTEXT, j, (LPARAM)buff); + if (_tcscmp(buff, swzContactDisplayName) > 0) { + index = SendMessage(list, LB_INSERTSTRING, (WPARAM)j, (LPARAM)swzContactDisplayName); + break; } - index = SendMessageW(list, LB_INSERTSTRING, (WPARAM)j, (LPARAM)swzContactDisplayName); - } else { - index = SendMessageW(list, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)swzContactDisplayName); } } else { - // don't insert huge strings that we have to compare with later - if (strlen(szCDN) > 1023) - szCDN[1024] = 0; - - if (sort) { - int j; - char buff[1024]; - for (j = 0; j < i; j++) { - SendMessage(list, LB_GETTEXT, j, (LPARAM)buff); - if (strcmp(buff, szCDN) > 0) break; - } - index = SendMessage(list, LB_INSERTSTRING, (WPARAM)j, (LPARAM)szCDN); - } else { - index = SendMessage(list, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)szCDN); - } + index = SendMessage(list, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)swzContactDisplayName); } SendMessage(list, LB_SETITEMDATA, (WPARAM)index, (LPARAM)hMetaUser); @@ -223,11 +189,11 @@ INT_PTR CALLBACK Meta_SelectDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP switch(LOWORD(wParam)) { case IDOK: { - HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - int item; // Get the index of the selected metacontact - if ((item = SendMessage(GetDlgItem(hwndDlg, IDC_METALIST),LB_GETCURSEL, 0, 0))==-1) + int item = SendMessage(GetDlgItem(hwndDlg, IDC_METALIST),LB_GETCURSEL, 0, 0); // Get the index of the selected metacontact + if (item == -1) return IDOK == MessageBox(hwndDlg, TranslateT("Please select a MetaContact"), TranslateT("No MetaContact selected"), MB_ICONHAND); + HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); HANDLE hMeta = (HANDLE)SendMessage(GetDlgItem(hwndDlg, IDC_METALIST), LB_GETITEMDATA, (WPARAM)item, 0); if ( !Meta_Assign(hContact,hMeta, FALSE)) MessageBox(hwndDlg, TranslateT("Assignment to the MetaContact failed."), TranslateT("Assignment failure"),MB_ICONERROR); diff --git a/plugins/MetaContacts/src/icons.cpp b/plugins/MetaContacts/src/icons.cpp index e56aab6195..694c28d7bd 100644 --- a/plugins/MetaContacts/src/icons.cpp +++ b/plugins/MetaContacts/src/icons.cpp @@ -1,19 +1,19 @@ #include "metacontacts.h" typedef struct { - char* szDescr; + TCHAR* szDescr; char* szName; int defIconID; } IconStruct; static IconStruct iconList[] = { - { "Toggle Off", "mc_off", IDI_MCMENUOFF }, - { "Toggle On", "mc_on", IDI_MCMENU }, - { "Convert to MetaContact", "mc_convert", IDI_MCCONVERT }, - { "Add to Existing", "mc_add", IDI_MCADD }, - { "Edit", "mc_edit", IDI_MCEDIT }, - { "Set to Default", "mc_default", IDI_MCSETDEFAULT }, - { "Remove", "mc_remove", IDI_MCREMOVE }, + { LPGENT("Toggle Off"), "mc_off", IDI_MCMENUOFF }, + { LPGENT("Toggle On"), "mc_on", IDI_MCMENU }, + { LPGENT("Convert to MetaContact"), "mc_convert", IDI_MCCONVERT }, + { LPGENT("Add to Existing"), "mc_add", IDI_MCADD }, + { LPGENT("Edit"), "mc_edit", IDI_MCEDIT }, + { LPGENT("Set to Default"), "mc_default", IDI_MCSETDEFAULT }, + { LPGENT("Remove"), "mc_remove", IDI_MCREMOVE }, }; @@ -66,12 +66,12 @@ void InitIcons(void) GetModuleFileName(hInstance, path, SIZEOF(path)); SKINICONDESC sid = { sizeof(sid) }; - sid.flags = SIDF_PATH_TCHAR; - sid.pszSection = META_PROTO; + sid.flags = SIDF_ALL_TCHAR; + sid.ptszSection = _T(META_PROTO); sid.ptszDefaultFile = path; for (int i=0; i < SIZEOF(iconList); ++i) { - sid.pszDescription = iconList[i].szDescr; + sid.ptszDescription = iconList[i].szDescr; sid.pszName = iconList[i].szName; sid.iDefaultIndex = -iconList[i].defIconID; Skin_AddIcon(&sid); -- cgit v1.2.3