Example #1
0
void TreeView::init(HINSTANCE hInst, HWND parent, int treeViewID)
{
	Window::init(hInst, parent);
	_hSelf = ::GetDlgItem(parent, treeViewID);

	_hSelf = CreateWindowEx(0,
                            WC_TREEVIEW,
                            TEXT("Tree View"),
                            WS_CHILD | WS_BORDER | WS_HSCROLL | WS_TABSTOP | TVS_LINESATROOT | TVS_HASLINES |
							TVS_HASBUTTONS | TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_EDITLABELS | TVS_INFOTIP, 
                            0,  0,  0, 0,
                            _hParent, 
                            NULL, 
                            _hInst, 
                            (LPVOID)0);

	TreeView_SetItemHeight(_hSelf, CY_ITEMHEIGHT);

	::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
	_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc));
}
Example #2
0
/**
 * name:	CPsTree
 * class:	CPsTree
 * desc:	constructor
 * param:	none
 * return:	none
 **/
BYTE CPsTree::Create(HWND hWndTree, CPsHdr* pPsh)
{
	BYTE rc;

	if (hWndTree && pPsh->_hImages && pPsh->_pPages && pPsh->_numPages)
	{
		_hWndTree = hWndTree;
		_hImages = pPsh->_hImages;
		_pItems = pPsh->_pPages;
		_numItems = pPsh->_numPages;
		_dwFlags = pPsh->_dwFlags;
		
		TreeView_SetImageList(_hWndTree, _hImages, TVSIL_NORMAL);
		TreeView_SetItemHeight(_hWndTree, TreeView_GetItemHeight(_hWndTree) + 4);
		SetUserData(_hWndTree, this);
		rc = TRUE;
	}
	else
	{
		rc = FALSE;
	}
	return rc;
}
Example #3
0
int TreeView::SetItemHeight(SHORT cyItem) {
  return TreeView_SetItemHeight(window_, cyItem);
}
Example #4
0
int TreeView::SetItemHeight(SHORT cyItem) {
  return TreeView_SetItemHeight(m_hWindow, cyItem);
}
Example #5
0
	BOOL CALLBACK FCLDialogProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
	{
		switch(msg)
		{
		case WM_INITDIALOG:
			{
				if (m_import)
					SetWindowText(wnd, _T("Select settings to import"));
				HWND wnd_tree = GetDlgItem(wnd, IDC_TREE);
				HWND wnd_combo = m_import ? NULL : GetDlgItem(wnd, IDC_DEST);
				SetWindowLongPtr(wnd_tree, GWL_STYLE, GetWindowLongPtr(wnd_tree, GWL_STYLE)|TVS_CHECKBOXES);

				uih::SetTreeViewWindowExplorerTheme(wnd_tree);

				if (wnd_combo)
				{
					ComboBox_AddString(wnd_combo, L"Any foobar2000 installation");
					ComboBox_AddString(wnd_combo, L"This foobar2000 installation");
					ComboBox_SetCurSel(wnd_combo, 0);
				}

				SendMessage(wnd_tree, WM_SETREDRAW, FALSE, 0);
				TreeView_SetItemHeight(wnd_tree, TreeView_GetItemHeight(wnd_tree)+2);

				cui::fcl::group_list m_groups;
				if (m_import)
				{
					cui::fcl::dataset_list datasets;
					pfc::list_t<GUID> groupslist;
					t_size j, count = datasets.get_count();
					for (j=0; j<count; j++)
					{
						if (m_filter.have_item(datasets[j]->get_guid()))
						{
							GUID guid = datasets[j]->get_group();
							if (!groupslist.have_item(guid))
								groupslist.add_item(guid);

							cui::fcl::group_ptr ptr;
							while (m_groups.find_by_guid(guid, ptr))
							{
								guid = ptr->get_parent_guid();
								if (guid != pfc::guid_null)
									if (!groupslist.have_item(guid))
										groupslist.add_item(guid);
								else break;

							}
						}
					}
					t_size i = m_groups.get_count();
					for (; i; i--)
						if (!groupslist.have_item(m_groups[i-1]->get_guid()))
							m_groups.remove_by_idx(i-1);
				}
				m_groups.sort_by_name();
				cui::fcl::group_list_filtered filtered(m_groups, pfc::guid_null);
				g_populate_tree(wnd_tree, m_groups, filtered);

				SendMessage(wnd_tree, WM_SETREDRAW, TRUE, 0);
				RedrawWindow(wnd_tree,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW);
			}
			return TRUE;
		case WM_COMMAND:
			switch (wp)
			{
			case IDOK:
				{
					HWND wnd_tree = GetDlgItem(wnd, IDC_TREE);
					t_size i, count = m_nodes.get_count();
					for (i=0; i<count; i++)
					{
						m_nodes[i].checked = 0 != TreeView_GetCheckState(wnd_tree, m_nodes[i].item);
					}
					HWND wnd_combo = m_import ? NULL : GetDlgItem(wnd, IDC_DEST);
					if (wnd_combo)
					{
						m_mode = ComboBox_GetCurSel(wnd_combo);
					}
				}
				EndDialog(wnd, 1);
				return FALSE;
			case IDCANCEL:
				EndDialog(wnd, 0);
				return FALSE;
			}
			break;
		case WM_CLOSE:
			EndDialog(wnd, 0);
			return 0;
		case WM_DESTROY:
			{
				HWND wnd_tree = GetDlgItem(wnd, IDC_TREE);
				HIMAGELIST il = TreeView_GetImageList(wnd_tree, TVSIL_STATE);
				TreeView_SetImageList(wnd_tree, NULL, TVSIL_STATE);
				ImageList_Destroy(il);
				DestroyWindow(wnd_tree);
			}
			break;
		case WM_NCDESTROY:
			break;
		}

		return FALSE;
	}