Пример #1
0
//------------------------------------------------------------------------------
void GetRegFile(char *reg_file, HTREEITEM hparent, char *parent, BOOL recovery_mode, HANDLE hlv, HANDLE htv)
{
  if (reg_file[0] == 0) return;

  //load a binary file to TreeView and ListView
  if (recovery_mode)
  {
    GetRecoveryRegFile(reg_file, hparent, parent, hlv, htv);
    TreeView_SortChildren(htv,hparent,TRUE);
  }else
  {
    //simple mode
    HK_F_OPEN hks_tmp;
    if(OpenRegFiletoMem(&hks_tmp, reg_file))
    {
      ReadArboRawRegFile(&hks_tmp, (HBIN_CELL_NK_HEADER *)(hks_tmp.buffer+hks_tmp.position), reg_file, hparent, parent,"\\", hlv, htv);
      CloseRegFiletoMem(&hks_tmp);
    }
    TreeView_SortChildren(htv,hparent,TRUE);
  }
}
Пример #2
0
static VOID
EnumChildDevices(HWND hTreeView,
                 HTREEITEM hRoot,
                 DEVINST dnParentDevInst,
                 BOOL bShowHidden)
{
    HTREEITEM hDevItem;
    DEVINST dnDevInst;
    CONFIGRET cr;

    cr = CM_Get_Child(&dnDevInst,
                      dnParentDevInst,
                      0);
    if (cr != CR_SUCCESS)
        return;

    hDevItem = AddDeviceToTree(hTreeView,
                               hRoot,
                               dnDevInst,
                               bShowHidden);
    if (hDevItem != NULL)
    {
        EnumChildDevices(hTreeView,
                         hDevItem,
                         dnDevInst,
                         bShowHidden);
    }

    while (cr == CR_SUCCESS)
    {
        cr = CM_Get_Sibling(&dnDevInst,
                            dnDevInst,
                            0);
        if (cr != CR_SUCCESS)
            break;

        hDevItem = AddDeviceToTree(hTreeView,
                                   hRoot,
                                   dnDevInst,
                                   bShowHidden);
        if (hDevItem != NULL)
        {
            EnumChildDevices(hTreeView,
                             hDevItem,
                             dnDevInst,
                             bShowHidden);
        }
    }

    (void)TreeView_SortChildren(hTreeView,
                                hRoot,
                                0);
}
Пример #3
0
//响应浏览器控件操作(在WM_NOTIFY消息中调用)
UINT Response_Browser(LONG lParam)
{
   NM_TREEVIEW *pnmtv = (NM_TREEVIEW *)lParam;
   LPTVITEMDATA lptvid ;
   HRESULT hr ;
   LPSHELLFOLDER lpsf2 = 0 ;

   switch( pnmtv -> hdr.code)
	{
		case TVN_SELCHANGED:
			lptvid = (LPTVITEMDATA)pnmtv -> itemNew.lParam;
         GetName(lptvid -> lpsfParent, lptvid->lpi, SHGDN_FORPARSING, szFoldername);

         if(szFoldername[1]!=':' || szFoldername[2]!='\\')
			{
		   	GetWindowsDirectory(szFoldername,MAX_PATH);
  				strcat(szFoldername,"\\desktop\0");
            TreeView_SelectItem(hTreeWnd,TreeView_GetRoot(hTreeWnd));
		   }
			return TVN_SELCHANGED;

		case TVN_ITEMEXPANDING:
		   if(( pnmtv -> itemNew.state & TVIS_EXPANDEDONCE))
				break ;

		   lptvid = (LPTVITEMDATA)pnmtv -> itemNew.lParam ;
		   hr=lptvid -> lpsfParent->BindToObject(lptvid -> lpi,
																   0,
																   IID_IShellFolder,
																   (LPVOID *)&lpsf2) ;

		   if( SUCCEEDED(hr))
		   {
			  FillTreeView(hTreeWnd,
								   lpsf2,
								   lptvid -> lpifq,
								   pnmtv -> itemNew.hItem) ;
		   }

		   TreeView_SortChildren(hTreeWnd, pnmtv -> itemNew.hItem, FALSE) ;
			return FALSE;//TVN_ITEMEXPANDING;

		default:
		   break;
   }
   return FALSE;
}
Пример #4
0
VOID
ListDevicesByType(HWND hTreeView,
                  HTREEITEM hRoot,
                  BOOL bShowHidden)
{
    PDEVCLASS_ENTRY pClassArray;
    ULONG ulClassCount;

    ulClassCount = GetClassCount();

    pClassArray = HeapAlloc(GetProcessHeap(),
                            HEAP_ZERO_MEMORY,
                            ulClassCount * sizeof(DEVCLASS_ENTRY));
    if (pClassArray == NULL)
        return;

    EnumDeviceClasses(hTreeView,
                      hRoot,
                      pClassArray,
                      ulClassCount);

    EnumDevices(hTreeView,
                pClassArray,
                ulClassCount,
                bShowHidden);

    CleanupDeviceClasses(hTreeView,
                         pClassArray,
                         ulClassCount);

    if (pClassArray != NULL)
        HeapFree(GetProcessHeap(), 0, pClassArray);

    (void)TreeView_Expand(hTreeView,
                          hRoot,
                          TVE_EXPAND);

    (void)TreeView_SortChildren(hTreeView,
                                hRoot,
                                0);

    (void)TreeView_SelectItem(hTreeView,
                              hRoot);
}
Пример #5
0
void wxTreeCtrl::SortChildren(const wxTreeItemId& item)
{
    wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );

    // rely on the fact that TreeView_SortChildren does the same thing as our
    // default behaviour, i.e. sorts items alphabetically and so call it
    // directly if we're not in derived class (much more efficient!)
    if ( GetClassInfo() == CLASSINFO(wxTreeCtrl) )
    {
        TreeView_SortChildren(GetHwnd(), HITEM(item), 0);
    }
    else
    {
        TV_SORTCB tvSort;
        tvSort.hParent = HITEM(item);
        tvSort.lpfnCompare = wxTreeSortHelper::Compare;
        tvSort.lParam = (LPARAM)this;
        TreeView_SortChildrenCB(GetHwnd(), &tvSort, 0 /* reserved */);
    }
}
Пример #6
0
static
VOID
CleanupDeviceClasses(
    HWND hTreeView,
    PDEVCLASS_ENTRY pClassArray,
    ULONG ulClassCount)
{
    PDEVCLASS_ENTRY pClass;
    ULONG i;

    for (i = 0; i < ulClassCount; i++)
    {
        pClass = &pClassArray[i];

        if (pClass->bUsed == FALSE)
            (void)TreeView_DeleteItem(hTreeView,
                                      pClass->hItem);
        else
            (void)TreeView_SortChildren(hTreeView,
                                        pClass->hItem,
                                        0);
    }
}
Пример #7
0
bool
CDeviceView::RecurseChildDevices(
    _In_ DEVINST ParentDevice,
    _In_ HTREEITEM hParentTreeItem
    )
{
    HTREEITEM hDevItem = NULL;
    DEVINST Device;
    bool HasProblem = false;
    bool bSuccess;

    // Check if the parent has any child devices 
    if (GetChildDevice(ParentDevice, &Device) == FALSE)
        return true;

    // Get the cached device node
    CDeviceNode *DeviceNode;
    DeviceNode = dynamic_cast<CDeviceNode *>(GetDeviceNode(Device));
    if (DeviceNode == nullptr)
    {
        ATLASSERT(FALSE);
        return false;
    }

    // Don't show hidden devices if not requested
    if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden())))
    {
        // Add this device to the tree under its parent 
        hDevItem = InsertIntoTreeView(hParentTreeItem,
                                      DeviceNode);
        if (hDevItem)
        {
            // Check if this child has any children itself 
            if (!RecurseChildDevices(Device, hDevItem))
                HasProblem = true;
        }

        if (DeviceNode->HasProblem())
        {
            HasProblem = true;
        }
    }


    // Check for siblings
    for (;;)
    {
        // Check if the parent device has anything at the same level 
        bSuccess = GetSiblingDevice(Device, &Device);
        if (bSuccess == FALSE) break;

        DeviceNode = dynamic_cast<CDeviceNode *>(GetDeviceNode(Device));
        if (DeviceNode == nullptr)
        {
            ATLASSERT(FALSE);
        }

        // Don't show hidden devices if not requested
        if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden())))
        {
            if (DeviceNode->HasProblem())
            {
                HasProblem = true;
            }

            // Add this device to the tree under its parent 
            hDevItem = InsertIntoTreeView(hParentTreeItem,
                                          DeviceNode);
            if (hDevItem)
            {
                // Check if this child has any children itself 
                if (!RecurseChildDevices(Device, hDevItem))
                    HasProblem = true;
            }
        }
    }

    (void)TreeView_SortChildren(m_hTreeView,
                                hParentTreeItem,
                                0);

    // Expand the class if it has a problem device
    if (HasProblem == true)
    {
        (void)TreeView_Expand(m_hTreeView,
                              hParentTreeItem,
                              TVE_EXPAND);
    }

    // If there was a problem, expand the ancestors
    if (HasProblem) return false;

    return true;
}
Пример #8
0
bool
CDeviceView::ListDevicesByType()
{
    CClassNode *ClassNode;
    CDeviceNode *DeviceNode;
    HDEVINFO hDevInfo;
    HTREEITEM hTreeItem = NULL;
    GUID ClassGuid;
    INT ClassIndex;
    BOOL bClassSuccess, bSuccess;

    ClassIndex = 0;
    do
    {
        // Loop through all the device classes
        bClassSuccess = GetNextClass(ClassIndex, &ClassGuid, &hDevInfo);
        if (bClassSuccess)
        {
            bool bClassUnknown = false;
            bool AddedParent = false;
            INT DeviceIndex = 0;
            bool MoreItems = false;

            // Get the cached class node
            ClassNode = GetClassNode(&ClassGuid);
            if (ClassNode == nullptr)
            {
                ATLASSERT(FALSE);
                ClassIndex++;
                continue;
            }

            // Set a flag is this is the (special case) unknown class
            if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_UNKNOWN))
                bClassUnknown = true;

            // Check if this is a hidden class
            if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_LEGACYDRIVER) ||
                IsEqualGUID(ClassGuid, GUID_DEVCLASS_VOLUME))
            {
                // Ignore this device if we aren't displaying hidden devices
                if (m_ShowHidden == FALSE)
                {
                    ClassIndex++;
                    continue;
                }
            }

            do
            {
                // Get a handle to all the devices in this class
                SP_DEVINFO_DATA DeviceInfoData;
                ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA));
                DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
                bSuccess = SetupDiEnumDeviceInfo(hDevInfo,
                                                 DeviceIndex,
                                                 &DeviceInfoData);
                if (bSuccess == FALSE && GetLastError() == ERROR_NO_MORE_ITEMS)
                    MoreItems = false;

                if (bSuccess)
                {
                    MoreItems = true;

                    // The unknown class handle contains all devices on the system,
                    // and we're just looking for the ones with a null GUID
                    if (bClassUnknown)
                    {
                        if (IsEqualGUID(DeviceInfoData.ClassGuid, GUID_NULL) == FALSE)
                        {
                            // This is a known device, we aren't interested in it
                            DeviceIndex++;
                            continue;
                        }
                    }

                    // Get the cached device node
                    DeviceNode = GetDeviceNode(DeviceInfoData.DevInst);
                    if (DeviceNode == nullptr)
                    {
                        ATLASSERT(bClassUnknown == true);
                        DeviceIndex++;
                        continue;
                    }

                    // Check if this is a hidden device
                    if (DeviceNode->IsHidden())
                    {
                        // Ignore this device if we aren't displaying hidden devices
                        if (m_ShowHidden == FALSE)
                        {
                            DeviceIndex++;
                            continue;
                        }
                    }

                    // We have a device, we need to add the parent if it hasn't yet been added
                    if (AddedParent == false)
                    {
                        // Insert the new class under the root item
                        hTreeItem = InsertIntoTreeView(m_hTreeRoot,
                                                       ClassNode);
                        AddedParent = true;
                    }

                    // Add the device under the class item node
                    (void)InsertIntoTreeView(hTreeItem, DeviceNode);

                    // Expand the class if it has a problem device
                    if (DeviceNode->HasProblem())
                    {
                        (void)TreeView_Expand(m_hTreeView,
                                              hTreeItem,
                                              TVE_EXPAND);
                    }
                }

                DeviceIndex++;

            } while (MoreItems);

            // If this class has devices, sort them alphabetically
            if (AddedParent == true)
            {
                (void)TreeView_SortChildren(m_hTreeView,
                                            hTreeItem,
                                            0);
            }
        }

        ClassIndex++;

    } while (bClassSuccess);

    // Sort the classes alphabetically
    (void)TreeView_SortChildren(m_hTreeView,
                                m_hTreeRoot,
                                0);

    // Expand the root item
    (void)TreeView_Expand(m_hTreeView,
                          m_hTreeRoot,
                          TVE_EXPAND);

    // Pre-select the root item
    (VOID)TreeView_SelectItem(m_hTreeView,
                              m_hTreeRoot);

    return 0;
}
Пример #9
0
static INT_PTR CALLBACK TemplateDlg(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static HWND hTreeCtrl;
	static HWND hOkBtn;
	static HWND hEditBtn;
	static HWND hInsertBtn;
	static HWND hRemoveMarkerBtn;
	static int LDX, LDY, BDX;
	static LPARAM param;
	if(WM_INITDIALOG == uMsg)
	{
		RECT rcWR, rcCR;
		POINT pt;
		EDITINFO ei;
		param = lParam;
		GetClientRect(hWndDlg,&rcWR);
		hTreeCtrl = GetDlgItem(hWndDlg,IDC_TREE);
		hOkBtn = GetDlgItem(hWndDlg,IDOK);
		hEditBtn = GetDlgItem(hWndDlg,IDC_EDIT);
		hInsertBtn = GetDlgItem(hWndDlg,IDC_INSERT);
		hRemoveMarkerBtn = GetDlgItem(hWndDlg, IDC_REMMARKER);
		GetWindowRect(hTreeCtrl,&rcCR);
		pt.x = rcCR.right; pt.y = rcCR.bottom;
		ScreenToClient(hWndDlg,&pt);
		LDX = rcWR.right - pt.x;
		LDY = rcWR.bottom - pt.y;
		GetWindowRect(hOkBtn,&rcCR);
		pt.x=rcCR.left; pt.y=0;
		ScreenToClient(hWndDlg,&pt);
		BDX = rcWR.right - pt.x;
		{
			TVINSERTSTRUCTW tvi;
			HTREEITEM hEmpty;
			WCHAR	szRoot[MAX_PATH];
			SHFILEINFOW sfi;
			HIMAGELIST hList
				= (HIMAGELIST)SHGetFileInfoW(g_szAkelPath,0,&sfi,sizeof(sfi),SHGFI_SYSICONINDEX|SHGFI_SMALLICON);
			TreeView_SetImageList(hTreeCtrl,hList,TVSIL_NORMAL);
			lstrcpyW(szRoot,g_szAkelPath);
			lstrcatW(szRoot,TEMPLATES_PATH);
			FillTreeCtrl(hTreeCtrl,szRoot,TVI_ROOT);
			TreeView_SortChildren(hTreeCtrl,TVI_ROOT,FALSE);
			tvi.hParent = TVI_ROOT;
			tvi.hInsertAfter = TVI_FIRST;
			tvi.item.pszText = L"<Empty>";
			tvi.item.lParam = TVNT_EMPTY;
			tvi.item.iImage = tvi.item.iSelectedImage = 3;
			tvi.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
			hEmpty = TreeView_InsertItem(hTreeCtrl,&tvi);
			if(TreeView_GetCount(hTreeCtrl)>0)
			{
				TreeView_SelectItem(hTreeCtrl,hEmpty);
				EnableWindow(hOkBtn,TRUE);
			}
			else
			{
				EnableWindow(hOkBtn,FALSE);
			}
		}
		if(!(lParam&DCP_ALLOWEDIT))
		{
			DestroyWindow(hEditBtn);
			hEditBtn = NULL;
		}
		if(SendMessageW(g_hMainWnd,AKD_GETEDITINFO,(WPARAM)NULL,(LPARAM)&ei))
		{
			if(!IsWindow(ei.hWndEdit) || (!(lParam&DCP_ALLOWINSERT)))
			{
				DestroyWindow(hInsertBtn);
				hInsertBtn = NULL;
			}
		}
		SendMessageW(hRemoveMarkerBtn, BM_SETCHECK,g_bRemoveMarker?BST_CHECKED:BST_UNCHECKED,0);
		PostMessageW(hWndDlg,WM_COMMAND,MAKEWPARAM(IDC_TREE,LBN_SELCHANGE),0);
		RestorePosition(hWndDlg);
#ifndef NO_SMALL_ICON
		SendMessageW(hWndDlg, WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)g_hMainIcon);
#endif
		SendMessageW(hWndDlg, WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)g_hMainIcon);
		return TRUE;
	}
	else if(WM_COMMAND == uMsg)
	{
		if(((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDC_EDIT) || (LOWORD(wParam) == IDC_INSERT)) && (HIWORD(wParam) == BN_CLICKED))
		{
			HTREEITEM hItem = TreeView_GetSelection(hTreeCtrl);
			TVITEM item;
			INT_PTR len = 0;
			if(!hItem) return TRUE;
			item.hItem = hItem;
			item.lParam = 0;
			item.mask = TVIF_PARAM;
			if(!TreeView_GetItem(hTreeCtrl,&item)) return TRUE;
			if(item.lParam==TVNT_DIR) return TRUE;
			lstrcpyW(g_szTemplate,g_szAkelPath);
			lstrcatW(g_szTemplate,TEMPLATES_PATH);
			lstrcatW(g_szTemplate,L"\\");
			g_bRemoveMarker = (SendMessageW(hRemoveMarkerBtn, BM_GETCHECK, 0, 0)==BST_CHECKED)?TRUE:FALSE;
			UpdateSettings(TSF_REMOVEMARKER,FALSE);
			len = lstrlenW(g_szTemplate);
			if(RebuildPath(hTreeCtrl, hItem, g_szTemplate+len))
			{
				if(lstrlenW(g_szTemplate) == len)
				{
					//! Opening empty template
					g_szTemplate[0] = 0;
				}
				EndDialog(hWndDlg,LOWORD(wParam));
			}
			else
			{
				g_szTemplate[0]=0;
			}
			return TRUE;
		}
		else if((LOWORD(wParam)==IDCANCEL) && (HIWORD(wParam) == BN_CLICKED))
		{
			EndDialog(hWndDlg,IDCANCEL);
			return TRUE;
		}
	}
	else if(WM_NOTIFY == uMsg)
	{
		if(IDC_TREE == wParam)
		{
			if(((LPNMHDR)lParam)->code == TVN_SELCHANGED)
			{
				LPNMTREEVIEWW ptv = (LPNMTREEVIEWW)lParam;
				if(ptv->itemNew.hItem && (ptv->itemNew.mask&TVIF_PARAM))
				{
					if(hOkBtn)
					{
						EnableWindow(hOkBtn, (ptv->itemNew.lParam != TVNT_DIR));
					}
					if(hEditBtn)
					{
						EnableWindow(hEditBtn, ptv->itemNew.lParam == TVNT_FILE);
					}
					if(hInsertBtn)
					{
						EnableWindow(hInsertBtn, ptv->itemNew.lParam == TVNT_FILE);
					}
				}
				return TRUE;
			}
			else if(((LPNMHDR)lParam)->code == NM_DBLCLK)
			{
				DWORD pos = GetMessagePos();
				TVHITTESTINFO thi;
				HTREEITEM hit=0;
				thi.pt.x = GET_X_LPARAM(pos);
				thi.pt.y = GET_Y_LPARAM(pos);
				ScreenToClient(hTreeCtrl,&thi.pt);
				thi.hItem =0;
				thi.flags =0;
				hit = TreeView_HitTest(hTreeCtrl,&thi);
				if(thi.hItem)
				{
					TVITEM item;
					item.hItem = thi.hItem;
					item.mask = TVIF_PARAM;
					TreeView_GetItem(hTreeCtrl,&item);
					if(hOkBtn)
					{
						EnableWindow(hOkBtn, item.lParam != TVNT_DIR);
					}
					if(hEditBtn)
					{
						EnableWindow(hEditBtn, item.lParam == TVNT_FILE);
					}
					if(hInsertBtn)
					{
						EnableWindow(hInsertBtn, item.lParam != TVNT_DIR);
					}
					if(item.lParam != TVNT_DIR)
						PostMessageW(hWndDlg,WM_COMMAND,MAKEWPARAM(IDOK,BN_CLICKED),0);
				}
				return TRUE;
			}
		}
	}
	else if(WM_CLOSE == uMsg)
	{
		PostMessageW(hWndDlg,WM_COMMAND,MAKEWPARAM(IDCANCEL,BN_CLICKED),0);
		return TRUE;
	}
	else if(WM_DESTROY == uMsg)
	{
		SavePosition(hWndDlg);
	}
	else if(WM_SIZE == uMsg)
	{
		RECT rcWindow, rcNew; POINT pt;
		GetClientRect(hWndDlg,&rcWindow);
		GetWindowRect(hTreeCtrl,&rcNew);
		pt.x = rcNew.left; pt.y = rcNew.top;
		ScreenToClient(hWndDlg,&pt);
		MoveWindow(hTreeCtrl,pt.x,pt.y,rcWindow.right-LDX-pt.x, rcWindow.bottom-LDY-pt.y,TRUE);
		MoveButton(hWndDlg,hOkBtn,rcWindow, BDX);
		MoveButton(hWndDlg,GetDlgItem(hWndDlg,IDCANCEL),rcWindow, BDX);
		MoveButton(hWndDlg,hEditBtn,rcWindow, BDX);
		MoveButton(hWndDlg,hInsertBtn,rcWindow, BDX);
		MoveButton(hWndDlg,hRemoveMarkerBtn,rcWindow,BDX);
		InvalidateRect(hWndDlg,NULL,TRUE);
	}
	else if(WM_PAINT == uMsg)
	{
		RECT rc;
		PAINTSTRUCT ps;
		HDC dc = BeginPaint(hWndDlg, &ps);
		if(dc)
		{
			GetClientRect(hWndDlg, &rc);
			rc.left = rc.right - GetSystemMetrics(SM_CXVSCROLL);
			rc.top  = rc.bottom - GetSystemMetrics(SM_CYVSCROLL);
			DrawFrameControl(dc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
			EndPaint(hWndDlg, &ps);
		}
	}
	return FALSE;
}
Пример #10
0
static void CALLCONV FillTreeCtrl(HWND hTreeCtrl, LPCWSTR szPath, HTREEITEM hRoot)
{
	SIZE_T i, nPathLen = lstrlenW(szPath);
	WIN32_FIND_DATAW fd;
	HANDLE hFind;
	LPWSTR szMask = PLUGIN_ALLOC(MAX_PATH*sizeof(WCHAR));
	if(!szMask) return;
	lstrcpyW(szMask,szPath);
	lstrcatW(szMask,L"\\");
	lstrcatW(szMask,TEMPLATES_MASK);
	hFind = FindFirstFileW(szMask,&fd);
	if(hFind != INVALID_HANDLE_VALUE)
	{
		LPWSTR szItem = PLUGIN_ALLOC(MAX_PATH*sizeof(szItem));
		LPCWSTR p = szPath;
		UINT_PTR tail = 0;
		SHFILEINFOW sfi,sfis;
		while(*p){ szItem[tail] = *p++;tail++;};
		szItem[tail]=L'\\';tail++;
		do
		{
			if(fd.cFileName[0] != L'.')
			{
				i=0;
				while(fd.cFileName[i]) {szItem[tail+i]=fd.cFileName[i];i++;}
				szItem[tail+i]=0;
				SHGetFileInfoW(szItem,0,&sfi,sizeof(sfi),SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_OPENICON);
				SHGetFileInfoW(szItem,0,&sfis,sizeof(sfis),SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_OPENICON);
				if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{
					TVINSERTSTRUCTW tvi;
					HTREEITEM hNode=NULL;
					WCHAR szChild[MAX_PATH],szLabel[MAX_PATH];
					p = fd.cFileName;
					tvi.hParent = hRoot;
					tvi.hInsertAfter = TVI_LAST;
					szLabel[0]=L'[';
					i=0;
					while(*p) {szLabel[1+i]=*p++;i++;}
					szLabel[1+i]=L']';
					szLabel[1+i+1]=0;
					tvi.item.pszText = szLabel;
					tvi.item.cchTextMax = MAX_PATH;
					tvi.item.lParam = TVNT_DIR;
					tvi.item.iImage = sfi.iIcon;
					tvi.item.iSelectedImage = sfis.iIcon;
					tvi.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
					hNode = TreeView_InsertItem(hTreeCtrl,&tvi);
					//! Что-бы не "оптимизировало" в вызов memcpy пришлось установить опцию
					//! компилятора "Inline Function Expansion" в /Ob1
					//! На значение по-умолчанию "Default" в Win32 всё нормально, в x64 - вылазит memcpy
					xmemcpy(szChild,szPath,nPathLen*sizeof(WCHAR));
					i = nPathLen;
					szChild[i]=L'\\'; i++;
					p = fd.cFileName;
					while(*p) {szChild[i]=*p++;i++;}
					szChild[i]=0;
					FillTreeCtrl(hTreeCtrl,szChild,hNode);
					TreeView_SortChildren(hTreeCtrl,hNode,FALSE);
					TreeView_Expand(hTreeCtrl,hNode,TVE_EXPAND);
				}
				else
				{
					TVINSERTSTRUCTW tvi;
					tvi.hParent = hRoot;
					tvi.hInsertAfter = TVI_LAST;
					tvi.item.pszText = fd.cFileName;
					tvi.item.cchTextMax = MAX_PATH;
					tvi.item.lParam = TVNT_FILE;
					tvi.item.iImage = sfi.iIcon;
					tvi.item.iSelectedImage = sfis.iIcon;
					tvi.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
					TreeView_InsertItem(hTreeCtrl,&tvi);
				}
			}
		}
		while(FindNextFileW(hFind, &fd));
		FindClose(hFind);
		PLUGIN_FREE(szItem);
	}
	PLUGIN_FREE(szMask);
}
Пример #11
0
/*****************************************************************************
 * PrefsTreeCtrl class definition.
 *****************************************************************************/
PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
                              PrefsDialog *_p_prefs_dialog, HWND hwnd,
                              HINSTANCE hInst )
{
    vlc_list_t      *p_list;
    module_t        *p_module;
    module_config_t *p_item;
    int i_index;

    INITCOMMONCONTROLSEX iccex;
    RECT rcClient;
    TVITEM tvi = {0}; 
    TVINSERTSTRUCT tvins = {0}; 
    HTREEITEM hPrev;

    size_t i_capability_count = 0;
    size_t i_child_index;

    HTREEITEM capability_item;

    /* Initializations */
    p_intf = _p_intf;
    p_prefs_dialog = _p_prefs_dialog;
    b_advanced = VLC_FALSE;

    /* Create a tree view */
    // Initialize the INITCOMMONCONTROLSEX structure.
    iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
    iccex.dwICC = ICC_TREEVIEW_CLASSES;

    // Registers Statusbar control classes from the common control dll
    InitCommonControlsEx( &iccex );

    // Get the client area rect to put the tv in
    GetClientRect(hwnd, &rcClient);

    // Create the tree-view control.
    hwndTV = CreateWindowEx( 0, WC_TREEVIEW, NULL,
        WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
        TVS_LINESATROOT | TVS_HASBUTTONS,
        5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
        hwnd, NULL, hInst, NULL );

    tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;

    /* List the plugins */
    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
    if( !p_list ) return;

    /*
     * Build a tree of the main options
     */
    ConfigTreeData *config_data = new ConfigTreeData;
    config_data->i_object_id = GENERAL_ID;
    config_data->psz_help = strdup("nothing");//strdup( GENERAL_HELP );
    config_data->psz_section = strdup( GENERAL_TITLE );
    tvi.pszText = _T("General settings");
    tvi.cchTextMax = lstrlen(_T("General settings"));
    tvi.lParam = (long)config_data;
    tvins.item = tvi;
    tvins.hInsertAfter = TVI_FIRST;
    tvins.hParent = TVI_ROOT;

    // Add the item to the tree-view control.
    hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
    general_item = hPrev;

    for( i_index = 0; i_index < p_list->i_count; i_index++ )
    {
        p_module = (module_t *)p_list->p_values[i_index].p_object;
        if( !strcmp( p_module->psz_object_name, "main" ) )
            break;
    }
    if( i_index < p_list->i_count )
    {
        /* We found the main module */

        /* Enumerate config categories and store a reference so we can
         * generate their config panel them when it is asked by the user. */
        p_item = p_module->p_config;

        if( p_item ) do
        {
            switch( p_item->i_type )
            {
            case CONFIG_HINT_CATEGORY:
                ConfigTreeData *config_data = new ConfigTreeData;
                config_data->psz_section = strdup( p_item->psz_text );
                if( p_item->psz_longtext )
                {
                    config_data->psz_help =
                        strdup( p_item->psz_longtext );
                }
                else
                {
                    config_data->psz_help = NULL;
                }
                config_data->i_object_id = p_module->i_object_id;

                /* Add the category to the tree */
                // Set the text of the item. 
                tvi.pszText = _FROMMB(p_item->psz_text); 
                tvi.cchTextMax = _tcslen(tvi.pszText);
                tvi.lParam = (long)config_data;
                tvins.item = tvi;
                tvins.hInsertAfter = hPrev; 
                tvins.hParent = general_item; //level 3
    
                // Add the item to the tree-view control. 
                hPrev = (HTREEITEM)TreeView_InsertItem( hwndTV, &tvins );

                break;
            }
        }
        while( p_item->i_type != CONFIG_HINT_END && p_item++ );

        TreeView_SortChildren( hwndTV, general_item, 0 );
    }
        
    /*
     * Build a tree of all the plugins
     */
    config_data = new ConfigTreeData;
    config_data->i_object_id = PLUGIN_ID;
    config_data->psz_help = strdup("nothing");//strdup( PLUGIN_HELP );
    config_data->psz_section = strdup("nothing");//strdup( PLUGIN_TITLE );
    tvi.pszText = _T("Modules");
    tvi.cchTextMax = lstrlen(_T("Modules"));
    tvi.lParam = (long)config_data;
    tvins.item = tvi;
    tvins.hInsertAfter = TVI_LAST;
    tvins.hParent = TVI_ROOT;

    // Add the item to the tree-view control.
    hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
    plugins_item = hPrev;

    i_capability_count = 0;
    for( i_index = 0; i_index < p_list->i_count; i_index++ )
    {
        i_child_index = 0;

        p_module = (module_t *)p_list->p_values[i_index].p_object;

        /* Exclude the main module */
        if( !strcmp( p_module->psz_object_name, "main" ) )
            continue;

        /* Exclude empty plugins (submodules don't have config options, they
         * are stored in the parent module) */
        if( p_module->b_submodule )
            p_item = ((module_t *)p_module->p_parent)->p_config;
        else
            p_item = p_module->p_config;

        if( !p_item ) continue;
        do
        {
            if( p_item->i_type & CONFIG_ITEM )
                break;
        }
        while( p_item->i_type != CONFIG_HINT_END && p_item++ );
        if( p_item->i_type == CONFIG_HINT_END ) continue;

        /* Find the capability child item */
        /*long cookie; size_t i_child_index;*/
        capability_item = TreeView_GetChild( hwndTV, plugins_item );
        while( capability_item != 0 )
        {
            TVITEM capability_tvi = {0};
            TCHAR psz_text[256];
            i_child_index++;

            capability_tvi.mask = TVIF_TEXT;
            capability_tvi.pszText = psz_text;
            capability_tvi.cchTextMax = 256;
            capability_tvi.hItem = capability_item;
            TreeView_GetItem( hwndTV, &capability_tvi );
            if( !strcmp( _TOMB(capability_tvi.pszText),
                         p_module->psz_capability ) ) break;
 
            capability_item =
                TreeView_GetNextSibling( hwndTV, capability_item );
        }

        if( i_child_index == i_capability_count &&
            p_module->psz_capability && *p_module->psz_capability )
        {
            /* We didn't find it, add it */
            ConfigTreeData *config_data = new ConfigTreeData;
            config_data->psz_section =
                strdup( GetCapabilityHelp( p_module->psz_capability , 1 ) );
            config_data->psz_help =
                strdup( GetCapabilityHelp( p_module->psz_capability , 2 ) );
            config_data->i_object_id = CAPABILITY_ID;
            tvi.pszText = _FROMMB(p_module->psz_capability);
            tvi.cchTextMax = _tcslen(tvi.pszText);
            tvi.lParam = (long)config_data;
            tvins.item = tvi;
            tvins.hInsertAfter = plugins_item; 
            tvins.hParent = plugins_item;// level 3

            // Add the item to the tree-view control. 
            capability_item = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);

            i_capability_count++;
        }

        /* Add the plugin to the tree */
        ConfigTreeData *config_data = new ConfigTreeData;
        config_data->b_submodule = p_module->b_submodule;
        config_data->i_object_id = p_module->b_submodule ?
            ((module_t *)p_module->p_parent)->i_object_id :
            p_module->i_object_id;
        config_data->psz_help = NULL;
        tvi.pszText = _FROMMB(p_module->psz_object_name);
        tvi.cchTextMax = _tcslen(tvi.pszText);
        tvi.lParam = (long)config_data;
        tvins.item = tvi;
        tvins.hInsertAfter = capability_item; 
        tvins.hParent = capability_item;// level 4

        // Add the item to the tree-view control. 
        TreeView_InsertItem( hwndTV, &tvins );
    }

    /* Sort all this mess */
    /*long cookie; size_t i_child_index;*/
    TreeView_SortChildren( hwndTV, plugins_item, 0 );
    capability_item = TreeView_GetChild( hwndTV, plugins_item );
    while( capability_item != 0 )
    {
        TreeView_SortChildren( hwndTV, capability_item, 0 );
        capability_item = TreeView_GetNextSibling( hwndTV, capability_item );
    }

    /* Clean-up everything */
    vlc_list_release( p_list );

    TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
}
Пример #12
0
VOID
CDeviceView::RecurseChildDevices(
    _In_ DEVINST ParentDevice,
    _In_ HTREEITEM hParentTreeItem
    )
{
    HTREEITEM hDevItem = NULL;
    DEVINST Device;
    WCHAR DeviceName[DEVICE_NAME_LEN];
    LPTSTR DeviceId = NULL;
    INT ClassImage;
    BOOL IsUnknown = FALSE;
    BOOL IsHidden = FALSE;
    ULONG DeviceStatus = 0;
    ULONG ProblemNumber = 0;
    UINT OverlayImage = 0;
    BOOL bSuccess;

    /* Check if the parent has any child devices */
    if (m_Devices->GetChildDevice(ParentDevice, &Device) == FALSE)
        return;

    /* Lookup the info about this device */
    bSuccess = m_Devices->GetDevice(Device,
                                    DeviceName,
                                    DEVICE_NAME_LEN,
                                    &DeviceId,
                                    &ClassImage,
                                    &DeviceStatus,
                                    &ProblemNumber);
    if (bSuccess)
    {
        /* Check if this is a hidden device */
        if ((m_ShowHidden == TRUE) || (!(DeviceStatus & DN_NO_SHOW_IN_DM)))
        {
            /* Check if the device has a problem */
            if (DeviceStatus & DN_HAS_PROBLEM)
            {
                OverlayImage = 1;
            }

            /* The disabled overlay takes precidence over the problem overlay */
            if (ProblemNumber == CM_PROB_HARDWARE_DISABLED)
            {
                OverlayImage = 2;
            }

            /* Add this device to the tree under its parent */
            hDevItem = InsertIntoTreeView(hParentTreeItem,
                                          DeviceName,
                                          (LPARAM)DeviceId,
                                          ClassImage,
                                          0);


            if (hDevItem)
            {
                /* Check if this child has any children itself */
                RecurseChildDevices(Device, hDevItem);
            }
        }
    }


    for (;;)
    {
        /* Check if the parent device has anything at the same level */
        bSuccess = m_Devices->GetSiblingDevice(Device, &Device);
        if (bSuccess == FALSE) break;

        /* Lookup the info about this device */
        bSuccess = m_Devices->GetDevice(Device,
                                        DeviceName,
                                        DEVICE_NAME_LEN,
                                        &DeviceId,
                                        &ClassImage,
                                        &DeviceStatus,
                                        &ProblemNumber);
        if (bSuccess)
        {
            /* Check if this is a hidden device */
            if (DeviceStatus & DN_NO_SHOW_IN_DM)
            {
                if (m_ShowHidden == FALSE)
                    continue;
            }

            /* Check if the device has a problem */
            if (DeviceStatus & DN_HAS_PROBLEM)
            {
                OverlayImage = 1;
            }

            /* The disabled overlay takes precidence over the problem overlay */
            if (ProblemNumber == CM_PROB_HARDWARE_DISABLED)
            {
                OverlayImage = 2;
            }


            /* Add this device to the tree under its parent */
            hDevItem = InsertIntoTreeView(hParentTreeItem,
                                            DeviceName,
                                            (LPARAM)DeviceId,
                                            ClassImage,
                                            0);
            if (hDevItem)
            {
                /* Check if this child has any children itself */
                RecurseChildDevices(Device, hDevItem);
            }
        }
    }

    (void)TreeView_SortChildren(m_hTreeView,
                                hParentTreeItem,
                                0);
}
Пример #13
0
BOOL
CDeviceView::ListDevicesByType()
{
    HTREEITEM hDevItem = NULL;
    GUID ClassGuid;
    WCHAR ClassName[CLASS_NAME_LEN];
    WCHAR ClassDescription[CLASS_DESC_LEN];
    INT ClassIndex;
    INT ClassImage;
    LPTSTR DeviceId = NULL;
    BOOL bSuccess;


    /* Get the details of the root of the device tree */
    bSuccess = m_Devices->GetDeviceTreeRoot(ClassName, CLASS_NAME_LEN, &ClassImage);
    if (bSuccess)
    {
        /* Add the root of the device tree to the treeview */
        m_hTreeRoot = InsertIntoTreeView(NULL,
                                         ClassName,
                                         NULL,
                                         ClassImage,
                                         0);
    }

    /* If something went wrong, bail */
    if (m_hTreeRoot == NULL) return FALSE;

    ClassIndex = 0;
    do
    {
        /* Get the next device class */
        bSuccess = m_Devices->EnumClasses(ClassIndex,
                                          &ClassGuid,
                                          ClassName,
                                          CLASS_NAME_LEN,
                                          ClassDescription,
                                          CLASS_DESC_LEN,
                                          &ClassImage);
        if (bSuccess)
        {
            BOOL bDevSuccess, AddedParent;
            HANDLE Handle = NULL;
            WCHAR DeviceName[DEVICE_NAME_LEN];
            INT DeviceIndex = 0;
            BOOL MoreItems = FALSE;
            BOOL DeviceHasProblem = FALSE;
            ULONG DeviceStatus = 0;
            ULONG ProblemNumber = 0;
            ULONG OverlayImage = 0;

            AddedParent = FALSE;

            do
            {
                /* Enum all the devices that belong to this class */
                bDevSuccess = m_Devices->EnumDevicesForClass(&Handle,
                                                             &ClassGuid,
                                                             DeviceIndex,
                                                             &MoreItems,
                                                             DeviceName,
                                                             DEVICE_NAME_LEN,
                                                             &DeviceId,
                                                             &DeviceStatus,
                                                             &ProblemNumber);
                if (bDevSuccess)
                {
                    /* Check if this is a hidden device */
                    if (DeviceStatus & DN_NO_SHOW_IN_DM)
                    {
                        if (m_ShowHidden == FALSE)
                        {
                            DeviceIndex++;
                            continue;
                        }
                    }

                    /* Check if the device has a problem */
                    if (DeviceStatus & DN_HAS_PROBLEM)
                    {
                        DeviceHasProblem = TRUE;
                        OverlayImage = 1;
                    }

                    /* The disabled overlay takes precidence over the problem overlay */
                    if (ProblemNumber == CM_PROB_HARDWARE_DISABLED)
                    {
                        OverlayImage = 2;
                    }


                    /* We have a device, we're gonna need to add the parent first */
                    if (AddedParent == FALSE)
                    {
                        /* Insert the new class under the root item */
                        hDevItem = InsertIntoTreeView(m_hTreeRoot,
                                                      ClassDescription,
                                                      NULL,
                                                      ClassImage,
                                                      0);

                        /* Don't add it again */
                        AddedParent = TRUE;
                    }

                    /* Add the device under the class item */
                    (VOID)InsertIntoTreeView(hDevItem,
                                             DeviceName,
                                             (LPARAM)DeviceId,
                                             ClassImage,
                                             OverlayImage);

                    /* Check if there's a problem with the device */
                    if (DeviceHasProblem)
                    {
                        /* Expand the class */
                        (VOID)TreeView_Expand(m_hTreeView,
                                              hDevItem,
                                              TVE_EXPAND);
                    }
                }

                DeviceIndex++;

            } while (MoreItems);

            /* Check if this class has any devices */
            if (AddedParent == TRUE)
            {
                /* Sort the devices alphabetically */
                (VOID)TreeView_SortChildren(m_hTreeView,
                                            hDevItem,
                                            0);
            }
        }

        ClassIndex++;

    } while (bSuccess);

    /* Sort the classes alphabetically */
    (VOID)TreeView_SortChildren(m_hTreeView,
                                m_hTreeRoot,
                                0);

    /* Expand the root item */
    (VOID)TreeView_Expand(m_hTreeView,
                          m_hTreeRoot,
                          TVE_EXPAND);

    /* Pre-select the root item */
    (VOID)TreeView_SelectItem(m_hTreeView,
                              m_hTreeRoot);

    return 0;
}
Пример #14
0
///////////////////////////////////////////////////////////////
// EnumChildren - キーのサブキーを列挙する
int CFolderDlg::EnumChildren(HWND hwndTV, HTREEITEM hParent, LPTSTR pszPath)
{
	int rc;
    DWORD nChild;
	HANDLE ff;
	WIN32_FIND_DATA wfd;
	TCHAR szName[MAX_PATH];
	TVINSERTSTRUCT tvis;
	DWORD dwCnt = 0;

	wsprintf (szName, _T("%s\\*.*"), pszPath);

	ff = FindFirstFile (szName, &wfd);
	if (ff != INVALID_HANDLE_VALUE) {
		while (1) {
			if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ||
				wfd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY) {
				// 下位のディレクトリがあるか検査
				nChild = CountChildren (pszPath, wfd.cFileName);

				// メモリカード?
				int nIndex = 1; // default icon index
				if (wfd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY) {
					wsprintf(szName, _T("%s\\%s"), pszPath, wfd.cFileName);
					SHFILEINFO shfi;
					SHGetFileInfo(szName, NULL, &shfi, sizeof(shfi), SHGFI_SMALLICON | SHGFI_ICON);
					nIndex = ImageList_AddIcon(m_hImageList, shfi.hIcon);
				}

				// ツリー ビュー コントロールにキーを挿入する
				tvis.hParent      = hParent;
				tvis.hInsertAfter = TVI_SORT;
				tvis.item.mask    = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN;
				tvis.item.pszText = wfd.cFileName;
				tvis.item.iImage  = nIndex;
				tvis.item.iSelectedImage = nIndex;
				tvis.item.cChildren = (nChild ? 1 : 0);
				TreeView_InsertItem(hwndTV, &tvis);

				dwCnt++;
			}
			rc = FindNextFile (ff, &wfd);
			if (rc == 0)
				break;
		}
		FindClose(ff);
	}

    // サブキーがない場合は展開ボタンを削除する
    TVITEM tvi;
	tvi.hItem = hParent;
	tvi.mask  = TVIF_CHILDREN;
    if (dwCnt == 0)
        tvi.cChildren = 0;
    else
        tvi.cChildren = 1;
	TreeView_SetItem (hwndTV, &tvi);

	// ソート
	TreeView_SortChildren(hwndTV, hParent, 0);

	return dwCnt;
}