コード例 #1
0
void CTreeView::CheckTreeItem(HTREEITEM hItem, bool check)
{
	if (check)
		CheckTreeItem(hItem);
	else
		UncheckTreeItem(hItem);

	CheckSubTreeItems(hItem, check);
}
コード例 #2
0
LRESULT CTreeView::OnClick(NMHDR* pnmh)
{
	// Q261289
	DWORD dwpos = GetMessagePos();
	CPoint pt(GET_X_LPARAM(dwpos), GET_Y_LPARAM(dwpos));
	ScreenToClient(&pt);

	UINT flags = 0;
	HTREEITEM hItem = HitTest(pt, &flags);
	if (flags & TVHT_ONITEMSTATEICON)
	{
		m_pMainFrame->EnQueue([this, hItem]() { CheckTreeItem(hItem, GetCheckState(hItem) != FALSE); });
	}

	return 0;
}
コード例 #3
0
void CTreeView::CheckTreeItem(HTREEITEM hItem)
{
	SetCheckState(hItem, true);
	if (HTREEITEM hParent = GetParentItem(hItem))
		CheckTreeItem(hParent);
}
コード例 #4
0
void CTreeView::CheckFailed()
{
	for (auto it = m_items.begin(); it != m_items.end(); ++it)
		CheckTreeItem(it->second, GetTestItemImage(it->second) == m_iCross);
}
コード例 #5
0
ファイル: Ui.c プロジェクト: kichik/nsis-1
static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  static HTREEITEM *hTreeItems;
  static HIMAGELIST hImageList;
  HWND hwndCombo1 = GetUIItem(IDC_COMBO1);
  HWND hwndTree1 = GetUIItem(IDC_TREE1);
  extern HWND g_SectionHack;
  section *sections=g_sections;
  if (uMsg == WM_INITDIALOG)
  {
    int doLines=0;
    HTREEITEM Par;
    HBITMAP hBMcheck1;
    int x, lastGoodX, i, noCombo=2;

    g_SectionHack=hwndDlg;

    if (hTreeItems) GlobalFree(hTreeItems);
    hTreeItems=(HTREEITEM*)my_GlobalAlloc(sizeof(HTREEITEM)*num_sections);

    hBMcheck1=LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1));

    oldTreeWndProc=SetWindowLong(hwndTree1,GWL_WNDPROC,(DWORD)newTreeWndProc);

    if (hImageList) ImageList_Destroy(hImageList);

    hImageList = ImageList_Create(16,16, ILC_COLOR32|ILC_MASK, 6, 0);
    ImageList_AddMasked(hImageList,hBMcheck1,RGB(255,0,255));

    TreeView_SetImageList(hwndTree1, hImageList, TVSIL_STATE);

#ifndef TVM_SETITEMHEIGHT
#define TVM_SETITEMHEIGHT (TV_FIRST + 27)
#endif
#ifndef TVM_GETITEMHEIGHT
#define TVM_GETITEMHEIGHT (TV_FIRST + 28)
#endif

    if (SendMessage(hwndTree1, TVM_GETITEMHEIGHT, 0, 0) < 16)
      SendMessage(hwndTree1, TVM_SETITEMHEIGHT, 16, 0);

    DeleteObject(hBMcheck1);

    for (i = 0; i < NSIS_MAX_INST_TYPES+1; i++)
    {
      if (g_header->install_types[i])
      {
        int j;
        if (i != NSIS_MAX_INST_TYPES) noCombo = 0;
        GetNSISString(g_tmp,g_header->install_types[i]);
        j=SendMessage(hwndCombo1,CB_ADDSTRING,0,(LPARAM)g_tmp);
        SendMessage(hwndCombo1,CB_SETITEMDATA,j,i);
        if (i == g_exec_flags.cur_insttype)
          SendMessage(hwndCombo1, CB_SETCURSEL, j, 0);
      }
    }

    if (!noCombo)
      ShowWindow(hwndCombo1,SW_SHOW);

    SetUITextFromLang(IDC_TEXT1,this_page->parms[1+noCombo]);
    SetUITextFromLang(IDC_TEXT2,this_page->parms[2+noCombo]);

    Par=NULL;

    for (lastGoodX = x = 0; x < num_sections; x ++)
    {
      section *sec=sections+x;

      if (sec->name_ptr)
      {
        TVINSERTSTRUCT tv;
        tv.hParent=Par;
        tv.hInsertAfter=TVI_LAST;
        tv.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE;
        tv.item.lParam=x;
        tv.item.pszText=GetNSISStringTT(sec->name_ptr);
        tv.item.stateMask=TVIS_STATEIMAGEMASK|TVIS_EXPANDED|TVIS_BOLD;

        {
          int l=1;
          // Sf_SELECTED == 1
          l += sec->flags & SF_SELECTED;
          //if (sec->flags & SF_SELECTED) l++;
          if (sec->flags & SF_RO) l+=3;

          tv.item.state=INDEXTOSTATEIMAGEMASK(l);
        }

        //if (sec->flags&SF_BOLD)
        {
          // SF_BOLD << 1 == 16 == TVIS_BOLD
          tv.item.state|=(sec->flags&SF_BOLD)<<1;
        }

        if (sec->flags&SF_SUBSEC)
        {
          tv.item.mask|=TVIF_CHILDREN;
          tv.item.cChildren=1;
          //if (sec->flags&SF_EXPAND)
            // TVIS_EXPANDED == SF_EXPAND
            tv.item.state|=sec->flags&SF_EXPAND;
          Par = hTreeItems[x] = TreeView_InsertItem(hwndTree1,&tv);
          doLines=1;
        }
        else if (sec->flags&SF_SUBSECEND)
        {
          SetParentState(hwndTree1,hTreeItems[lastGoodX]);
          Par=TreeView_GetParent(hwndTree1,Par);
        }
        else
        {
          lastGoodX = x;
          hTreeItems[x] = TreeView_InsertItem(hwndTree1,&tv);
        }
      }
    }
    if (!doLines)
    {
      SetWindowLong(hwndTree1,GWL_STYLE,GetWindowLong(hwndTree1,GWL_STYLE)&~(TVS_LINESATROOT));
    }
    SendMessage(hwndTree1,WM_VSCROLL,SB_TOP,0);

    uMsg = g_exec_flags.insttype_changed ? WM_NOTIFY_INSTTYPE_CHANGE : WM_IN_UPDATEMSG;
  }
  if (uMsg == WM_NOTIFY_SECTEXT) // update text
  {
    int x=wParam;
    int ns=lParam;
    TVITEM tv;

    if (tv.hItem=hTreeItems[x])
    {
      tv.mask=TVIF_TEXT;
      tv.pszText=GetNSISStringTT(ns);
      TreeView_SetItem(hwndTree1,&tv);
    }
  }
  if (uMsg == WM_NOTIFY_SECFLAGS) // change flags
  {
    int flags = sections[wParam].flags;
    TVITEM tvItem;

    if (!(tvItem.hItem = hTreeItems[wParam])) return 0;
    tvItem.mask = TVIF_STATE;
    tvItem.stateMask = TVIS_BOLD;
    tvItem.state = 0;
    //if (flags&SF_BOLD) tvItem.state |= TVIS_BOLD;
    // SF_BOLD << 1 == 16 == TVIS_BOLD
    tvItem.state|=(flags&SF_BOLD)<<1;
    TreeView_SetItem(hwndTree1, &tvItem);

    TreeView_Expand(hwndTree1, tvItem.hItem, flags & SF_EXPAND ? TVE_EXPAND : TVE_COLLAPSE);

    if ((flags & (SF_PSELECTED | SF_SELECTED)) != SF_PSELECTED)
    {
      CheckTreeItem(hwndTree1, tvItem.hItem, flags & SF_SELECTED);
    }
  }
  if (uMsg == WM_NOTIFY || uMsg == WM_TREEVIEW_KEYHACK)
  {
    LPNMHDR lpnmh = (LPNMHDR) lParam;
    if (uMsg == WM_TREEVIEW_KEYHACK || lpnmh->idFrom == IDC_TREE1)
    {
      if (!(g_flags&CH_FLAGS_NO_CUSTOM) && (uMsg == WM_TREEVIEW_KEYHACK || lpnmh->code == NM_CLICK))
      {
        TVITEM tvItem;

        if (uMsg != WM_TREEVIEW_KEYHACK)
          tvItem.hItem=TreeHitTest(hwndTree1);
        else
          tvItem.hItem=TreeView_GetSelection(hwndTree1);

        if (tvItem.hItem)
        {
          int iState;

          tvItem.mask = TVIF_STATE|TVIF_PARAM;
          TreeView_GetItem(hwndTree1, &tvItem);

          iState = tvItem.state >> 12;

          if (iState < 4) // not RO
          {
            if (iState == 2) // already checked
            {
              sections[tvItem.lParam].flags&=~SF_SELECTED;
              CheckTreeItem(hwndTree1,tvItem.hItem,0);
            }
            else
            {
              sections[tvItem.lParam].flags|=SF_SELECTED;
              CheckTreeItem(hwndTree1,tvItem.hItem,1);
            }
            lParam = 0;
            wParam = 1;
            uMsg = WM_IN_UPDATEMSG;
          } // not ro
        } // was valid click
      } // was click or hack
コード例 #6
0
void CDongleMakerDlg::OnAppTreeDblClk(NMHDR* pNMHDR, LRESULT* pResult)
{
    NM_TREEVIEW* pnmtv = (NM_TREEVIEW*)pNMHDR;

    HTREEITEM hSelected = m_AppTree.GetSelectedItem();

    // Returning a result of true will prevent normal processing,
    // therefore the tree will not expand and contract when doubleclicked
    if (pResult)
//j		*pResult = true;
        *pResult = false;

    DWORD dwParam;
    DWORD dwState;
    AppLock* applock = GetSelectedApp(hSelected, &dwState, &dwParam);
    if (!applock)
        return;

    if (dwParam & TREE_LEVEL_APP)
    {   // Double click on an app to select/deselect it
        applock->active = !applock->active;
        DWORD algorithm = m_pDongle->GetAlgorithm(applock);
        UpdateData(FALSE);

        CheckTreeItem(hSelected, applock->active);

//j		// Collapse this app
//j		if (!applock->active)
//j			m_AppTree.Expand(hSelected, TVE_COLLAPSE);
//j
//j		// Collapse the entire tree
//j		HTREEITEM hItem = m_AppTree.GetRootItem();
//j		while (hItem)
//j		{
//j			m_AppTree.Expand(hItem, TVE_COLLAPSE);
//j			hItem = m_AppTree.GetNextItem()
//j		}
    }
    else if (dwParam & TREE_LEVEL_VERSIONS_HEADER)
    {   // Double click on the version header to clear all version bits
        HTREEITEM hChild = m_AppTree.GetChildItem(hSelected);
        while (hChild)
        {
            CheckTreeItem(hChild, false);
            hChild = m_AppTree.GetNextSiblingItem(hChild);
        }
        applock->versions = 0;
        m_versions.Format("0x%04lx", applock->versions);
        m_versions.MakeLower();
        UpdateData(FALSE);
    }
    else if (dwParam & TREE_LEVEL_FEATURES_HEADER)
    {   // Double click on the feature header to clear all feature bits
        HTREEITEM hChild = m_AppTree.GetChildItem(hSelected);
        while (hChild)
        {
            CheckTreeItem(hChild, false);
            hChild = m_AppTree.GetNextSiblingItem(hChild);
        }
        applock->features = 0;
        m_features.Format("0x%04lx", applock->features);
        m_features.MakeLower();
        UpdateData(FALSE);
    }
    else if (dwParam & TREE_LEVEL_VERSIONS)
    {   // Double click on a version to select/deselect it
        int iBit = (dwParam & 0x00FF0000) >> 16;
        bool bOn = !(applock->versions & (1 << iBit));
        if (!bOn)
            applock->versions &= ~(1 << iBit);
        else
            applock->versions |=  (1 << iBit);

        m_versions.Format("0x%04lx", applock->versions);
        m_versions.MakeLower();
        UpdateData(FALSE);

        CheckTreeItem(hSelected, bOn);
    }