Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse from a listbox?

Status
Not open for further replies.
Oct 22, 2001
215
US
Can any one tell me how to browse a file from a list box...? I need to double click a list box and select a file.
Thanks
 
What exactly do you mean by browse a file. You can browse for a file but I'm not sure what you mean. If I assume you mean to double click on the listbox and open a file to be read that would be much clearer. If that is what you mean the put some code behind the doubleclick event for the listbox and use supershell. Supershell will open the application using whatever application is registered in the registry to open it.

Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type

Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" _
(ByVal lpApplicationName As String, ByVal lpCommandLine As String, _
lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As _
SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal _
dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory _
As String, lpStartupInfo As STARTUPINFO, lpProcessInformation _
As PROCESS_INFORMATION) As Long

Public Function SuperShell(ByVal App As String, ByVal WorkDir As String, _
dwMilliseconds As Long, ByVal start_size As Integer, ByVal Priority_Class _
As Byte) As Boolean

Dim pclass As Long
Dim sInfo As STARTUPINFO
Dim pinfo As PROCESS_INFORMATION
'Not used, but needed
Dim sec1 As SECURITY_ATTRIBUTES
Dim sec2 As SECURITY_ATTRIBUTES

On Error GoTo HandleErr

sec1.nLength = Len(sec1)
sec2.nLength = Len(sec2)
sInfo.cb = Len(sInfo)

sInfo.dwFlags = STARTF_USESHOWWINDOW
sInfo.wShowWindow = start_size

pclass = Priority_Class

If CreateProcess(vbNullString, App, sec1, sec2, False, pclass, _
0&, WorkDir, sInfo, pinfo) Then
WaitForSingleObject pinfo.hProcess, dwMilliseconds
SuperShell = True
Else
SuperShell = False
End If

ExitProc:
Exit Function

HandleErr:

Call HandleTheError("basSuperShell", "SuperShell", Err)
GoTo ExitProc
Resume

End Function


Steve King Growth follows a healthy professional curiosity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top