From e48bae4c6ccf1003916b3960f30816ce8aaa955b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 31 May 2015 21:02:26 +0000 Subject: - additional operator LPARAM() for _A2T & _T2A; - we don't need StrConvA anymore; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@13952 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/miranda.h | 15 --------------- src/core/stdchat/src/window.cpp | 4 ++-- src/core/stdfile/src/filesenddlg.cpp | 2 +- src/core/stduserinfo/src/contactinfo.cpp | 16 ++++++++-------- src/modules/chat/clist.cpp | 2 +- src/modules/chat/tools.cpp | 2 +- src/modules/clist/genmenuopt.cpp | 2 +- src/modules/protocols/protoaccs.cpp | 2 +- src/modules/protocols/protoint.cpp | 8 ++++---- src/modules/protocols/protoopts.cpp | 2 +- 10 files changed, 20 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/core/miranda.h b/src/core/miranda.h index 2609052789..c5008e358a 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -172,21 +172,6 @@ int AssertInsideScreen(RECT &rc); HBITMAP ConvertIconToBitmap(HICON hIcon, HIMAGELIST hIml, int iconId); -class StrConvA -{ -private: - char* m_body; - -public: - StrConvA(const wchar_t* pSrc) : - m_body(mir_u2a(pSrc)) {} - - ~StrConvA() { mir_free(m_body); } - operator const char* () const { return m_body; } - operator const wchar_t* () const { return (wchar_t*)m_body; } // type cast to fake the interface definition - operator const LPARAM () const { return (LPARAM)m_body; } -}; - /////////////////////////////////////////////////////////////////////////////// extern "C" diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 3a7969746e..806fa9a128 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -357,11 +357,11 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (wParam <= '9' && wParam >= '1' && isCtrl && !isAlt) // CTRL + 1 -> 9 (switch tab) if (g_Settings.bTabsEnable) - SendMessage(GetParent(hwnd), GC_SWITCHTAB, 0, (LPARAM)((int)wParam - (int)'1')); + SendMessage(GetParent(hwnd), GC_SWITCHTAB, 0, (int)wParam - (int)'1'); if (wParam <= VK_NUMPAD9 && wParam >= VK_NUMPAD1 && isCtrl && !isAlt) // CTRL + 1 -> 9 (switch tab) if (g_Settings.bTabsEnable) - SendMessage(GetParent(hwnd), GC_SWITCHTAB, 0, (LPARAM)((int)wParam - (int)VK_NUMPAD1)); + SendMessage(GetParent(hwnd), GC_SWITCHTAB, 0, (int)wParam - (int)VK_NUMPAD1); if (wParam == VK_TAB && !isCtrl && !isShift) { //tab-autocomplete TCHAR* pszText = NULL; diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp index fc410095cb..bb4128b9dd 100644 --- a/src/core/stdfile/src/filesenddlg.cpp +++ b/src/core/stdfile/src/filesenddlg.cpp @@ -141,7 +141,7 @@ void __cdecl ChooseFilesThread(void* param) TCHAR *buf = (TCHAR*)mir_alloc(sizeof(TCHAR) * 32767); if (buf == NULL) { - PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, (LPARAM)(TCHAR*)NULL); + PostMessage(hwndDlg, M_FILECHOOSEDONE, 0, NULL); return; } diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index 1e82742ef7..301371a4ef 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -267,7 +267,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP LVITEM lvi; lvi.mask = LVIF_TEXT|LVIF_PARAM; - lvi.lParam = (LPARAM)(-1); + lvi.lParam = -1; lvi.iSubItem = 0; lvi.iItem = 0; for (i = -1;; i++) { @@ -303,12 +303,12 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lvi.iItem++; } lvi.mask = LVIF_PARAM; - lvi.lParam = (LPARAM)(-2); + lvi.lParam = -2; ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); //phones ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES)); lvi.mask = LVIF_TEXT|LVIF_PARAM; - lvi.lParam = (LPARAM)(-1); + lvi.lParam = -1; lvi.iSubItem = 0; lvi.iItem = 0; if ( !db_get_ts(hContact, szProto, "Phone", &dbv)) { @@ -368,7 +368,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lvi.iItem++; } lvi.mask = LVIF_PARAM; - lvi.lParam = (LPARAM)(-2); + lvi.lParam = -2; ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); } } @@ -410,9 +410,9 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } HICON hIcon = NULL; - if (nm->nmcd.lItemlParam == (LPARAM)(-2) && nm->iSubItem-3 == (nm->nmcd.hdr.idFrom == IDC_PHONES)) + if (nm->nmcd.lItemlParam == -2 && nm->iSubItem-3 == (nm->nmcd.hdr.idFrom == IDC_PHONES)) hIcon = LoadSkinIcon(SKINICON_OTHER_ADDCONTACT); - else if (nm->iSubItem>1 && nm->nmcd.lItemlParam != (LPARAM)(-1) && nm->nmcd.lItemlParam != (LPARAM)(-2)) { + else if (nm->iSubItem>1 && nm->nmcd.lItemlParam != -1 && nm->nmcd.lItemlParam != -2) { static int iconResources[3] = {SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE}; if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) { TCHAR szText[2]; @@ -455,8 +455,8 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lvi.iItem = hti.iItem; lvi.iSubItem = 0; ListView_GetItem(nm->hdr.hwndFrom, &lvi); - if (lvi.lParam == (LPARAM)(-1)) break; - if (lvi.lParam == (LPARAM)(-2)) { + if (lvi.lParam == -1) break; + if (lvi.lParam == -2) { if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { //add char szNewData[256] = "", idstr[33]; diff --git a/src/modules/chat/clist.cpp b/src/modules/chat/clist.cpp index 8f8535eea1..4306806568 100644 --- a/src/modules/chat/clist.cpp +++ b/src/modules/chat/clist.cpp @@ -93,7 +93,7 @@ BOOL SetAllOffline(BOOL bHide, const char *pszModule) continue; int i = db_get_b(hContact, szProto, "ChatRoom", 0); if (i != 0) { - db_set_w(hContact, szProto, "ApparentMode", (LPARAM)(WORD)0); + db_set_w(hContact, szProto, "ApparentMode", 0); db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); } } diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp index e20b59111f..fd4044515f 100644 --- a/src/modules/chat/tools.cpp +++ b/src/modules/chat/tools.cpp @@ -332,7 +332,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight if (bInactive && !(si->wState & STATE_TALK)) { si->wState |= STATE_TALK; - db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD)40071); + db_set_w(si->hContact, si->pszModule, "ApparentMode", ID_STATUS_OFFLINE); } if (ci.OnFlashWindow) ci.OnFlashWindow(si, bInactive); diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp index dd5d537c8c..7a2339ed47 100644 --- a/src/modules/clist/genmenuopt.cpp +++ b/src/modules/clist/genmenuopt.cpp @@ -355,7 +355,7 @@ public: PD->pos = ((MenuItemOptData *)tvi.lParam)->pos - 1; TVINSERTSTRUCT tvis = { 0 }; - tvis.item.lParam = (LPARAM)(PD); + tvis.item.lParam = (LPARAM)PD; tvis.item.pszText = PD->name; tvis.item.iImage = tvis.item.iSelectedImage = 1; tvis.hInsertAfter = hti; diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp index 06a7268a6f..9e99d22ae5 100644 --- a/src/modules/protocols/protoaccs.cpp +++ b/src/modules/protocols/protoaccs.cpp @@ -418,7 +418,7 @@ static INT_PTR stub44(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam) static INT_PTR stub45(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam) { - return CallProtoServiceInt(NULL, ppi->m_szModuleName, PS_SETMYAVATARW, wParam, (LPARAM)(LPCTSTR)_A2T((char*)lParam)); + return CallProtoServiceInt(NULL, ppi->m_szModuleName, PS_SETMYAVATARW, wParam, _A2T((char*)lParam)); } static HANDLE CreateProtoServiceEx(const char* szModule, const char* szService, MIRANDASERVICEOBJ pFunc, void* param) diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp index e8c834c45a..6f9624f9f5 100644 --- a/src/modules/protocols/protoint.cpp +++ b/src/modules/protocols/protoint.cpp @@ -66,7 +66,7 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE if (m_iVersion > 1) return (int)ProtoCallService(m_szModuleName, PS_AUTHDENY, hDbEvent, (LPARAM)szReason); - return (int)ProtoCallService(m_szModuleName, PS_AUTHDENY, hDbEvent, (LPARAM)StrConvA(szReason)); + return (int)ProtoCallService(m_szModuleName, PS_AUTHDENY, hDbEvent, _T2A(szReason)); } int __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT *evt) @@ -152,14 +152,14 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE if (m_iVersion > 1) return (HANDLE)ProtoCallService(m_szModuleName, PS_BASICSEARCH, 0, (LPARAM)id); - return (HANDLE)ProtoCallService(m_szModuleName, PS_BASICSEARCH, 0, (LPARAM)StrConvA(id)); + return (HANDLE)ProtoCallService(m_szModuleName, PS_BASICSEARCH, 0, _T2A(id)); } HANDLE __cdecl SearchByEmail(const TCHAR* email) { if (m_iVersion > 1) return (HANDLE)ProtoCallService(m_szModuleName, PS_SEARCHBYEMAIL, 0, (LPARAM)email); - return (HANDLE)ProtoCallService(m_szModuleName, PS_SEARCHBYEMAIL, 0, (LPARAM)StrConvA(email)); + return (HANDLE)ProtoCallService(m_szModuleName, PS_SEARCHBYEMAIL, 0, _T2A(email)); } HANDLE __cdecl SearchByName(const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName) @@ -270,7 +270,7 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE { if (m_iVersion > 1) return (int)ProtoCallService(m_szModuleName, PS_SETAWAYMSG, iStatus, (LPARAM)msg); - return (int)ProtoCallService(m_szModuleName, PS_SETAWAYMSG, iStatus, (LPARAM)StrConvA(msg)); + return (int)ProtoCallService(m_szModuleName, PS_SETAWAYMSG, iStatus, _T2A(msg)); } int __cdecl UserIsTyping(MCONTACT hContact, int type) diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp index 10968a73b2..48cb033202 100644 --- a/src/modules/protocols/protoopts.cpp +++ b/src/modules/protocols/protoopts.cpp @@ -355,7 +355,7 @@ static LRESULT CALLBACK AccListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA mir_subclassWindow(dat->hwndEdit, sttEditSubclassProc); SendMessage(dat->hwndEdit, WM_SETFONT, (WPARAM)parentDat->hfntTitle, 0); SendMessage(dat->hwndEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN | EC_USEFONTINFO, 0); - SendMessage(dat->hwndEdit, EM_SETSEL, 0, (LPARAM)(-1)); + SendMessage(dat->hwndEdit, EM_SETSEL, 0, -1); ShowWindow(dat->hwndEdit, SW_SHOW); } SetFocus(dat->hwndEdit); -- cgit v1.2.3