From 732cfa3336e6cbd20e19fab683ad22989d13461c Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Fri, 20 Feb 2015 01:49:42 +0000 Subject: TabSRMM: wine fixes for settings. git-svn-id: http://svn.miranda-ng.org/main/trunk@12208 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/options.cpp | 75 ++++++--------------- plugins/TabSRMM/src/commonheaders.h | 11 +++ plugins/TabSRMM/src/eventpopups.cpp | 127 +++++++++-------------------------- plugins/TabSRMM/src/msgoptions.cpp | 65 ++++++++++++------ 4 files changed, 107 insertions(+), 171 deletions(-) diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 3c2af47c1b..0bbc7c8bda 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -236,10 +236,11 @@ static HTREEITEM InsertBranch(HWND hwndTree, TCHAR* pszDescr, BOOL bExpanded) TVINSERTSTRUCT tvis; tvis.hParent = NULL; tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_STATE; + tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvis.item.pszText = TranslateTS(pszDescr); - tvis.item.stateMask = (bExpanded ? TVIS_STATEIMAGEMASK | TVIS_EXPANDED : TVIS_STATEIMAGEMASK) | TVIS_BOLD; - tvis.item.state = (bExpanded ? INDEXTOSTATEIMAGEMASK(0) | TVIS_EXPANDED : INDEXTOSTATEIMAGEMASK(0)) | TVIS_BOLD; + tvis.item.stateMask = TVIS_EXPANDED | TVIS_BOLD; + tvis.item.state = (bExpanded ? TVIS_EXPANDED : 0) | TVIS_BOLD; + tvis.item.iImage = tvis.item.iSelectedImage = (bExpanded ? IMG_GRPOPEN : IMG_GRPCLOSED); return TreeView_InsertItem(hwndTree, &tvis); } @@ -248,41 +249,38 @@ static void FillBranch(HWND hwndTree, HTREEITEM hParent, branch_t *branch, int n if (hParent == 0) return; - TVINSERTSTRUCT tvis; - int iState; + TVINSERTSTRUCT tvis = { 0 }; - tvis.hParent = hParent; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_STATE; for (int i = 0; i < nValues; i++) { + tvis.hParent = hParent; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvis.item.pszText = TranslateTS(branch[i].szDescr); - tvis.item.stateMask = TVIS_STATEIMAGEMASK; if (branch[i].iMode) - iState = ((M.GetDword(CHAT_MODULE, branch[i].szDBName, defaultval) & branch[i].iMode) & branch[i].iMode) != 0 ? 3 : 2; + tvis.item.iImage = tvis.item.iSelectedImage = ((((M.GetDword(CHAT_MODULE, branch[i].szDBName, defaultval) & branch[i].iMode) & branch[i].iMode) != 0) ? IMG_CHECK : IMG_NOCHECK); else - iState = M.GetByte(CHAT_MODULE, branch[i].szDBName, branch[i].bDefault) != 0 ? 3 : 2; - tvis.item.state = INDEXTOSTATEIMAGEMASK(iState); + tvis.item.iImage = tvis.item.iSelectedImage = ((M.GetByte(CHAT_MODULE, branch[i].szDBName, branch[i].bDefault) != 0) ? IMG_CHECK : IMG_NOCHECK); branch[i].hItem = TreeView_InsertItem(hwndTree, &tvis); } } static void SaveBranch(HWND hwndTree, branch_t *branch, int nValues) { - TVITEM tvi; + TVITEM tvi = { 0 }; BYTE bChecked; - int iState = 0; + DWORD iState = 0; - tvi.mask = TVIF_HANDLE | TVIF_STATE; for (int i = 0; i < nValues; i++) { + tvi.mask = TVIF_HANDLE | TVIF_IMAGE; tvi.hItem = branch[i].hItem; TreeView_GetItem(hwndTree, &tvi); - bChecked = ((tvi.state & TVIS_STATEIMAGEMASK) >> 12 == 2) ? 0 : 1; + bChecked = ((tvi.iImage == IMG_CHECK) ? 1 : 0); if (branch[i].iMode) { if (bChecked) iState |= branch[i].iMode; if (iState & GC_EVENT_ADDSTATUS) iState |= GC_EVENT_REMOVESTATUS; - db_set_dw(0, CHAT_MODULE, branch[i].szDBName, (DWORD)iState); + db_set_dw(0, CHAT_MODULE, branch[i].szDBName, iState); } else db_set_b(0, CHAT_MODULE, branch[i].szDBName, bChecked); } @@ -399,10 +397,10 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); { - HIMAGELIST himlOptions = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_CHECKBOXES, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)CreateStateImageList()); - ImageList_Destroy(himlOptions); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CHECKBOXES), GWL_STYLE) | (TVS_NOHSCROLL)); + /* Replace image list, destroy old. */ + ImageList_Destroy(TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_CHECKBOXES), CreateStateImageList(), TVSIL_NORMAL)); hListHeading1 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance and functionality of chat room windows"), TRUE); hListHeading2 = InsertBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), TranslateT("Appearance of the message log"), TRUE); @@ -429,41 +427,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case IDC_CHECKBOXES: - if (((LPNMHDR)lParam)->code == NM_CLICK || (((LPNMHDR)lParam)->code == TVN_KEYDOWN && ((LPNMTVKEYDOWN)lParam)->wVKey == VK_SPACE)) { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN) { - if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) - hti.flags |= TVHT_ONITEMSTATEICON; - if (hti.flags&TVHT_ONITEMSTATEICON) { - TVITEM tvi = { 0 }; - - tvi.mask = TVIF_HANDLE | TVIF_STATE; - tvi.stateMask = TVIS_STATEIMAGEMASK | TVIS_BOLD; - - if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) - tvi.hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom); - else - tvi.hItem = (HTREEITEM)hti.hItem; - - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); - - if (tvi.state & TVIS_BOLD && hti.flags & TVHT_ONITEMSTATEICON) { - tvi.state = INDEXTOSTATEIMAGEMASK(0) | TVIS_BOLD; - SendDlgItemMessageA(hwndDlg, IDC_CHECKBOXES, TVM_SETITEMA, 0, (LPARAM)&tvi); - } - else if (hti.flags&TVHT_ONITEMSTATEICON) { - if (((tvi.state & TVIS_STATEIMAGEMASK) >> 12) == 3) { - tvi.state = INDEXTOSTATEIMAGEMASK(1); - SendDlgItemMessageA(hwndDlg, IDC_CHECKBOXES, TVM_SETITEMA, 0, (LPARAM)&tvi); - } - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - } + return TreeViewHandleClick(hwndDlg, ((LPNMHDR)lParam)->hwndFrom, wParam, lParam); break; case 0: @@ -502,6 +466,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM db_set_b(0, CHAT_MODULE, "Branch1Exp", b); b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; db_set_b(0, CHAT_MODULE, "Branch2Exp", b); + TreeViewDestroy(GetDlgItem(hwndDlg, IDC_CHECKBOXES)); } return FALSE; } diff --git a/plugins/TabSRMM/src/commonheaders.h b/plugins/TabSRMM/src/commonheaders.h index 0fe23c1094..069a38f10b 100644 --- a/plugins/TabSRMM/src/commonheaders.h +++ b/plugins/TabSRMM/src/commonheaders.h @@ -263,7 +263,18 @@ void DeleteCachedIcon(TLogIcon *theIcon); INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam); INT_PTR SendMessageCommand_W(WPARAM wParam, LPARAM lParam); + +#define IMG_NOCHECK 0 +#define IMG_CHECK 1 +#define IMG_GRPOPEN 2 +#define IMG_GRPCLOSED 3 HIMAGELIST CreateStateImageList(); +void TreeViewInit(HWND hwndTree, UINT id, DWORD dwFlags, BOOL bFromMem); +void TreeViewDestroy(HWND hwndTree); +void TreeViewSetFromDB(HWND hwndTree, UINT id, DWORD dwFlags); +void TreeViewToDB(HWND hwndTree, UINT id, char *DBPath, DWORD *dwFlags); +BOOL TreeViewHandleClick(HWND hwndDlg, HWND hwndTree, WPARAM wParam, LPARAM lParam); + INT_PTR CALLBACK DlgProcSetupStatusModes(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index 3faa91cc84..e2b061a203 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -150,9 +150,7 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa case WM_INITDIALOG: TranslateDialogDefault(hWnd); { - SetWindowLongPtr(GetDlgItem(hWnd, IDC_EVENTOPTIONS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hWnd, IDC_EVENTOPTIONS), GWL_STYLE) | (TVS_NOHSCROLL | TVS_CHECKBOXES)); - HIMAGELIST himl = (HIMAGELIST)SendDlgItemMessage(hWnd, IDC_EVENTOPTIONS, TVM_SETIMAGELIST, TVSIL_STATE, (LPARAM)CreateStateImageList()); - ImageList_Destroy(himl); + TreeViewInit(GetDlgItem(hWnd, IDC_EVENTOPTIONS), CTranslator::TREE_NEN, 0, TRUE); if (!PluginConfig.g_PopupAvail) { HWND hwndChild = FindWindowEx(hWnd, 0, 0, 0); @@ -164,39 +162,6 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa } else Utils::showDlgControl(hWnd, IDC_NOPOPUPAVAIL, SW_HIDE); - /* - * fill the tree view - */ - - TOptionListGroup *lGroups = CTranslator::getGroupTree(CTranslator::TREE_NEN); - for (int i=0; lGroups[i].szName != NULL; i++) { - TVINSERTSTRUCT tvi = { 0 }; - tvi.hInsertAfter = TVI_LAST; - tvi.item.mask = TVIF_TEXT | TVIF_STATE; - tvi.item.pszText = TranslateTS(lGroups[i].szName); - tvi.item.stateMask = TVIS_STATEIMAGEMASK | TVIS_EXPANDED | TVIS_BOLD; - tvi.item.state = INDEXTOSTATEIMAGEMASK(0) | TVIS_EXPANDED | TVIS_BOLD; - lGroups[i].handle = (LRESULT)TreeView_InsertItem(GetDlgItem(hWnd, IDC_EVENTOPTIONS), &tvi); - } - - TOptionListItem *defaultItems = CTranslator::getTree(CTranslator::TREE_NEN); - for (int i=0; defaultItems[i].szName != 0; i++) { - TVINSERTSTRUCT tvi = { 0 }; - tvi.hParent = (HTREEITEM)lGroups[defaultItems[i].uGroup].handle; - tvi.hInsertAfter = TVI_LAST; - tvi.item.pszText = TranslateTS(defaultItems[i].szName); - tvi.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; - tvi.item.lParam = i; - tvi.item.stateMask = TVIS_STATEIMAGEMASK; - if (defaultItems[i].uType == LOI_TYPE_SETTING) - tvi.item.state = INDEXTOSTATEIMAGEMASK(*((BOOL *)defaultItems[i].lParam) ? 3 : 2);//2 : 1); - else if (defaultItems[i].uType == LOI_TYPE_FLAG) { - UINT uVal = *((UINT *)defaultItems[i].lParam); - tvi.item.state = INDEXTOSTATEIMAGEMASK(uVal & defaultItems[i].id ? 3 : 2);//2 : 1); - } - defaultItems[i].handle = (LRESULT)TreeView_InsertItem(GetDlgItem(hWnd, IDC_EVENTOPTIONS), &tvi); - } - SendDlgItemMessage(hWnd, IDC_COLBACK_MESSAGE, CPM_SETCOLOUR, 0, options->colBackMsg); SendDlgItemMessage(hWnd, IDC_COLTEXT_MESSAGE, CPM_SETCOLOUR, 0, options->colTextMsg); SendDlgItemMessage(hWnd, IDC_COLBACK_OTHERS, CPM_SETCOLOUR, 0, options->colBackOthers); @@ -244,6 +209,12 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa } return TRUE; + case WM_DESTROY: + TreeViewDestroy(GetDlgItem(hWnd, IDC_LOGOPTIONS)); + bWmNotify = TRUE; + break; + + // configure the option page - hide most of the settings here when either IEView case DM_STATUSMASKSET: db_set_dw(0, MODULE, "statusmask", (DWORD)lParam); options->dwStatusMask = (int)lParam; @@ -321,73 +292,35 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa break; case WM_NOTIFY: - if (((LPNMHDR) lParam)->idFrom == IDC_EVENTOPTIONS && ((LPNMHDR)lParam)->code == NM_CLICK) { - TVHITTESTINFO hti; - TVITEM item = {0}; - - item.mask = TVIF_HANDLE | TVIF_STATE; - item.stateMask = TVIS_STATEIMAGEMASK | TVIS_BOLD; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) { - item.hItem = (HTREEITEM)hti.hItem; - SendDlgItemMessageA(hWnd, IDC_EVENTOPTIONS, TVM_GETITEMA, 0, (LPARAM)&item); - if (item.state & TVIS_BOLD && hti.flags & TVHT_ONITEMSTATEICON) { - item.state = INDEXTOSTATEIMAGEMASK(0) | TVIS_BOLD; - SendDlgItemMessageA(hWnd, IDC_EVENTOPTIONS, TVM_SETITEMA, 0, (LPARAM)&item); - } - else if (hti.flags&TVHT_ONITEMSTATEICON) { - if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 3) { - item.state = INDEXTOSTATEIMAGEMASK(1); - SendDlgItemMessageA(hWnd, IDC_EVENTOPTIONS, TVM_SETITEMA, 0, (LPARAM)&item); - } - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } - } - } - - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - NEN_ReadOptions(&nen_options); + switch (((LPNMHDR)lParam)->idFrom) { + case IDC_EVENTOPTIONS: + return TreeViewHandleClick(hWnd, ((LPNMHDR)lParam)->hwndFrom, wParam, lParam); break; - case PSN_APPLY: - TOptionListItem *defaultItems = CTranslator::getTree(CTranslator::TREE_NEN); - for (int i=0; defaultItems[i].szName != NULL; i++) { - TVITEM item = {0}; - item.mask = TVIF_HANDLE | TVIF_STATE; - item.hItem = (HTREEITEM)defaultItems[i].handle; - item.stateMask = TVIS_STATEIMAGEMASK; - - SendDlgItemMessageA(hWnd, IDC_EVENTOPTIONS, TVM_GETITEMA, 0, (LPARAM)&item); - if (defaultItems[i].uType == LOI_TYPE_SETTING) { - BOOL *ptr = (BOOL *)defaultItems[i].lParam; - *ptr = (item.state >> 12) == 3/*2*/ ? TRUE : FALSE; - } - else if (defaultItems[i].uType == LOI_TYPE_FLAG) { - UINT *uVal = (UINT *)defaultItems[i].lParam; - *uVal = ((item.state >> 12) == 3/*2*/) ? *uVal | defaultItems[i].id : *uVal & ~defaultItems[i].id; - } - } + default: + switch (((LPNMHDR)lParam)->code) { + case PSN_RESET: + NEN_ReadOptions(&nen_options); + break; - db_set_b(0, CHAT_MODULE, "PopupStyle", (BYTE)g_Settings.iPopupStyle); - db_set_w(NULL, CHAT_MODULE, "PopupTimeout", g_Settings.iPopupTimeout); + case PSN_APPLY: + // scan the tree view and obtain the options... + TreeViewToDB(GetDlgItem(hWnd, IDC_EVENTOPTIONS), CTranslator::TREE_NEN, NULL, NULL); - g_Settings.crPUBkgColour = SendDlgItemMessage(hWnd, IDC_COLBACK_MUC, CPM_GETCOLOUR, 0, 0); - db_set_dw(0, CHAT_MODULE, "PopupColorBG", (DWORD)g_Settings.crPUBkgColour); - g_Settings.crPUTextColour = SendDlgItemMessage(hWnd, IDC_COLTEXT_MUC, CPM_GETCOLOUR, 0, 0); - db_set_dw(0, CHAT_MODULE, "PopupColorText", (DWORD)g_Settings.crPUTextColour); + db_set_b(0, CHAT_MODULE, "PopupStyle", (BYTE)g_Settings.iPopupStyle); + db_set_w(NULL, CHAT_MODULE, "PopupTimeout", g_Settings.iPopupTimeout); - NEN_WriteOptions(&nen_options); - CheckForRemoveMask(); - CreateSystrayIcon(nen_options.bTraySupport); - SetEvent(g_hEvent); // wake up the thread which cares about the floater and tray - } - break; + g_Settings.crPUBkgColour = SendDlgItemMessage(hWnd, IDC_COLBACK_MUC, CPM_GETCOLOUR, 0, 0); + db_set_dw(0, CHAT_MODULE, "PopupColorBG", (DWORD)g_Settings.crPUBkgColour); + g_Settings.crPUTextColour = SendDlgItemMessage(hWnd, IDC_COLTEXT_MUC, CPM_GETCOLOUR, 0, 0); + db_set_dw(0, CHAT_MODULE, "PopupColorText", (DWORD)g_Settings.crPUTextColour); - case WM_DESTROY: - bWmNotify = TRUE; + NEN_WriteOptions(&nen_options); + CheckForRemoveMask(); + CreateSystrayIcon(nen_options.bTraySupport); + SetEvent(g_hEvent); // wake up the thread which cares about the floater and tray + } + } break; } diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 81cf5ea04c..bf7317480a 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -28,11 +28,6 @@ #include "commonheaders.h" -#define IMG_NOCHECK 0 -#define IMG_CHECK 1 -#define IMG_GRPOPEN 2 -#define IMG_GRPCLOSED 3 - #define DM_GETSTATUSMASK (WM_USER + 10) struct FontOptionsList @@ -387,7 +382,7 @@ static INT_PTR CALLBACK DlgProcSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L } ///////////////////////////////////////////////////////////////////////////////////////// -void TreeViewInit(HWND hwndTree, UINT id, DWORD dwFlags) +void TreeViewInit(HWND hwndTree, UINT id, DWORD dwFlags, BOOL bFromMem) { TVINSERTSTRUCT tvi = { 0 }; TOptionListGroup *lvGroups = CTranslator::getGroupTree(id); @@ -415,10 +410,25 @@ void TreeViewInit(HWND hwndTree, UINT id, DWORD dwFlags) tvi.item.pszText = TranslateTS(lvItems[i].szName); tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvi.item.lParam = i; - if (lvItems[i].uType == LOI_TYPE_FLAG) - tvi.item.iImage = tvi.item.iSelectedImage = ((dwFlags & (UINT)lvItems[i].lParam) ? IMG_CHECK : IMG_NOCHECK); - else if (lvItems[i].uType == LOI_TYPE_SETTING) - tvi.item.iImage = tvi.item.iSelectedImage = (M.GetByte((char *)lvItems[i].lParam, lvItems[i].id) ? IMG_CHECK : IMG_NOCHECK); + if (bFromMem == FALSE) { + switch (lvItems[i].uType) { + case LOI_TYPE_FLAG: + tvi.item.iImage = tvi.item.iSelectedImage = ((dwFlags & (UINT)lvItems[i].lParam) ? IMG_CHECK : IMG_NOCHECK); + break; + case LOI_TYPE_SETTING: + tvi.item.iImage = tvi.item.iSelectedImage = (M.GetByte((char *)lvItems[i].lParam, lvItems[i].id) ? IMG_CHECK : IMG_NOCHECK); + break; + } + } else { + switch (lvItems[i].uType) { + case LOI_TYPE_FLAG: + tvi.item.iImage = tvi.item.iSelectedImage = (((*((UINT*)lvItems[i].lParam)) & lvItems[i].id) ? IMG_CHECK : IMG_NOCHECK); + break; + case LOI_TYPE_SETTING: + tvi.item.iImage = tvi.item.iSelectedImage = ((*((BOOL*)lvItems[i].lParam)) ? IMG_CHECK : IMG_NOCHECK); + break; + } + } lvItems[i].handle = (LRESULT)TreeView_InsertItem(hwndTree, &tvi); } @@ -454,10 +464,24 @@ void TreeViewToDB(HWND hwndTree, UINT id, char *DBPath, DWORD *dwFlags) item.mask = TVIF_HANDLE | TVIF_IMAGE; item.hItem = (HTREEITEM)lvItems[i].handle; TreeView_GetItem(hwndTree, &item); - if (lvItems[i].uType == LOI_TYPE_FLAG && dwFlags != NULL) - (*dwFlags) |= (item.iImage == IMG_CHECK) ? lvItems[i].lParam : 0; - else if (lvItems[i].uType == LOI_TYPE_SETTING) - db_set_b(0, DBPath, (char *)lvItems[i].lParam, (BYTE)((item.iImage == IMG_CHECK) ? 1 : 0)); + + switch (lvItems[i].uType) { + case LOI_TYPE_FLAG: + if (dwFlags != NULL) + (*dwFlags) |= (item.iImage == IMG_CHECK) ? lvItems[i].lParam : 0; + if (DBPath == NULL) { + UINT *tm = (UINT*)lvItems[i].lParam; + (*tm) = (item.iImage == IMG_CHECK) ? ((*tm) | lvItems[i].id) : ((*tm) & ~lvItems[i].id); + } + break; + case LOI_TYPE_SETTING: + if (DBPath != NULL) { + db_set_b(0, DBPath, (char *)lvItems[i].lParam, (BYTE)((item.iImage == IMG_CHECK) ? 1 : 0)); + } else { + (*((BOOL*)lvItems[i].lParam)) = ((item.iImage == IMG_CHECK) ? TRUE : FALSE); + } + break; + } } } @@ -507,6 +531,8 @@ BOOL TreeViewHandleClick(HWND hwndDlg, HWND hwndTree, WPARAM wParam, LPARAM lPar } return TRUE; break; + default: + return FALSE; } item.mask = TVIF_HANDLE | TVIF_IMAGE; @@ -538,8 +564,9 @@ BOOL TreeViewHandleClick(HWND hwndDlg, HWND hwndTree, WPARAM wParam, LPARAM lPar if (item.mask & TVIF_STATE) { RedrawWindow(hwndTree, NULL, NULL, RDW_INVALIDATE | RDW_NOFRAME | RDW_ERASENOW | RDW_ALLCHILDREN); InvalidateRect(hwndTree, NULL, TRUE); + } else { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); return TRUE; } @@ -552,7 +579,7 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { - TreeViewInit(GetDlgItem(hwndDlg, IDC_WINDOWOPTIONS), CTranslator::TREE_MSG, 0); + TreeViewInit(GetDlgItem(hwndDlg, IDC_WINDOWOPTIONS), CTranslator::TREE_MSG, 0, FALSE); SetDlgItemInt(hwndDlg, IDC_MAXAVATARHEIGHT, M.GetDword("avatarheight", 100), FALSE); CheckDlgButton(hwndDlg, IDC_PRESERVEAVATARSIZE, M.GetByte("dontscaleavatars", 0) ? BST_CHECKED : BST_UNCHECKED); @@ -648,7 +675,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, break; } - TreeViewInit(GetDlgItem(hwndDlg, IDC_LOGOPTIONS), CTranslator::TREE_LOG, dwFlags); + TreeViewInit(GetDlgItem(hwndDlg, IDC_LOGOPTIONS), CTranslator::TREE_LOG, dwFlags, FALSE); SendDlgItemMessage(hwndDlg, IDC_LOADCOUNTSPIN, UDM_SETRANGE, 0, MAKELONG(100, 0)); SendDlgItemMessage(hwndDlg, IDC_LOADCOUNTSPIN, UDM_SETPOS, 0, db_get_w(NULL, SRMSGMOD, SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT)); @@ -980,7 +1007,7 @@ static INT_PTR CALLBACK DlgProcTabbedOptions(HWND hwndDlg, UINT msg, WPARAM wPar case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - TreeViewInit(GetDlgItem(hwndDlg, IDC_TABMSGOPTIONS), CTranslator::TREE_TAB, 0); + TreeViewInit(GetDlgItem(hwndDlg, IDC_TABMSGOPTIONS), CTranslator::TREE_TAB, 0, FALSE); CheckDlgButton(hwndDlg, IDC_CUT_TABTITLE, M.GetByte("cuttitle", 0) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_CUT_TITLEMAXSPIN, UDM_SETRANGE, 0, MAKELONG(20, 5)); @@ -1147,7 +1174,7 @@ INT_PTR CALLBACK PlusOptionsProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lPar case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - TreeViewInit(GetDlgItem(hwndDlg, IDC_PLUS_CHECKTREE), CTranslator::TREE_MODPLUS, 0); + TreeViewInit(GetDlgItem(hwndDlg, IDC_PLUS_CHECKTREE), CTranslator::TREE_MODPLUS, 0, FALSE); SendDlgItemMessage(hwndDlg, IDC_TIMEOUTSPIN, UDM_SETRANGE, 0, MAKELONG(300, SRMSGSET_MSGTIMEOUT_MIN / 1000)); SendDlgItemMessage(hwndDlg, IDC_TIMEOUTSPIN, UDM_SETPOS, 0, PluginConfig.m_MsgTimeout / 1000); -- cgit v1.2.3