当前位置:编程学习 > VB >>

让 CommonDialog(文件选取) 自动反

With CommonDialog1
  .CancelError = True 
  .InitDir = "C:\"
  .Filter = "所有文件(*.txt)|*.txt"
  .DialogTitle = ""
  .ShowOpen
  End With



CommonDialog1 打开后, 假设可以看到

1.txt
2.txt
3.txt
4.txt
5.txt
6.txt


希望 2.txt 能够用程序控制被选取 ( 反白色 ) 
不知要如何写 ?

正常都是用滑鼠点 2.txt 才会出现反白
现在是希望用程序自动使其出现反白 --------------------编程问答-------------------- 试试 GetOpenFileName API,调用前将 lpstrTitle 属性设置成你缺省选中的文件名。

       Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" _
           (ByRef pOpenfilename As OPENFILENAME) As Integer
 
        Structure OPENFILENAME
            Public lStructSize As Integer
            Public hwndOwner As Integer
            Public hInstance As Integer
            Public lpstrFilter As String
            Public lpstrCustomFilter As String
            Public nMaxCustFilter As Integer
            Public nFilterIndex As Integer
            Public lpstrFile As String
            Public nMaxFile As Integer
            Public lpstrFileTitle As String
            Public nMaxFileTitle As Integer
            Public lpstrInitialDir As String
            Public lpstrTitle As String
            Public flags As Integer
            Public nFileOffset As Short
            Public nFileExtension As Short
            Public lpstrDefExt As String
            Public lCustData As Integer
            Public lpfnHook As Integer
            Public lpTemplateName As String
        End Structure --------------------编程问答-------------------- 要怎么在commondialog里实现可预览呢? --------------------编程问答--------------------
引用 1 楼 of123 的回复:
试试 GetOpenFileName API,调用前将 lpstrTitle 属性设置成你缺省选中的文件名。

       Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" _
           (ByRef pOpenfilename As OPENFILENAME) As In……


已经测试了
不过没成功
无法反白
补充:VB ,  控件
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,