| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1141 人关注过本帖
标题:打开文件夹后并选定文件
只看楼主 加入收藏
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
程序代码:
CLEAR ALL
CLOSE DATABASES ALL
frmMain = CREATEOBJECT("C_Form")
frmMain.Show
READ EVENTS
CLEAR
RETURN 

DEFINE CLASS C_Form AS Form
    Caption = ""
    Width = 600
    Height = 400
    AutoCenter = .T.
   
    ADD OBJECT Button1 AS CommandButton WITH Caption = "需定位的文件", Width = 100, Height = 25
    ADD OBJECT Text1   AS TextBox       WITH Value = "", Height = 25

    ADD OBJECT List1 AS C_ShowFile NOINIT WITH Visible = .F.
   
    PROCEDURE Arrange
        WITH ThisForm.Button1
            .Top = 5
            .Left = 5
        ENDWITH
        WITH ThisForm.Text1
            .Top = ThisForm.Button1.Top
            .Left = ThisForm.Button1.Left + ThisForm.Button1.Width + 5
            .Width = ThisForm.Width - .Left - 5
        ENDWITH
        WITH ThisForm.List1
            .Top = ThisForm.Button1.Top + ThisForm.Button1.Height + 5
            .Left = 5
            .Height = ThisForm.Height - .Top - 5
            .Width = ThisForm.Width - .Left - 5
        ENDWITH
    ENDPROC
   
    PROCEDURE Activate
        ThisForm.Arrange
    ENDPROC
   
    PROCEDURE Resize
        ThisForm.Arrange
    ENDPROC
   
    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
    PROCEDURE Button1.CLick
        WITH ThisForm
            .Text1.Value = GETFILE()
            .List1.Init(.Text1.Value)
            .List1.Visible = .T.
        ENDWITH
    ENDPROC
   
    PROCEDURE Text1.Valid
        IF !EMPTY(This.Value)
            WITH ThisForm.List1
                .Init(This.Value)
                .Visible = .T.
            ENDWITH
        ENDIF
    ENDPROC
   
ENDDEFINE 

DEFINE CLASS C_ShowFile AS ListBox

    PROCEDURE Init(tcFileName AS Character)
        LOCAL lcPath AS Character
        LOCAL laFiles[1,5]
        LOCAL lnIndex AS Integer
        LOCAL lnPos AS Integer
       
        IF (PCOUNT() > 0) .AND. (VARTYPE(tcFileName) == "C") .AND. !EMPTY(tcFileName)
            tcFileName = ALLTRIM(UPPER(tcFileName))
            IF FILE(tcFileName)
                lcPath = JUSTPATH(tcFileName)
                IF ADIR(laFiles, lcPath + "\*.*") > 0
                    WITH This
                        .Clear
                        .ColumnCount = 4
                        .ColumnWidths = "200,100,100,100"
                        FOR lnIndex = 1 TO ALEN(laFiles,1)
                            .AddListItem(laFiles[lnIndex,1], lnIndex, 1)
                            .AddListItem(TRANSFORM(laFiles[lnIndex,2], "999,999,999,999"), lnIndex, 2)
                            .AddListItem(DTOC(laFiles[lnIndex,3]), lnIndex, 3)
                            .AddListItem(laFiles[lnIndex,4], lnIndex, 4)
                            IF (lcPath + "\" + laFiles[lnIndex,1]) == tcFileName
                                lnPos = lnIndex
                            ENDIF
                        NEXT
                        .ListIndex = lnPos
                    ENDWITH
                ENDIF
            ELSE
                This.Clear
            ENDIF
        ENDIF
       
    ENDPROC
   
ENDDEFINE


[ 本帖最后由 TonyDeng 于 2012-1-8 23:55 编辑 ]

授人以渔,不授人以鱼。
2012-01-08 23:53
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:0 
回复 11楼 TonyDeng
加20分
2012-01-09 09:58
wengjl
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:109
帖 子:2215
专家分:3882
注 册:2007-4-27
收藏
得分:0 
高手,学一招。感谢!

只求每天有一丁点儿的进步就可以了
2012-01-09 13:02
xs591222
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:28
帖 子:682
专家分:1299
注 册:2009-3-1
收藏
得分:0 
谢谢啦
一等一的高手
2012-01-09 19:33
qingxinwufua
Rank: 2
等 级:论坛游民
帖 子:21
专家分:48
注 册:2011-9-6
收藏
得分:0 
高手啊
2012-01-10 08:35
快速回复:打开文件夹后并选定文件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029399 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved