From ea68d4474bb7329a5e59e0388b88155b96f31f7c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 1 Jun 2016 09:11:39 +0000 Subject: - view modes support incorporated into the CLIST_INTERFACE; - fix for the broken search by protocols in clist_nicer; - numerous Unicode fixes in clist_nicer; git-svn-id: http://svn.miranda-ng.org/main/trunk@16893 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/src/clc.cpp | 2 +- plugins/Clist_nicer/src/clc.h | 12 +- plugins/Clist_nicer/src/clcitems.cpp | 7 +- plugins/Clist_nicer/src/clnplus.cpp | 2 - plugins/Clist_nicer/src/clui.cpp | 27 +- plugins/Clist_nicer/src/init.cpp | 1 + plugins/Clist_nicer/src/viewmodes.cpp | 657 +++++++++++++++++----------------- 7 files changed, 342 insertions(+), 366 deletions(-) (limited to 'plugins/Clist_nicer/src') diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 97748297a4..fb81cdbefa 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -139,7 +139,7 @@ static int ClcSettingChanged(WPARAM hContact, LPARAM lParam) SendMessage(pcli->hwndContactTree, INTM_STATUSCHANGED, hContact, lParam); return 0; } - + if (strstr("YMsg|StatusDescr|XStatusMsg", cws->szSetting)) SendMessage(pcli->hwndContactTree, INTM_STATUSMSGCHANGED, hContact, lParam); else if (strstr(cws->szSetting, "XStatus")) diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h index 2585013914..91b917162f 100644 --- a/plugins/Clist_nicer/src/clc.h +++ b/plugins/Clist_nicer/src/clc.h @@ -405,21 +405,21 @@ int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BO void FreeProtocolData( void ); void GetClientID(ClcContact *contact, char *client); -int LoadCLCButtonModule(void); +int LoadCLCButtonModule(void); void SetButtonStates(); void ConfigureCLUIGeometry(int mode); void IcoLibReloadIcons(); -int CompareContacts(const ClcContact* p1, const ClcContact* p2); +int CompareContacts(const ClcContact* p1, const ClcContact* p2); void PaintNotifyArea(HDC hDC, RECT *rc); -int AvatarChanged(WPARAM wParam, LPARAM lParam); +int AvatarChanged(WPARAM wParam, LPARAM lParam); void ConfigureFrame(); void ConfigureEventArea(); void ClearIcons(int mode); void SkinDrawBg(HWND hwnd, HDC hdc); -int GetBasicFontID(ClcContact * contact); -extern int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szStatus, struct ClcData *dat); +int GetBasicFontID(ClcContact *contact); +int CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szStatus, struct ClcData *dat); void CreateViewModeFrame(); -int GetExtraCache(MCONTACT hContact, char *szProto); +int GetExtraCache(MCONTACT hContact, char *szProto); void ReloadExtraInfo(MCONTACT hContact); void LoadAvatarForContact(ClcContact *p); void ApplyViewMode(const char *name); diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 452fc2863d..a015a15740 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -373,7 +373,7 @@ void LoadSkinItemToCache(TExtraCache *cEntry) * also cares about sub contacts (if meta is active) */ -int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, struct ClcData *dat) +int CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, struct ClcData *dat) { int dbHidden = db_get_b(hContact, "CList", "Hidden", 0); // default hidden state, always respect it. @@ -410,8 +410,9 @@ int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, str ptrT tszGroup(db_get_tsa(hContact, "CList", "Group")); if (tszGroup != NULL) { TCHAR szGroupMask[256]; - mir_sntprintf(szGroupMask, _T("%s|"), LPTSTR(tszGroup)+1); - filterResult = (cfg::dat.filterFlags & CLVM_PROTOGROUP_OP) ? (filterResult | (_tcsstr(cfg::dat.groupFilter, szGroupMask) ? 1 : 0)) : (filterResult & (_tcsstr(cfg::dat.groupFilter, szGroupMask) ? 1 : 0)); + mir_sntprintf(szGroupMask, _T("%s|"), tszGroup); + int bHasGroup = _tcsstr(cfg::dat.groupFilter, szGroupMask) ? 1 : 0; + filterResult = (cfg::dat.filterFlags & CLVM_PROTOGROUP_OP) ? (filterResult | bHasGroup) : (filterResult & bHasGroup); } else if (cfg::dat.filterFlags & CLVM_INCLUDED_UNGROUPED) filterResult = (cfg::dat.filterFlags & CLVM_PROTOGROUP_OP) ? filterResult : filterResult & 1; diff --git a/plugins/Clist_nicer/src/clnplus.cpp b/plugins/Clist_nicer/src/clnplus.cpp index a59b2ef982..b150537963 100644 --- a/plugins/Clist_nicer/src/clnplus.cpp +++ b/plugins/Clist_nicer/src/clnplus.cpp @@ -8,8 +8,6 @@ #define _CLN_GDIP -#undef Translate - void RemoveFromTaskBar(HWND hWnd) { CComPtr pTaskbarList; diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index 65d9b83add..178962e422 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -205,7 +205,7 @@ static int CreateCLC() Frame.TBtname = TranslateT("My contacts"); Frame.height = 200; hFrameContactTree = (HWND)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_TBTIPNAME, hFrameContactTree), (LPARAM)Translate("My contacts")); + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_TBTIPNAME | FO_TCHAR, hFrameContactTree), (LPARAM)TranslateT("My contacts")); // ugly, but working hack. Prevent that annoying little scroll bar from appearing in the "My Contacts" title bar DWORD flags = (DWORD)CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, hFrameContactTree), 0); @@ -1415,10 +1415,9 @@ skipbg: if (!contactOK) MessageBox(0, TranslateT("The requested action requires a valid contact selection. Please select a contact from the contact list and repeat."), TranslateT("Parameter mismatch"), MB_OK); if (serviceFailure) { - char szError[512]; - - mir_snprintf(szError, Translate("The service %s specified by the %s button definition was not found. You may need to install additional plugins."), item->szService, item->szName); - MessageBoxA(0, szError, Translate("Service failure"), MB_OK); + TCHAR szError[512]; + mir_sntprintf(szError, TranslateT("The service %S specified by the %S button definition was not found. You may need to install additional plugins."), item->szService, item->szName); + MessageBox(NULL, szError, TranslateT("Service failure"), MB_OK); } break; } @@ -1555,10 +1554,8 @@ buttons_done: case WM_LBUTTONDOWN: if (g_ButtonItems) { - POINT ptMouse, pt; - - GetCursorPos(&ptMouse); - pt = ptMouse; + POINT pt; + GetCursorPos(&pt); return SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); } break; @@ -1578,12 +1575,10 @@ buttons_done: { NMCLISTCONTROL *nm = (NMCLISTCONTROL *)lParam; DWORD hitFlags; - HANDLE hItem; - - hItem = (HANDLE)SendMessage(pcli->hwndContactTree, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); - + SendMessage(pcli->hwndContactTree, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); if ((hitFlags & (CLCHT_NOWHERE | CLCHT_INLEFTMARGIN | CLCHT_BELOWITEMS)) == 0) break; + if (db_get_b(NULL, "CLUI", "ClientAreaDrag", SETTING_CLIENTDRAG_DEFAULT)) { POINT pt; pt = nm->pt; @@ -1830,10 +1825,10 @@ INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_SETFONT, (WPARAM)hFont, 0); } { - char str[64]; + TCHAR str[64]; DWORD v = pluginInfo.version; - mir_snprintf(str, "%s %d.%d.%d.%d", Translate("Version"), HIBYTE(HIWORD(v)), LOBYTE(HIWORD(v)), HIBYTE(LOWORD(v)), LOBYTE(LOWORD(v))); - SetDlgItemTextA(hwndDlg, IDC_VERSION, str); + mir_sntprintf(str, _T("%s %d.%d.%d.%d"), TranslateT("Version"), HIBYTE(HIWORD(v)), LOBYTE(HIWORD(v)), HIBYTE(LOWORD(v)), LOBYTE(LOWORD(v))); + SetDlgItemText(hwndDlg, IDC_VERSION, str); } { HICON hIcon = LoadIcon(GetModuleHandleA("miranda32.exe"), MAKEINTRESOURCE(102)); diff --git a/plugins/Clist_nicer/src/init.cpp b/plugins/Clist_nicer/src/init.cpp index eb83a1df9d..27b7742c62 100644 --- a/plugins/Clist_nicer/src/init.cpp +++ b/plugins/Clist_nicer/src/init.cpp @@ -191,6 +191,7 @@ extern "C" int __declspec(dllexport) CListInitialise() pcli->pfnCompareContacts = CompareContacts; pcli->pfnCreateClcContact = CreateClcContact; pcli->pfnDocking_ProcessWindowMessage = Docking_ProcessWindowMessage; + pcli->pfnGetContactHiddenStatus = CLVM_GetContactHiddenStatus; pcli->pfnGetDefaultFontSetting = GetDefaultFontSetting; pcli->pfnGetRowBottomY = RowHeight::getItemBottomY; pcli->pfnGetRowHeight = RowHeight::getHeight; diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index 5a403a317f..eb7c557e63 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HPEN g_hPenCLUIFrames; extern FRAMEWND *wndFrameViewMode; -typedef int (__cdecl *pfnEnumCallback)(char *szName); +typedef int(__cdecl *pfnEnumCallback)(char *szName); static HWND sttClvmHwnd = 0; static int sttClvm_curItem = 0; HMENU hViewModeMenu = 0; @@ -44,13 +44,13 @@ static char sttModeName[2048]; static int g_ViewModeOptDlg = FALSE; -static UINT _page1Controls[] = {IDC_STATIC1, IDC_STATIC2, IDC_STATIC3, IDC_STATIC5, IDC_STATIC4, - IDC_STATIC8, IDC_ADDVIEWMODE, IDC_DELETEVIEWMODE, IDC_NEWVIEMODE, IDC_GROUPS, IDC_PROTOCOLS, - IDC_VIEWMODES, IDC_STATUSMODES, IDC_STATIC12, IDC_STATIC13, IDC_STATIC14, IDC_PROTOGROUPOP, IDC_GROUPSTATUSOP, - IDC_AUTOCLEAR, IDC_AUTOCLEARVAL, IDC_AUTOCLEARSPIN, IDC_STATIC15, IDC_STATIC16, - IDC_LASTMESSAGEOP, IDC_LASTMESSAGEUNIT, IDC_LASTMSG, IDC_LASTMSGVALUE, 0}; +static UINT _page1Controls[] = { IDC_STATIC1, IDC_STATIC2, IDC_STATIC3, IDC_STATIC5, IDC_STATIC4, +IDC_STATIC8, IDC_ADDVIEWMODE, IDC_DELETEVIEWMODE, IDC_NEWVIEMODE, IDC_GROUPS, IDC_PROTOCOLS, +IDC_VIEWMODES, IDC_STATUSMODES, IDC_STATIC12, IDC_STATIC13, IDC_STATIC14, IDC_PROTOGROUPOP, IDC_GROUPSTATUSOP, +IDC_AUTOCLEAR, IDC_AUTOCLEARVAL, IDC_AUTOCLEARSPIN, IDC_STATIC15, IDC_STATIC16, +IDC_LASTMESSAGEOP, IDC_LASTMESSAGEUNIT, IDC_LASTMSG, IDC_LASTMSGVALUE, 0 }; -static UINT _page2Controls[] = {IDC_CLIST, IDC_STATIC9, IDC_STATIC8, IDC_CLEARALL, IDC_CURVIEWMODE2, 0}; +static UINT _page2Controls[] = { IDC_CLIST, IDC_STATIC9, IDC_STATIC8, IDC_CLEARALL, IDC_CURVIEWMODE2, 0 }; /* * enumerate all view modes, call the callback function with the mode name @@ -70,7 +70,7 @@ void CLVM_EnumModes(pfnEnumCallback EnumCallback) DBCONTACTENUMSETTINGS dbces; dbces.pfnEnumProc = CLVM_EnumProc; dbces.szModule = CLVM_MODULE; - dbces.ofsSettings=0; + dbces.ofsSettings = 0; dbces.lParam = (LPARAM)EnumCallback; CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces); } @@ -122,7 +122,7 @@ static int UpdateClistItem(MCONTACT hContact, DWORD mask) { for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, hContact, MAKELONG(i - ID_STATUS_OFFLINE, - (1 << (i - ID_STATUS_OFFLINE)) & mask ? i - ID_STATUS_OFFLINE : nullImage)); + (1 << (i - ID_STATUS_OFFLINE)) & mask ? i - ID_STATUS_OFFLINE : nullImage)); return 0; } @@ -151,35 +151,36 @@ static void UpdateStickies() SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hInfoItem, MAKELONG(i - ID_STATUS_OFFLINE, (1 << (i - ID_STATUS_OFFLINE)) & sttStickyStatusMask ? i - ID_STATUS_OFFLINE : ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1)); HANDLE hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_ROOT, 0); - hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP, (LPARAM)hItem); + hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); while (hItem) { for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELONG(i - ID_STATUS_OFFLINE, nullImage)); - hItem=(HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem); + hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } ShowPage(sttClvmHwnd, 0); } static int FillDialog(HWND hwnd) { - LVCOLUMN lvc = {0}; + LVCOLUMN lvc = { 0 }; HWND hwndList = GetDlgItem(hwnd, IDC_PROTOCOLS); - LVITEM item = {0}; + LVITEM item = { 0 }; int protoCount = 0, i; PROTOACCOUNT **accs = 0; CLVM_EnumModes(FillModes); - ListView_SetExtendedListViewStyle(GetDlgItem(hwnd, IDC_PROTOCOLS), LVS_EX_CHECKBOXES); + ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES); lvc.mask = LVCF_FMT; lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_PROTOCOLS), 0, &lvc); + ListView_InsertColumn(hwndList, 0, &lvc); // fill protocols... - Proto_EnumAccounts( &protoCount, &accs ); - item.mask = LVIF_TEXT; + Proto_EnumAccounts(&protoCount, &accs); + item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = 1000; for (i = 0; i < protoCount; i++) { + item.lParam = (LPARAM)accs[i]->szModuleName; item.pszText = accs[i]->tszAccountName; ListView_InsertItem(hwndList, &item); } @@ -263,7 +264,7 @@ static void SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int while (hItem) { iOldIcon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); if (iOldIcon != EMPTY_EXTRA_ICON && iOldIcon != iImage) - SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn,iImage)); + SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } } @@ -283,7 +284,7 @@ static void SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int if (hItem == hItemAll) SetAllChildIcons(hwndList, hItem, iColumn, iImage); else - SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn,iImage)); //hItemUnknown + SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); //hItemUnknown } else if (itemType == CLCIT_GROUP) { int oldiImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); @@ -321,44 +322,37 @@ void SaveState() { CMString newGroupFilter(_T("|")); CMStringA newProtoFilter("|"); - int i; - HWND hwndList; - char *szModeName = NULL; DWORD statusMask = 0; - HANDLE hItem; DWORD operators = 0; if (sttClvm_curItem == -1) return; { - LVITEMA item = {0}; - char szTemp[256]; + LVITEM item = { 0 }; + item.mask = LVIF_PARAM; - hwndList = GetDlgItem(sttClvmHwnd, IDC_PROTOCOLS); - for (i = 0; i < ListView_GetItemCount(hwndList); i++) { + HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_PROTOCOLS); + for (int i = 0; i < ListView_GetItemCount(hwndList); i++) { if (ListView_GetCheckState(hwndList, i)) { - item.mask = LVIF_TEXT; - item.pszText = szTemp; - item.cchTextMax = _countof(szTemp); item.iItem = i; - SendMessageA(hwndList, LVM_GETITEMA, 0, (LPARAM)&item); - - newProtoFilter.Append(szTemp); + ListView_GetItem(hwndList, &item); + + newProtoFilter.Append((char*)item.lParam); newProtoFilter.AppendChar('|'); } } } { - LVITEM item = {0}; + LVITEM item = { 0 }; TCHAR szTemp[256]; - hwndList = GetDlgItem(sttClvmHwnd, IDC_GROUPS); + HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_GROUPS); operators |= ListView_GetCheckState(hwndList, 0) ? CLVM_INCLUDED_UNGROUPED : 0; - for (i = 0; i < ListView_GetItemCount(hwndList); i++) { + for (int i = 0; i < ListView_GetItemCount(hwndList); i++) { if (ListView_GetCheckState(hwndList, i)) { item.mask = LVIF_TEXT; item.pszText = szTemp; @@ -371,28 +365,25 @@ void SaveState() } } } - hwndList = GetDlgItem(sttClvmHwnd, IDC_STATUSMODES); - for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) + + HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_STATUSMODES); + for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) if (ListView_GetCheckState(hwndList, i - ID_STATUS_OFFLINE)) statusMask |= (1 << (i - ID_STATUS_OFFLINE)); int iLen = SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, sttClvm_curItem, 0); if (iLen) { - unsigned int stickies = 0; - DWORD dwGlobalMask, dwLocalMask; - BOOL translated; - - szModeName = (char*)malloc(iLen + 1); + char *szModeName = (char*)malloc(iLen + 1); if (szModeName) { - DWORD options, lmdat; SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXT, sttClvm_curItem, (LPARAM)szModeName); - dwGlobalMask = GetMaskForItem(hInfoItem); + DWORD dwGlobalMask = GetMaskForItem(hInfoItem); + unsigned int stickies = 0; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); + HANDLE hItem = (HANDLE)SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); if (hItem) { if (SendDlgItemMessage(sttClvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { - dwLocalMask = GetMaskForItem(hItem); + DWORD dwLocalMask = GetMaskForItem(hItem); db_set_dw(hContact, "CLVM", szModeName, MAKELONG(1, (unsigned short)dwLocalMask)); stickies++; } @@ -406,15 +397,14 @@ void SaveState() (IsDlgButtonChecked(sttClvmHwnd, IDC_AUTOCLEAR) ? CLVM_AUTOCLEAR : 0) | (IsDlgButtonChecked(sttClvmHwnd, IDC_LASTMSG) ? CLVM_USELASTMSG : 0)); - options = SendDlgItemMessage(sttClvmHwnd, IDC_AUTOCLEARSPIN, UDM_GETPOS, 0, 0); + DWORD options = SendDlgItemMessage(sttClvmHwnd, IDC_AUTOCLEARSPIN, UDM_GETPOS, 0, 0); - lmdat = MAKELONG(GetDlgItemInt(sttClvmHwnd, IDC_LASTMSGVALUE, &translated, FALSE), + BOOL translated; + DWORD lmdat = MAKELONG(GetDlgItemInt(sttClvmHwnd, IDC_LASTMSGVALUE, &translated, FALSE), MAKEWORD(SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEOP, CB_GETCURSEL, 0, 0), SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEUNIT, CB_GETCURSEL, 0, 0))); - SaveViewMode(szModeName, newGroupFilter, newProtoFilter, statusMask, dwGlobalMask, options, - stickies, operators, lmdat); - //free(vastring); + SaveViewMode(szModeName, newGroupFilter, newProtoFilter, statusMask, dwGlobalMask, options, stickies, operators, lmdat); free(szModeName); } } @@ -425,11 +415,9 @@ void SaveState() // updates the filter list boxes with the data taken from the filtering string void UpdateFilters() { - DBVARIANT dbv_pf = {0}; - DBVARIANT dbv_gf = {0}; + DBVARIANT dbv_pf = { 0 }; + DBVARIANT dbv_gf = { 0 }; char szSetting[128]; - char *szBuf = NULL; - int iLen; DWORD statusMask = 0; DWORD dwFlags; DWORD opt; @@ -437,62 +425,63 @@ void UpdateFilters() if (sttClvm_curItem == LB_ERR) return; - iLen = SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, sttClvm_curItem, 0); - + int iLen = SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXTLEN, sttClvm_curItem, 0); if (iLen == 0) return; - szBuf = (char *)malloc(iLen + 1); + char *szBuf = (char *)malloc(iLen + 1); SendDlgItemMessageA(sttClvmHwnd, IDC_VIEWMODES, LB_GETTEXT, sttClvm_curItem, (LPARAM)szBuf); - strncpy(sttModeName, szBuf, sizeof(sttModeName)); - sttModeName[sizeof(sttModeName) - 1] = 0; + mir_strncpy(sttModeName, szBuf, sizeof(sttModeName)); { - char szTemp[100]; - mir_snprintf(szTemp, Translate("Current view mode: %s"), sttModeName); - SetDlgItemTextA(sttClvmHwnd, IDC_CURVIEWMODE2, szTemp); + TCHAR szTemp[100]; + mir_sntprintf(szTemp, TranslateT("Current view mode: %S"), sttModeName); + SetDlgItemText(sttClvmHwnd, IDC_CURVIEWMODE2, szTemp); } + mir_snprintf(szSetting, "%c%s_PF", 246, szBuf); if (db_get(NULL, CLVM_MODULE, szSetting, &dbv_pf)) goto cleanup; + mir_snprintf(szSetting, "%c%s_GF", 246, szBuf); if (db_get_ts(NULL, CLVM_MODULE, szSetting, &dbv_gf)) goto cleanup; + mir_snprintf(szSetting, "%c%s_OPT", 246, szBuf); if ((opt = db_get_dw(NULL, CLVM_MODULE, szSetting, -1)) != -1) { SendDlgItemMessage(sttClvmHwnd, IDC_AUTOCLEARSPIN, UDM_SETPOS, 0, MAKELONG(LOWORD(opt), 0)); } + mir_snprintf(szSetting, "%c%s_SM", 246, szBuf); statusMask = db_get_dw(NULL, CLVM_MODULE, szSetting, -1); + mir_snprintf(szSetting, "%c%s_SSM", 246, szBuf); sttStickyStatusMask = db_get_dw(NULL, CLVM_MODULE, szSetting, -1); + dwFlags = db_get_dw(NULL, CLVM_MODULE, szBuf, 0); { - LVITEMA item = {0}; - char szTemp[256]; char szMask[256]; - int i; HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_PROTOCOLS); - item.mask = LVIF_TEXT; - item.pszText = szTemp; - item.cchTextMax = _countof(szTemp); + LVITEM item = { 0 }; + item.mask = LVIF_PARAM; - for (i = 0; i < ListView_GetItemCount(hwndList); i++) { + for (int i = 0; i < ListView_GetItemCount(hwndList); i++) { item.iItem = i; - SendMessageA(hwndList, LVM_GETITEMA, 0, (LPARAM)&item); - mir_snprintf(szMask, "%s|", szTemp); - if (dbv_pf.pszVal && strstr(dbv_pf.pszVal, szMask)) - ListView_SetCheckState(hwndList, i, TRUE) - else - ListView_SetCheckState(hwndList, i, FALSE); + ListView_GetItem(hwndList, &item); + mir_snprintf(szMask, "%s|", (char*)item.lParam); + if (dbv_pf.pszVal && strstr(dbv_pf.pszVal, szMask)) { + ListView_SetCheckState(hwndList, i, TRUE); + } + else { + ListView_SetCheckState(hwndList, i, FALSE); + } } } { - LVITEM item = {0}; + LVITEM item = { 0 }; TCHAR szTemp[256]; TCHAR szMask[256]; - int i; HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_GROUPS); item.mask = LVIF_TEXT; @@ -501,28 +490,29 @@ void UpdateFilters() ListView_SetCheckState(hwndList, 0, dwFlags & CLVM_INCLUDED_UNGROUPED ? TRUE : FALSE); - for (i = 1; i < ListView_GetItemCount(hwndList); i++) { + for (int i = 1; i < ListView_GetItemCount(hwndList); i++) { item.iItem = i; SendMessage(hwndList, LVM_GETITEM, 0, (LPARAM)&item); mir_sntprintf(szMask, _T("%s|"), szTemp); - if (dbv_gf.ptszVal && _tcsstr(dbv_gf.ptszVal, szMask)) - ListView_SetCheckState(hwndList, i, TRUE) - else + if (dbv_gf.ptszVal && _tcsstr(dbv_gf.ptszVal, szMask)) { + ListView_SetCheckState(hwndList, i, TRUE); + } + else { ListView_SetCheckState(hwndList, i, FALSE); + } } } { HWND hwndList = GetDlgItem(sttClvmHwnd, IDC_STATUSMODES); - int i; - - for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { if ((1 << (i - ID_STATUS_OFFLINE)) & statusMask) ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, TRUE) else - ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, FALSE); + ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, FALSE); } } + SendDlgItemMessage(sttClvmHwnd, IDC_PROTOGROUPOP, CB_SETCURSEL, dwFlags & CLVM_PROTOGROUP_OP ? 1 : 0, 0); SendDlgItemMessage(sttClvmHwnd, IDC_GROUPSTATUSOP, CB_SETCURSEL, dwFlags & CLVM_GROUPSTATUS_OP ? 1 : 0, 0); CheckDlgButton(sttClvmHwnd, IDC_AUTOCLEAR, dwFlags & CLVM_AUTOCLEAR ? BST_CHECKED : BST_UNCHECKED); @@ -561,64 +551,64 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP switch (msg) { case WM_INITDIALOG: - { - int i = 0; - TCITEMA tci; - RECT rcClient; - CLCINFOITEM cii = {0}; - HICON hIcon; - - if (IS_THEMED) - EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB); + if (IS_THEMED) + EnableThemeDialogTexture(hwndDlg, ETDT_ENABLETAB); - himlViewModes = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 12, 0); - for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) - ImageList_AddIcon(himlViewModes, Skin_LoadProtoIcon(NULL, i)); - - hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MINIMIZE), IMAGE_ICON, 16, 16, 0); + himlViewModes = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 12, 0); + for (int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) + ImageList_AddIcon(himlViewModes, Skin_LoadProtoIcon(NULL, i)); + { + HICON hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MINIMIZE), IMAGE_ICON, 16, 16, 0); nullImage = ImageList_AddIcon(himlViewModes, hIcon); DestroyIcon(hIcon); - GetClientRect(hwndDlg, &rcClient); + } - tci.mask = TCIF_PARAM | TCIF_TEXT; - tci.lParam = 0; - tci.pszText = Translate("Sticky contacts"); - SendDlgItemMessageA(hwndDlg, IDC_TAB, TCM_INSERTITEMA, 0, (LPARAM)&tci); + RECT rcClient; + GetClientRect(hwndDlg, &rcClient); - tci.pszText = Translate("Filtering"); - SendDlgItemMessageA(hwndDlg, IDC_TAB, TCM_INSERTITEMA, 0, (LPARAM)&tci); + TCITEM tci; + tci.mask = TCIF_PARAM | TCIF_TEXT; + tci.lParam = 0; + tci.pszText = TranslateT("Sticky contacts"); + SendDlgItemMessage(hwndDlg, IDC_TAB, TCM_INSERTITEM, 0, (LPARAM)&tci); - TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TAB), 0); + tci.pszText = TranslateT("Filtering"); + SendDlgItemMessage(hwndDlg, IDC_TAB, TCM_INSERTITEM, 0, (LPARAM)&tci); - TranslateDialogDefault(hwndDlg); - FillDialog(hwndDlg); - Utils::enableDlgControl(hwndDlg, IDC_ADDVIEWMODE, FALSE); + TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TAB), 0); - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)himlViewModes); - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETEXTRACOLUMNS, ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE, 0); + TranslateDialogDefault(hwndDlg); + FillDialog(hwndDlg); + Utils::enableDlgControl(hwndDlg, IDC_ADDVIEWMODE, FALSE); + + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)himlViewModes); + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETEXTRACOLUMNS, ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE, 0); + { + CLCINFOITEM cii = { 0 }; cii.cbSize = sizeof(cii); cii.hParentGroup = 0; cii.pszText = LPGENT("*** All contacts ***"); hInfoItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0); - if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) { - sttClvm_curItem = 0; - UpdateFilters(); - } - else - sttClvm_curItem = -1; - g_ViewModeOptDlg = TRUE; - i = 0; - while (_page2Controls[i] != 0) - ShowWindow(GetDlgItem(hwndDlg, _page2Controls[i++]), SW_HIDE); - ShowWindow(hwndDlg, SW_SHOWNORMAL); - Utils::enableDlgControl(hwndDlg, IDC_APPLY, FALSE); - SendDlgItemMessage(hwndDlg, IDC_AUTOCLEARSPIN, UDM_SETRANGE, 0, MAKELONG(1000, 0)); - SetWindowText(hwndDlg, TranslateT("Configure view modes")); - return TRUE; } + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0); + if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) { + sttClvm_curItem = 0; + UpdateFilters(); + } + else sttClvm_curItem = -1; + + g_ViewModeOptDlg = TRUE; + + for (int i = 0; _page2Controls[i] != 0; i++) + ShowWindow(GetDlgItem(hwndDlg, _page2Controls[i]), SW_HIDE); + ShowWindow(hwndDlg, SW_SHOWNORMAL); + Utils::enableDlgControl(hwndDlg, IDC_APPLY, FALSE); + SendDlgItemMessage(hwndDlg, IDC_AUTOCLEARSPIN, UDM_SETRANGE, 0, MAKELONG(1000, 0)); + SetWindowText(hwndDlg, TranslateT("Configure view modes")); + return TRUE; + case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_PROTOGROUPOP: case IDC_GROUPSTATUSOP: case IDC_LASTMESSAGEUNIT: @@ -636,90 +626,86 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP Utils::enableDlgControl(hwndDlg, IDC_LASTMESSAGEUNIT, bUseLastMsg); Utils::enableDlgControl(hwndDlg, IDC_LASTMSGVALUE, bUseLastMsg); Utils::enableDlgControl(hwndDlg, IDC_APPLY, TRUE); - break; } + break; case IDC_AUTOCLEARVAL: case IDC_LASTMSGVALUE: if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam) Utils::enableDlgControl(hwndDlg, IDC_APPLY, TRUE); break; case IDC_DELETEVIEWMODE: - { - if (MessageBoxA(0, Translate("Really delete this view mode? This cannot be undone"), Translate("Delete a view mode"), MB_YESNO | MB_ICONQUESTION) == IDYES) { - char szSetting[256]; - int iLen = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXTLEN, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0); - if (iLen) { - char *szBuf = (char*)malloc(iLen + 1); - if (szBuf) { - SendDlgItemMessageA(hwndDlg, IDC_VIEWMODES, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), (LPARAM)szBuf); - mir_snprintf(szSetting, "%c%s_PF", 246, szBuf); - db_unset(NULL, CLVM_MODULE, szSetting); - mir_snprintf(szSetting, "%c%s_GF", 246, szBuf); - db_unset(NULL, CLVM_MODULE, szSetting); - mir_snprintf(szSetting, "%c%s_SM", 246, szBuf); - db_unset(NULL, CLVM_MODULE, szSetting); - mir_snprintf(szSetting, "%c%s_VA", 246, szBuf); - db_unset(NULL, CLVM_MODULE, szSetting); - mir_snprintf(szSetting, "%c%s_SSM", 246, szBuf); - db_unset(NULL, CLVM_MODULE, szSetting); - db_unset(NULL, CLVM_MODULE, szBuf); - if (!mir_strcmp(cfg::dat.current_viewmode, szBuf) && mir_strlen(szBuf) == mir_strlen(cfg::dat.current_viewmode)) { - cfg::dat.bFilterEffective = 0; - pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); - SetWindowTextA(hwndSelector, Translate("No view mode")); - } - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) - if (db_get_dw(hContact, "CLVM", szBuf, -1) != -1) - db_set_dw(hContact, "CLVM", szBuf, 0); - - SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0); - if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) { - sttClvm_curItem = 0; - UpdateFilters(); - } - else - sttClvm_curItem = -1; - free(szBuf); + if (MessageBox(0, TranslateT("Really delete this view mode? This cannot be undone"), TranslateT("Delete a view mode"), MB_YESNO | MB_ICONQUESTION) == IDYES) { + char szSetting[256]; + int iLen = SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETTEXTLEN, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0); + if (iLen) { + char *szBuf = (char*)malloc(iLen + 1); + if (szBuf) { + SendDlgItemMessageA(hwndDlg, IDC_VIEWMODES, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), (LPARAM)szBuf); + mir_snprintf(szSetting, "%c%s_PF", 246, szBuf); + db_unset(NULL, CLVM_MODULE, szSetting); + mir_snprintf(szSetting, "%c%s_GF", 246, szBuf); + db_unset(NULL, CLVM_MODULE, szSetting); + mir_snprintf(szSetting, "%c%s_SM", 246, szBuf); + db_unset(NULL, CLVM_MODULE, szSetting); + mir_snprintf(szSetting, "%c%s_VA", 246, szBuf); + db_unset(NULL, CLVM_MODULE, szSetting); + mir_snprintf(szSetting, "%c%s_SSM", 246, szBuf); + db_unset(NULL, CLVM_MODULE, szSetting); + db_unset(NULL, CLVM_MODULE, szBuf); + if (!mir_strcmp(cfg::dat.current_viewmode, szBuf) && mir_strlen(szBuf) == mir_strlen(cfg::dat.current_viewmode)) { + cfg::dat.bFilterEffective = 0; + pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); + SetWindowText(hwndSelector, TranslateT("No view mode")); } + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) + if (db_get_dw(hContact, "CLVM", szBuf, -1) != -1) + db_set_dw(hContact, "CLVM", szBuf, 0); + + SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_GETCURSEL, 0, 0), 0); + if (SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, 0, 0) != LB_ERR) { + sttClvm_curItem = 0; + UpdateFilters(); + } + else sttClvm_curItem = -1; + free(szBuf); } } - break; } + break; + case IDC_ADDVIEWMODE: - { - char szBuf[256]; - - szBuf[0] = 0; - GetDlgItemTextA(hwndDlg, IDC_NEWVIEMODE, szBuf, _countof(szBuf)); - szBuf[255] = 0; - - if (mir_strlen(szBuf) > 2) { - if (db_get_dw(NULL, CLVM_MODULE, szBuf, -1) != -1) - MessageBox(0, TranslateT("A view mode with this name does already exist"), TranslateT("Duplicate name"), MB_OK); - else { - int iNewItem = SendDlgItemMessageA(hwndDlg, IDC_VIEWMODES, LB_INSERTSTRING, -1, (LPARAM)szBuf); - if (iNewItem != LB_ERR) { - SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, (WPARAM)iNewItem, 0); - SaveViewMode(szBuf, _T(""), "", -1, -1, 0, 0, 0, 0); - sttClvm_curItem = iNewItem; - UpdateStickies(); - SendDlgItemMessage(hwndDlg, IDC_PROTOGROUPOP, CB_SETCURSEL, 0, 0); - SendDlgItemMessage(hwndDlg, IDC_GROUPSTATUSOP, CB_SETCURSEL, 0, 0); - } + char szBuf[256]; + + szBuf[0] = 0; + GetDlgItemTextA(hwndDlg, IDC_NEWVIEMODE, szBuf, _countof(szBuf)); + szBuf[255] = 0; + + if (mir_strlen(szBuf) > 2) { + if (db_get_dw(NULL, CLVM_MODULE, szBuf, -1) != -1) + MessageBox(0, TranslateT("A view mode with this name does already exist"), TranslateT("Duplicate name"), MB_OK); + else { + int iNewItem = SendDlgItemMessageA(hwndDlg, IDC_VIEWMODES, LB_INSERTSTRING, -1, (LPARAM)szBuf); + if (iNewItem != LB_ERR) { + SendDlgItemMessage(hwndDlg, IDC_VIEWMODES, LB_SETCURSEL, (WPARAM)iNewItem, 0); + SaveViewMode(szBuf, _T(""), "", -1, -1, 0, 0, 0, 0); + sttClvm_curItem = iNewItem; + UpdateStickies(); + SendDlgItemMessage(hwndDlg, IDC_PROTOGROUPOP, CB_SETCURSEL, 0, 0); + SendDlgItemMessage(hwndDlg, IDC_GROUPSTATUSOP, CB_SETCURSEL, 0, 0); } - SetDlgItemTextA(hwndDlg, IDC_NEWVIEMODE, ""); } - Utils::enableDlgControl(hwndDlg, IDC_ADDVIEWMODE, FALSE); - break; + SetDlgItemTextA(hwndDlg, IDC_NEWVIEMODE, ""); } + Utils::enableDlgControl(hwndDlg, IDC_ADDVIEWMODE, FALSE); + break; + case IDC_CLEARALL: - { - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); - if (hItem) - SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 0); - } + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); + if (hItem) + SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 0); } + case IDOK: case IDC_APPLY: SaveState(); @@ -728,10 +714,12 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (LOWORD(wParam) == IDOK) DestroyWindow(hwndDlg); break; + case IDCANCEL: DestroyWindow(hwndDlg); break; } + if (LOWORD(wParam) == IDC_NEWVIEMODE && HIWORD(wParam) == EN_CHANGE) Utils::enableDlgControl(hwndDlg, IDC_ADDVIEWMODE, TRUE); if (LOWORD(wParam) == IDC_VIEWMODES && HIWORD(wParam) == LBN_SELCHANGE) { @@ -740,50 +728,51 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP UpdateFilters(); } break; + case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->idFrom) { - case IDC_GROUPS: - case IDC_STATUSMODES: - case IDC_PROTOCOLS: - case IDC_CLIST: - if (((LPNMHDR)lParam)->code == NM_CLICK || ((LPNMHDR)lParam)->code == CLN_CHECKCHANGED) - Utils::enableDlgControl(hwndDlg, IDC_APPLY, TRUE); - - switch (((LPNMHDR)lParam)->code) { - case NM_CLICK: - { - NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam; - if (nm->iColumn == -1) - break; - - DWORD hitFlags; - HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST,CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); - if (hItem == NULL || !(hitFlags & CLCHT_ONITEMEXTRA)) - break; - - int iImage = SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); - if (iImage == nullImage) - iImage = nm->iColumn; - else if (iImage != EMPTY_EXTRA_ICON) - iImage = nullImage; - SetIconsForColumn(GetDlgItem(hwndDlg, IDC_CLIST), hItem, hInfoItem, nm->iColumn, iImage); + switch (((LPNMHDR)lParam)->idFrom) { + case IDC_GROUPS: + case IDC_STATUSMODES: + case IDC_PROTOCOLS: + case IDC_CLIST: + if (((LPNMHDR)lParam)->code == NM_CLICK || ((LPNMHDR)lParam)->code == CLN_CHECKCHANGED) + Utils::enableDlgControl(hwndDlg, IDC_APPLY, TRUE); + + switch (((LPNMHDR)lParam)->code) { + case NM_CLICK: + { + NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam; + if (nm->iColumn == -1) break; - } - } - break; - case IDC_TAB: - if (((LPNMHDR)lParam)->code == TCN_SELCHANGE) { - int id = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB)); - if (id == 0) - ShowPage(hwndDlg, 0); - else - ShowPage(hwndDlg, 1); + + DWORD hitFlags; + HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); + if (hItem == NULL || !(hitFlags & CLCHT_ONITEMEXTRA)) + break; + + int iImage = SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); + if (iImage == nullImage) + iImage = nm->iColumn; + else if (iImage != EMPTY_EXTRA_ICON) + iImage = nullImage; + SetIconsForColumn(GetDlgItem(hwndDlg, IDC_CLIST), hItem, hInfoItem, nm->iColumn, iImage); break; } } break; + + case IDC_TAB: + if (((LPNMHDR)lParam)->code == TCN_SELCHANGE) { + int id = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB)); + if (id == 0) + ShowPage(hwndDlg, 0); + else + ShowPage(hwndDlg, 1); + break; + } } + break; + case WM_DESTROY: ImageList_RemoveAll(himlViewModes); ImageList_Destroy(himlViewModes); @@ -827,22 +816,21 @@ struct } static _buttons[] = { - { IDC_RESETMODES, "CLN_CLVM_reset" }, - { IDC_SELECTMODE, "CLN_CLVM_select" }, - { IDC_CONFIGUREMODES, "CLN_CLVM_options" } + { IDC_RESETMODES, "CLN_CLVM_reset" }, + { IDC_SELECTMODE, "CLN_CLVM_select" }, + { IDC_CONFIGUREMODES, "CLN_CLVM_options" } }; LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: + hwndSelector = CreateWindowEx(0, MIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 20, 20, + hwnd, (HMENU)IDC_SELECTMODE, g_hInst, NULL); + CustomizeButton(hwndSelector, false, false, false); + SendMessage(hwndSelector, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select a view mode"), BATF_UNICODE); + SendMessage(hwndSelector, BUTTONSETSENDONDOWN, TRUE, 0); { - hwndSelector = CreateWindowEx(0, MIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 20, 20, - hwnd, (HMENU)IDC_SELECTMODE, g_hInst, NULL); - CustomizeButton(hwndSelector, false, false, false); - SendMessage(hwndSelector, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select a view mode"), BATF_UNICODE); - SendMessage(hwndSelector, BUTTONSETSENDONDOWN, TRUE, 0); - HWND hwndButton = CreateWindowEx(0, MIRANDABUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 20, 20, hwnd, (HMENU)IDC_CONFIGUREMODES, g_hInst, NULL); CustomizeButton(hwndButton, false, false, false); @@ -852,10 +840,11 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM hwnd, (HMENU)IDC_RESETMODES, g_hInst, NULL); CustomizeButton(hwndButton, false, false, false); SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear view mode and return to default display"), BATF_UNICODE); - - SendMessage(hwnd, WM_USER + 100, 0, 0); - return FALSE; } + + SendMessage(hwnd, WM_USER + 100, 0, 0); + return FALSE; + case WM_NCCALCSIZE: { BOOL hasTitleBar = wndFrameViewMode ? wndFrameViewMode->TitleBar.ShowTitleBar : 0; @@ -866,9 +855,10 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM BOOL hasTitleBar = wndFrameViewMode ? wndFrameViewMode->TitleBar.ShowTitleBar : 0; return FrameNCPaint(hwnd, DefWindowProc, wParam, lParam, hasTitleBar); } + case WM_SIZE: + RECT rcCLVMFrame; { - RECT rcCLVMFrame; HDWP PosBatch = BeginDeferWindowPos(3); GetClientRect(hwnd, &rcCLVMFrame); PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_RESETMODES), 0, @@ -878,8 +868,9 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_SELECTMODE), 0, 2, 1, rcCLVMFrame.right - 50, 20, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS); EndDeferWindowPos(PosBatch); - break; } + break; + case WM_USER + 100: { bool bSkinned = db_get_b(NULL, "CLCExt", "bskinned", 0) != 0; @@ -900,12 +891,12 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; case WM_PAINT: + PAINTSTRUCT ps; { - PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); - RECT rc; HDC hdcMem = CreateCompatibleDC(hdc); + RECT rc; GetClientRect(hwnd, &rc); HBITMAP hbm = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); HBITMAP hbmold = (HBITMAP)SelectObject(hdcMem, hbm); @@ -920,81 +911,79 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM DeleteObject(hbm); DeleteDC(hdcMem); EndPaint(hwnd, &ps); - return 0; } - case WM_TIMER: - { - switch(wParam) { - case TIMERID_VIEWMODEEXPIRE: - { - POINT pt; - RECT rcCLUI; + return 0; - GetWindowRect(pcli->hwndContactList, &rcCLUI); - GetCursorPos(&pt); - if (PtInRect(&rcCLUI, pt)) - break; + case WM_TIMER: + switch (wParam) { + case TIMERID_VIEWMODEEXPIRE: + { + POINT pt; + RECT rcCLUI; - KillTimer(hwnd, wParam); - if (!cfg::dat.old_viewmode[0]) - SendMessage(hwnd, WM_COMMAND, IDC_RESETMODES, 0); - else - ApplyViewMode((const char *)cfg::dat.old_viewmode); + GetWindowRect(pcli->hwndContactList, &rcCLUI); + GetCursorPos(&pt); + if (PtInRect(&rcCLUI, pt)) break; - } } - break; + + KillTimer(hwnd, wParam); + if (!cfg::dat.old_viewmode[0]) + SendMessage(hwnd, WM_COMMAND, IDC_RESETMODES, 0); + else + ApplyViewMode((const char *)cfg::dat.old_viewmode); + break; + } } + break; + case WM_COMMAND: - { - switch (LOWORD(wParam)) { - case IDC_SELECTMODE: - { - RECT rc; - POINT pt; - int selection; - MENUITEMINFOA mii = {0}; - char szTemp[256]; + switch (LOWORD(wParam)) { + case IDC_SELECTMODE: + BuildViewModeMenu(); - BuildViewModeMenu(); - //GetWindowRect(GetDlgItem(hwnd, IDC_SELECTMODE), &rc); - GetWindowRect((HWND)lParam, &rc); - pt.x = rc.left; - pt.y = rc.bottom; - selection = TrackPopupMenu(hViewModeMenu, TPM_RETURNCMD | TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL); - if (selection) { - - if (selection == 10001) - goto clvm_config_command; - else if (selection == 10002) - goto clvm_reset_command; - - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STRING; - mii.dwTypeData = szTemp; - mii.cch = 256; - if(GetMenuItemInfoA(hViewModeMenu, selection, FALSE, &mii)) - ApplyViewMode(szTemp); - } - break; + RECT rc; + GetWindowRect((HWND)lParam, &rc); + { + POINT pt; + pt.x = rc.left; + pt.y = rc.bottom; + int selection = TrackPopupMenu(hViewModeMenu, TPM_RETURNCMD | TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL); + if (selection) { + if (selection == 10001) + goto clvm_config_command; + else if (selection == 10002) + goto clvm_reset_command; + + char szTemp[256]; + MENUITEMINFOA mii = { 0 }; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING; + mii.dwTypeData = szTemp; + mii.cch = 256; + if (GetMenuItemInfoA(hViewModeMenu, selection, FALSE, &mii)) + ApplyViewMode(szTemp); } - case IDC_RESETMODES: + } + break; + + case IDC_RESETMODES: clvm_reset_command: - cfg::dat.bFilterEffective = 0; - pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); - SetDlgItemTextA(hwnd, IDC_SELECTMODE, Translate("No view mode")); - CallService(MS_CLIST_SETHIDEOFFLINE, (WPARAM)cfg::dat.boldHideOffline, 0); - cfg::dat.boldHideOffline = (BYTE)-1; - SetButtonStates(); - cfg::dat.current_viewmode[0] = 0; - cfg::dat.old_viewmode[0] = 0; - db_set_s(NULL, "CList", "LastViewMode", ""); - break; - case IDC_CONFIGUREMODES: + cfg::dat.bFilterEffective = 0; + pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); + SetDlgItemText(hwnd, IDC_SELECTMODE, TranslateT("No view mode")); + CallService(MS_CLIST_SETHIDEOFFLINE, (WPARAM)cfg::dat.boldHideOffline, 0); + cfg::dat.boldHideOffline = (BYTE)-1; + SetButtonStates(); + cfg::dat.current_viewmode[0] = 0; + cfg::dat.old_viewmode[0] = 0; + db_set_s(NULL, "CList", "LastViewMode", ""); + break; + + case IDC_CONFIGUREMODES: clvm_config_command: - if (!g_ViewModeOptDlg) - CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_OPT_VIEWMODES), 0, DlgProcViewModesSetup, 0); - break; - } + if (!g_ViewModeOptDlg) + CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_OPT_VIEWMODES), 0, DlgProcViewModesSetup, 0); + break; } break; @@ -1009,8 +998,8 @@ HWND g_hwndViewModeFrame; void CreateViewModeFrame() { - CLISTFrame frame = {0}; - WNDCLASS wndclass = {0}; + CLISTFrame frame = { 0 }; + WNDCLASS wndclass = { 0 }; wndclass.style = 0; wndclass.lpfnWndProc = ViewModeFrameWndProc; @@ -1022,7 +1011,6 @@ void CreateViewModeFrame() wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE); wndclass.lpszMenuName = 0; wndclass.lpszClassName = _T("CLVMFrameWindow"); - RegisterClass(&wndclass); memset(&frame, 0, sizeof(frame)); @@ -1043,29 +1031,23 @@ const char *MakeVariablesString(const char *src, const char *UIN); void ApplyViewMode(const char *name) { - char szSetting[256]; - DBVARIANT dbv = {0}; - cfg::dat.bFilterEffective = 0; + char szSetting[256]; mir_snprintf(szSetting, "%c%s_PF", 246, name); - if (!db_get_s(NULL, CLVM_MODULE, szSetting, &dbv)) { - if (mir_strlen(dbv.pszVal) >= 2) { - strncpy(cfg::dat.protoFilter, dbv.pszVal, sizeof(cfg::dat.protoFilter)); - cfg::dat.protoFilter[sizeof(cfg::dat.protoFilter) - 1] = 0; - cfg::dat.bFilterEffective |= CLVM_FILTER_PROTOS; - } - mir_free(dbv.pszVal); + ptrA szProtos(db_get_sa(NULL, CLVM_MODULE, szSetting)); + if (mir_strlen(szProtos) >= 2) { + strncpy_s(cfg::dat.protoFilter, szProtos, _TRUNCATE); + cfg::dat.bFilterEffective |= CLVM_FILTER_PROTOS; } + mir_snprintf(szSetting, "%c%s_GF", 246, name); - if (!db_get_ts(NULL, CLVM_MODULE, szSetting, &dbv)) { - if (mir_tstrlen(dbv.ptszVal) >= 2) { - _tcsncpy(cfg::dat.groupFilter, dbv.ptszVal, _countof(cfg::dat.groupFilter)); - cfg::dat.groupFilter[_countof(cfg::dat.groupFilter) - 1] = 0; - cfg::dat.bFilterEffective |= CLVM_FILTER_GROUPS; - } - mir_free(dbv.ptszVal); + ptrT tszGroups(db_get_tsa(NULL, CLVM_MODULE, szSetting)); + if (mir_tstrlen(tszGroups) >= 2) { + _tcsncpy_s(cfg::dat.groupFilter, tszGroups, _TRUNCATE); + cfg::dat.bFilterEffective |= CLVM_FILTER_GROUPS; } + mir_snprintf(szSetting, "%c%s_SM", 246, name); cfg::dat.statusMaskFilter = db_get_dw(NULL, CLVM_MODULE, szSetting, -1); if (cfg::dat.statusMaskFilter >= 1) @@ -1088,8 +1070,7 @@ void ApplyViewMode(const char *name) cfg::dat.old_viewmode[255] = 0; SetTimer(g_hwndViewModeFrame, TIMERID_VIEWMODEEXPIRE, timerexpire * 1000, NULL); } - strncpy(cfg::dat.current_viewmode, name, 256); - cfg::dat.current_viewmode[255] = 0; + strncpy_s(cfg::dat.current_viewmode, name, _TRUNCATE); if (cfg::dat.filterFlags & CLVM_USELASTMSG) { BYTE bSaved = cfg::dat.sortOrder[0]; -- cgit v1.2.3