我想实现这样的功能点一个按牛 出现个一个选择窗口,选择图片文件,让后窗体上有个TEXT控件,在控件上显示刚才选择图片的路径!!!
解决方案 »
- VB POST上传图片的问题
- 从CommonDialog中选择多个文件
- 如何配合使用treeview控件和listview控件显示出“我的电脑”里面每个分区的内容
- 我现在是进入数据库jyglxt,打开表organ_password_database后我想删除此数据库jyglxt,直接删除提示说数据库正在使用,我想关闭,如何做
- 为什么我设置工具栏的imagelist总是设不上?
- 关于使用api创建数据源的问题!(见者有分!)
- 在vb开发环境中怎样才能知道登录到数据库的用户数(如sql server)
- Listview的滚动条问题
- 关于读取文本文件中字符串的问题
- 今天心情特好!散分
- 如何隐藏运行的程序(按下ctrl+alt+del看不见)?
- 一个connection下的多个recordset问题
是不是就要这种呢?
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 TypeConst BIF_RETURNONLYFSDIRS = 1
Const MAX_PATH = 260Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String
'declare variables to be used
Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo 'initialise variables
With udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With 'Call the browse for folder API
lpIDList = SHBrowseForFolder(udtBI)
'get the resulting string path
If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)
If iNull Then sPath = Left$(sPath, iNull - 1)
End If 'If cancel was pressed, sPath = ""
BrowseForFolder = sPathEnd FunctionPrivate Sub Command1_Click()
Dim strResFolder As String
strResFolder = BrowseForFolder(hWnd, "Please select a folder.")
Text1.Text = strResFolder
End Sub
Public Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End TypePublic Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long在
Private Sub Command1_Click()
Dim ofn As OPENFILENAME
Dim a As Long ofn.lStructSize = Len(ofn)
ofn.hwndOwner = frmMain.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "图片文件 (*.bmp)" + Chr$(0) + "*.bmp" + Chr$(0)
ofn.lpstrFile = Space$(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = CurDir
ofn.lpstrTitle = "打开文件"
ofn.flags = 0 a = GetOpenFileName(ofn) If (a) Then
Text1.text = Trim$(ofn.lpstrFile)
Else
'MsgBox "按了取消键"
End If
End Sub