LRESULT CBrowseDocker::OnRefresh(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if (m_rightClickNode != NULL) { HTREEITEM hChild = TreeView_GetChild(m_view->m_hWnd, m_rightClickNode); if (hChild) { bool expanded = (TreeView_GetItemState(m_view->m_hWnd, m_rightClickNode, TVIS_EXPANDED) & TVIS_EXPANDED) == TVIS_EXPANDED; TreeView_Expand(m_view->m_hWnd, m_rightClickNode, TVE_COLLAPSERESET | TVE_COLLAPSE); /*while(hChild) { TreeView_DeleteItem(m_view->m_hWnd, hChild); hChild = TreeView_GetChild(m_view->m_hWnd, m_rightClickNode); }*/ if (expanded) { TreeView_Expand(m_view->m_hWnd, m_rightClickNode, TVE_EXPAND); } } } return 0; }
void CAddBookmarkDialog::SaveTreeViewExpansionState(HWND hTreeView,HTREEITEM hItem) { UINT uState = TreeView_GetItemState(hTreeView,hItem,TVIS_EXPANDED); if(uState & TVIS_EXPANDED) { CBookmarkFolder &BookmarkFolder = m_pBookmarkTreeView->GetBookmarkFolderFromTreeView(hItem); m_pabdps->m_setExpansion.insert(BookmarkFolder.GetGUID()); HTREEITEM hChild = TreeView_GetChild(hTreeView,hItem); SaveTreeViewExpansionState(hTreeView,hChild); while((hChild = TreeView_GetNextSibling(hTreeView,hChild)) != NULL) { SaveTreeViewExpansionState(hTreeView,hChild); } } }
void CCList::SelectGroups(HTREEITEM hCurItem, bool bSelected) { // select/deselect all child items HTREEITEM hItem = TreeView_GetChild(hTreeView, hCurItem); HTREEITEM hLimitItem = GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_NOTCHILD, hCurItem); while (hItem && hItem != hLimitItem) { TreeView_SetItemState(hTreeView, hItem, bSelected ? TVIS_SELECTED : 0, TVIS_SELECTED); Array_SetItemState(hItem, bSelected); hItem = GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_MULTILEVEL, hItem); } // select/deselect all parent groups hCurItem = TreeView_GetParent(hTreeView, hCurItem); if (bSelected) { while (hCurItem) { // select until we'll find an unselected item or until we'll reach the root hItem = TreeView_GetChild(hTreeView, hCurItem); while (hItem) { // walk through all siblings if (!(TreeView_GetItemState(hTreeView, hItem, TVIS_SELECTED) & TVIS_SELECTED)) break; hItem = TreeView_GetNextSibling(hTreeView, hItem); } if (hItem) // means there was at least one unselected item break; TreeView_SetItemState(hTreeView, hCurItem, TVIS_SELECTED, TVIS_SELECTED); Array_SetItemState(hCurItem, true); hCurItem = TreeView_GetParent(hTreeView, hCurItem); } } while (hCurItem) { // and deselect all remaining parent groups TreeView_SetItemState(hTreeView, hCurItem, 0, TVIS_SELECTED); Array_SetItemState(hCurItem, false); hCurItem = TreeView_GetParent(hTreeView, hCurItem); } }
INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_AUDIO_CONFIGURE: configureAudioDriver(hDlg); break; case IDC_AUDIO_TEST: if(!PlaySound(MAKEINTRESOURCE(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC)) MessageBox(NULL, "Audio test failed!", "Error", MB_OK | MB_ICONERROR); break; case IDC_AUDIO_CONTROL_PANEL: MessageBox(NULL, "Launching audio control panel not implemented yet!", "Fixme", MB_OK | MB_ICONERROR); break; case IDC_DSOUND_HW_ACCEL: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_accel; int i, j = 0; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_accel = SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_GETCURSEL, 0, 0); for (i = 0; DSound_HW_Accels[i].settingStr; ++i) { if (DSound_HW_Accels[i].visible) { if (j == selected_dsound_accel) { set_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration", DSound_HW_Accels[i].settingStr); break; } j++; } } } break; case IDC_DSOUND_RATES: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_rate; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_rate = SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_GETCURSEL, 0, 0); set_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", DSound_Rates[selected_dsound_rate]); } break; case IDC_DSOUND_BITS: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_bits; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_bits = SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_GETCURSEL, 0, 0); set_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", DSound_Bits[selected_dsound_bits]); } break; } break; case WM_SHOWWINDOW: set_window_title(hDlg); break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->code) { case PSN_KILLACTIVE: SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE); break; case PSN_APPLY: set_reg_key(config_key, "Drivers", "Audio", curAudioDriver); apply(); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR); break; case PSN_SETACTIVE: break; case NM_CLICK: if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE) { TVHITTESTINFO ht; DWORD dwPos = GetMessagePos(); HWND tree = ((LPNMHDR)lParam)->hwndFrom; ZeroMemory(&ht, sizeof(ht)); ht.pt.x = (short)LOWORD(dwPos); ht.pt.y = (short)HIWORD(dwPos); MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1); SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht ); if (TVHT_ONITEMSTATEICON & ht.flags) { TVITEM tvItem; int index; ZeroMemory(&tvItem, sizeof(tvItem)); tvItem.hItem = ht.hItem; SendMessageW( tree, TVM_GETITEMW, 0, (LPARAM) &tvItem ); index = TreeView_GetItemState(tree, ht.hItem, TVIS_STATEIMAGEMASK); if (index == INDEXTOSTATEIMAGEMASK(1)) { TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK); addDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver); SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */ } else if (index == INDEXTOSTATEIMAGEMASK(2)) { TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); removeDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver); SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */ } } } break; case NM_RCLICK: if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE) { TVHITTESTINFO ht; DWORD dwPos = GetMessagePos(); HWND tree = ((LPNMHDR)lParam)->hwndFrom; POINT pt; ZeroMemory(&ht, sizeof(ht)); pt.x = (short)LOWORD(dwPos); pt.y = (short)HIWORD(dwPos); ht.pt = pt; MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1); SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht ); if (TVHT_ONITEMLABEL & ht.flags) { TVITEM tvItem; ZeroMemory(&tvItem, sizeof(tvItem)); tvItem.hItem = ht.hItem; tvItem.mask = TVIF_PARAM; tvItem.lParam = -1; if (TreeView_GetItem(tree, &tvItem)) { if (tvItem.lParam & DRIVER_MASK) { if (hPopupMenus) { TrackPopupMenu(GetSubMenu(hPopupMenus, 0), TPM_RIGHTBUTTON, pt.x, pt.y, 0, tree, NULL); toConfigure = tvItem.lParam & ~DRIVER_MASK; } } else if (tvItem.lParam & DEVICE_MASK) { /* FIXME TBD */ } } } } } break; case WM_INITDIALOG: initAudioDlg(hDlg); break; } return FALSE; }
INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HTREEITEM hListHeading1 = 0; static HTREEITEM hListHeading2 = 0; switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { 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); FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, branch1, _countof(branch1), 0x0000); FillBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading2, branch2, _countof(branch2), 0x0000); TCHAR* pszGroup = NULL; InitSetting(pszGroup, "AddToGroup", _T("Chat rooms")); SetDlgItemText(hwndDlg, IDC_GROUP, pszGroup); mir_free(pszGroup); Utils::showDlgControl(hwndDlg, IDC_STATIC_MESSAGE, SW_HIDE); } break; case WM_COMMAND: if ((LOWORD(wParam) == IDC_GROUP) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; if (lParam != 0) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case IDC_CHECKBOXES: return TreeViewHandleClick(hwndDlg, ((LPNMHDR)lParam)->hwndFrom, wParam, lParam); break; case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: int iLen; TCHAR *pszText = NULL; BYTE b; iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP)); if (iLen > 0) { pszText = (TCHAR*)mir_realloc(pszText, (iLen + 2) * sizeof(TCHAR)); GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen + 1); db_set_ts(NULL, CHAT_MODULE, "AddToGroup", pszText); } else db_set_ts(NULL, CHAT_MODULE, "AddToGroup", _T("")); mir_free(pszText); b = M.GetByte(CHAT_MODULE, "Tabs", 1); SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, _countof(branch1)); SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, _countof(branch2)); pci->ReloadSettings(); pci->MM_IconsChanged(); pci->MM_FontsChanged(); pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); SM_ReconfigureFilters(); return TRUE; } } break; case WM_DESTROY: BYTE b = TreeView_GetItemState(GetDlgItem(hwndDlg, IDC_CHECKBOXES), hListHeading1, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0; 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; }
bool TreeNode::GetState(int state) { return !!TreeView_GetItemState(mTreeView->GetHandle(), mHandle, state); }
void MorphByBone::BuildTreeList() { //get our handle suspendUI = TRUE; HWND treeHWND = GetDlgItem(rollupHWND,IDC_TREE1); int tempBone, tempMorph; tempBone = currentBone; tempMorph = currentMorph; COLORREF clrBk = ColorMan()->GetColor(kWindow); TreeView_SetBkColor( treeHWND, clrBk); // TVITEM tvi; BitArray expanded; expanded.SetSize(boneData.Count()); expanded.ClearAll(); for (int i = 0; i < boneData.Count(); i++) { //if !null INode *node = GetNode(i); if (node != NULL) { //add to parent TSTR name = node->GetName(); //add the node as a root entry BOOL expand = TreeView_GetItemState(treeHWND,boneData[i]->treeHWND,TVIS_EXPANDED); if (expand) { expanded.Set(i); } } } TreeView_DeleteAllItems(treeHWND); currentBone = tempBone; currentMorph = tempMorph; //DebugPrint(_T("Morph name creatiuon\n")); //loop through our nodes for (int i = 0; i < boneData.Count(); i++) { //if !null INode *node = GetNode(i); if (node != NULL) { //add to parent TSTR name = node->GetName(); //add the node as a root entry boneData[i]->tvi.state = 0; HTREEITEM parent = AddItemToTree(treeHWND, boneData[i]->tvi, name,i,TVI_ROOT); boneData[i]->treeHWND = parent; if (expanded[i]) { boneData[i]->tvi.state = TVIS_EXPANDED; TreeView_SetItemState(treeHWND,boneData[i]->treeHWND,TVIS_EXPANDED,TVIS_EXPANDED); } if ((currentMorph == -1) && (i==currentBone)) { if (i==currentBone) { TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,TVIS_SELECTED,TVIS_SELECTED); TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,TVIS_BOLD,TVIS_BOLD); } else { TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,0,TVIS_SELECTED); TreeView_SetItemState(treeHWND,boneData[currentBone]->treeHWND,0,TVIS_BOLD); } } //loop through targets and add those as children for (int j = 0 ; j < boneData[i]->morphTargets.Count(); j++) { if (!boneData[i]->morphTargets[j]->IsDead()) { //add morph target to list TSTR morphName; if (boneData[i]->morphTargets[j]->IsDisabled()) morphName.printf(_T("%s(%s)"),boneData[i]->morphTargets[j]->name,GetString(IDS_DISABLED)); else morphName.printf(_T("%s(%0.1f)"),boneData[i]->morphTargets[j]->name,boneData[i]->morphTargets[j]->weight*100.f); // boneData[i]->morphTargets[j]->tvi.state = TVIS_BOLD ; // boneData[i]->morphTargets[j]->tvi.stateMask |= TVIS_BOLD ; //DebugPrint(_T("Morph name %s\n"),morphName); boneData[i]->morphTargets[j]->tvi.state = 0; boneData[i]->morphTargets[j]->treeHWND = AddItemToTree(treeHWND ,boneData[i]->morphTargets[j]->tvi, morphName, (i+1)*1000+j,parent); if ((i== currentBone) && (j == currentMorph)) { TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,TVIS_SELECTED ,TVIS_SELECTED ); TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,TVIS_BOLD ,TVIS_BOLD ); } else { TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,0 ,TVIS_SELECTED ); TreeView_SetItemState(treeHWND,boneData[i]->morphTargets[j]->treeHWND,0 ,TVIS_BOLD ); } } } } } suspendUI = FALSE; }