Exemple #1
0
LRESULT CMainFrame::OnTVSelChanged(int, LPNMHDR pnmh, BOOL&)
{
	// 如何解析参数
	LPNMTREEVIEW pnmtv = reinterpret_cast<LPNMTREEVIEW>(pnmh);
	CTreeViewCtrlEx tree = pnmh->hwndFrom;
	if (tree.IsWindow())
	{
		CTreeItem item = tree.GetSelectedItem();
		std::string path;
		for (; !item.IsNull() && !item.GetParent().IsNull(); item = item.GetParent())
		{
			std::string name(256, 0);
			item.GetText((LPTSTR)name.c_str(), 256);
			std::string temp = name.c_str();
			if (!path.empty())
			{
				path = temp + "/" + path;
			}
			else
			{
				path = temp;
			}
		}
		//
		if (_canvas)
		{
			path = Buddha::FileSystem::getInstancePtr()->getDataDirectory() + path;
			_canvas->changeModelFile(standardFilePath(path));
		}
	}

	return 0L;
}
Exemple #2
0
LRESULT CMainWindow::OnTVSelChanged(int, LPNMHDR pnmh, BOOL&)
{
  // 如何解析参数
  LPNMTREEVIEW pnmtv = reinterpret_cast<LPNMTREEVIEW>(pnmh);
  CTreeViewCtrlEx tree = pnmh->hwndFrom;
  if (tree.IsWindow())
    {
      CTreeItem item = tree.GetSelectedItem();
      std::string path;
      for (; !item.IsNull(); item = item.GetParent())
	{
	  std::string name(256, 0);
	  item.GetText((LPTSTR)name.c_str(), 256);
	  std::string temp = name.c_str();
	  if (!path.empty())
	    {
	      path = temp + "/" + path;
	    }
	  else
	    {
	      path = temp;
	    }
	}
      //
      m_wndStatusBar.SetPaneText(ID_DEFAULT_PANE, TEXT(path.c_str()));
      //
      mViewWindow.changeModelFile(path);
    }

  return 0L;
}
Exemple #3
0
LRESULT CMainFrame::OnTVSelChanged(int, LPNMHDR pnmh, BOOL&)
{
	// 如何解析参数
	{
		LPNMTREEVIEW pnmtv = reinterpret_cast<LPNMTREEVIEW>(pnmh);
		CTreeViewCtrlEx tree = pnmh->hwndFrom;
		if (tree.IsWindow())
		{
			CTreeItem item = tree.GetSelectedItem();
			std::string name(256, 0);
			item.GetText((LPTSTR)name.c_str(), 256);

			// 如何插入列表
			int r = rand();
			m_wndListView.SetTextColor((DWORD)r);
			static int i = 0;
			if (0 == m_wndListView.GetItemCount())
			{
				m_wndListView.InsertItem(i, "ok");
			}
			m_wndListView.SetItemText(i, 0, name.c_str());
			m_wndListView.SetItemText(i, 1, "1");
			m_wndListView.SetItemText(i, 2, "2");
			//++i;
		}
	}
	return 0L;
}
LRESULT CChildFrame::OnTvnSelChanged(int idCtrl, LPNMHDR pNMHDR, BOOL& bHandled)
{ 
    USES_CONVERSION; 
    HRESULT hr = E_FAIL; 

    idCtrl, pNMHDR, bHandled; 
    CTreeViewCtrl ctrlTree = m_wndCatalog; 

    bHandled = FALSE; 

    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; 
    ATLASSERT( pNMTreeView ); 

    { 
        m_pData.m_hTreeItem = pNMTreeView->itemNew.hItem; 
        m_pData.m_pTreeView = &m_wndCatalog; 
    } 

    CTreeItem hItem(pNMTreeView->itemNew.hItem, &m_wndCatalog); 

    TREE_ITEM_DATA * pCurrSel = NULL; 
    pCurrSel = (TREE_ITEM_DATA *) ctrlTree.GetItemData(hItem); 

    if (pCurrSel && STGTY_STREAM == pCurrSel->dwStgType) 
    { 
        CComPtr<IStream> spStrm; 
        hr = pCurrSel->spStgOrStrm->QueryInterface(&spStrm); 
        if (FAILED(hr)) return hr; 

        STATSTG st = { 0 }; 
        hr = spStrm->Stat(&st, STATFLAG_NONAME); 
        if (FAILED(hr)) return hr; 

        LARGE_INTEGER liBegin = { 0 }; 
        hr = spStrm->Seek(liBegin, STREAM_SEEK_SET, NULL); 

        BYTE * byBuff = new BYTE[st.cbSize.QuadPart+1]; 
        ZeroMemory(byBuff, (st.cbSize.QuadPart+1)*sizeof(BYTE)); 
        ULONG ulSize = 0; 
        hr = spStrm->Read(byBuff, st.cbSize.QuadPart, &ulSize); 

		ATLASSERT(SUCCEEDED(hr));

        if(st.cbSize.QuadPart) 
        { 
            CComSafeArray data; 
            data.CreateOneDim(VT_UI1, st.cbSize.QuadPart, (const void *)byBuff); 
            m_wndHexEdit.SetData(data); 
        } 
        else 
        {
            CComVariant data; 
            m_wndHexEdit.SetData(data); 
        }

        { 
            m_wndFileDetails.ShowWindow(SW_HIDE); 
            m_wndHexEdit.ShowWindow(SW_NORMAL); 
            SetSplitterPane(SPLIT_PANE_RIGHT, m_wndHexEdit); 
        } 

        delete [] byBuff; 
    } 
    else if (pCurrSel && STGTY_STORAGE == pCurrSel->dwStgType) 
    { 
        CComVariant data; 
        m_wndHexEdit.SetData(data); 
        m_wndHexEdit.ShowWindow(SW_HIDE); 

        std::vector<STATSTG_EX> vecFileInfo; 

        CTreeItem tiChild = hItem.GetChild(); 
        while (FALSE == tiChild.IsNull()) 
        { 
            TREE_ITEM_DATA * pData = (TREE_ITEM_DATA *)tiChild.GetData(); 

            STATSTG_EX statstgex; 

            do 
            { 
                if (pData->dwStgType == STGTY_STREAM) 
                { 
                    CComPtr<IStream> spStrm; 
                    hr = pData->spStgOrStrm->QueryInterface(&spStrm); 
                    if (FAILED(hr)) break; 
                    
                    hr = spStrm->Stat(&statstgex, STATFLAG_NONAME); 
                    if (FAILED(hr)) break; 
                } 
                else if (pData->dwStgType == STGTY_STORAGE) 
                { 
                    CComPtr<IStorage> spStg; 
                    hr = pData->spStgOrStrm->QueryInterface(&spStg); 
                    if (FAILED(hr)) break; 
                    
                    hr = spStg->Stat(&statstgex, STATFLAG_NONAME); 
                    if (FAILED(hr)) break; 
                } 
            } while(0); 
            
            statstgex.htiHost = tiChild.m_hTreeItem; 
            
            TCHAR szSwap[MAX_PATH] = { 0 }; 
            tiChild.GetText(szSwap, _countof(szSwap)); 
            TCHAR2WCHAR(szSwap, statstgex.szwName, _countof(statstgex.szwName)); 
            
            vecFileInfo.push_back(statstgex); 

            tiChild = tiChild.GetNextSibling(); 
        } 

        m_wndFileDetails.SetFileInfo(vecFileInfo); 

        m_wndFileDetails.ShowWindow(SW_NORMAL); 
        SetSplitterPane(SPLIT_PANE_RIGHT, m_wndFileDetails); 
    } 

    return 0;
}