在TShellTreeView里实现只显示目录的功能,就像“选择目录”对话框的目录树。TShellTreeView的根目录为桌面,显示包括隐藏目录在内的所有目录,但在桌面下不显示“Internet Explorer”,“回收站”等项,在各驱动器下,不显示“回收站”。总之,出来的结果就和“选择目录”对话框中的目录树显示的内容一致。直接调用SelectDirectory出来的是一个对话框,但我只想要一个TTreeView控件作为界面的一部分。我想用判断名字的方法来取消它们的显示,但在各个Windows平台下可能运行的结果不会相同,不知道各位高手有什么高招。

解决方案 »

  1.   

    http://expert.csdn.net/Expert/TopicView1.asp?id=1917857还是用SelectDirectorySelectDirectory('选择目录','',Dir)就是这种效果~~~
      

  2.   

    但不知道怎么把SelectDirectory显示的TTreeView嵌到我的窗口上去呢?
      

  3.   

    将TShellTreeView的Root属性设置为rfMyComputer就可以了!这样就会只显示文件夹而不显示回收站和IE了
      

  4.   

    wrxljf(小黑马灵):谢谢你的建议,不过将TShellTreeView的Root属性设置为rfMyComputer后,也不只显示文件夹,“打印机”,“控制面板”等系统文件夹也显示出来了。最难过滤掉的就是每一个驱动器内的回收站。我想不可能用设置Root的方法来解决,一定要一个过滤的程序,我希望做出来的效果就和SelectDirectory显示出的TTreeView的内容一致。
      

  5.   

    to 搂主
    但不知道怎么把SelectDirectory显示的TTreeView嵌到我的窗口上去呢?用findWindowEx把selectdirectory的handle找到
    再用setParent这个api函数就可以了
    The SetParent function changes the parent window of the specified child window. HWND SetParent(    HWND hWndChild, // handle of window whose parent is changing
        HWND hWndNewParent  // handle of new parent window
       );
     ParametershWndChildIdentifies the child window. hWndNewParentIdentifies the new parent window. If this parameter is NULL, the desktop window becomes the new parent window.  Return ValuesIf the function succeeds, the return value is the handle of the previous parent window.
    If the function fails, the return value is NULL. To get extended error information, call GetLastError. ResAn application can use the SetParent function to set the parent window of a pop-up, overlapped, or child window. The new parent window and the child window must belong to the same application. 
    If the window identified by the hWndChild parameter is visible, Windows performs the appropriate redrawing and repainting.
      

  6.   

    嗯,这也是一个方法,我来试试看。不过我的本意还是想要一个TreeView,真的就没有招了??
      

  7.   

    ghostmirror(mirror): 我试过了,一个模态对话框无法嵌入主窗口啊!