| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 778 人关注过本帖
标题:请问高手一个小问题〜要怎在一个是装加个按钮〜并且让它有该有 ...
取消只看楼主 加入收藏
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
结帖率:97.66%
收藏
已结贴  问题点数:20 回复次数:2 
请问高手一个小问题〜要怎在一个是装加个按钮〜并且让它有该有的功能?
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册


上边图的我会做〜只是下边图多个红框部份〜不知道要怎么镶嵌上去?
2011-05-20 11:29
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
收藏
得分:0 
我的代码是这样写的~不知道要怎加上那个功能?(但是这样写并没有那个功能)
百度查找的关键字示什么?提示一下~

Form1
程序代码:
Private Sub BrowseCmd_Click()

Dim Path As String

    Path = BrowseForFolder(Me, 0, "Select Project's Location :")
    If (Trim(Path) <> "") Then
        TextTarget.Text = Path
    End If
    
    ComAdd1.Enabled = True: ComAdd2.Enabled = True
    ComLess1.Enabled = True: ComLess2.Enabled = True
    
End Sub


Module1
程序代码:
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)

Public Type BrowseInfo
    hWndOwner As Long
    pIDLRoot As Long
    pszDisplayName As Long
    lpszTitle As Long
    ulFlags As Long
    lpfnCallback As Long
    lParam As Long
    iImage As Long
End Type

Public Const BIF_RETURNONLYFSDIRS = &H1
Public Const MAX_PATH_LEN = (256 - 1)


Public Function BrowseForFolder(ByRef owner As Form, ByRef StartLoc As Long, ByRef Title As String) As String

Dim lpbi As BrowseInfo
Dim lpIDList As Long
Dim sPath As String
Dim iNull As Integer
Dim code As Integer, Description As String

On Error GoTo ErrorHandling
    
    With lpbi
        'Set the owner window
        .hWndOwner = owner.hwnd
        ' Specific Root Location
        .pIDLRoot = StartLoc
        'lstrcat appends the two strings and returns the memory address
        .lpszTitle = lstrcat(Title, "")
        'Return only if the user selected a directory
        .ulFlags = BIF_RETURNONLYFSDIRS
    End With

    lpIDList = SHBrowseForFolder(lpbi)
    If lpIDList Then
        sPath = String$(MAX_PATH_LEN, 0)
        'Get the path from the IDList
        Call SHGetPathFromIDList(lpIDList, sPath)
        'free the block of memory
        Call CoTaskMemFree(lpIDList)
        iNull = InStr(sPath, vbNullChar)
        If iNull Then
           sPath = Left$(sPath, iNull - 1)
        End If
    End If
    BrowseForFolder = sPath
    
Exit Function

ErrorHandling:

    code = Err.Number
    Description = Err.Description
    MsgBox "BrowseForFolder" & " " & code & " " & Description
    Resume Next
    
End Function


[ 本帖最后由 wube 于 2011-5-20 14:20 编辑 ]

不要選我當版主
2011-05-20 14:18
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
收藏
得分:0 
谢谢了~用出来了~原来加一个参数就行了~
要写Me.hwnd~不能直接写Me~不然BrowseForFolder Type会出问题~

试过的结果要这样写才行~
path = BrowseForFolder(Me.hwnd, "Select Project's Location :", , NEWFOLDER)

总之解决了~感谢高手~

不要選我當版主
2011-05-20 15:55
快速回复:请问高手一个小问题&#12316;要怎在一个是装加个按钮&#12316;并且让它有 ...
数据加载中...
 
   



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

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