|
-
Feb 15th, 2002, 03:17 AM
#1
Thread Starter
New Member
Thanks Hack!
This works very well but i want use GetOpenFileName API and not the COMMON DIALOG object.
JoshT thanks for your replies, i've not understand very well...
if you have a complete example....
However THANKS ALL!!
-
Feb 15th, 2002, 07:21 AM
#2
Black Cat
Can you follow this? I snipped the API declarations for brevity - you proably already have them or can look them up.
VB Code:
Public Function ShowOpen(hwndOwner As Long) As String
Dim OFN As OPENFILENAME 'struct
Dim retval As Long 'API return value
strFileName = "" 'make sure this doesn't stay in memory
lngPrevProc = 0
With OFN
.lStructSize = Len(OFN)
.hwndOwner = hwndOwner
.hInstance = 0
.lpstrFilter = "All Files (*.*)" & vbNullChar & "*.*" & vbNullChar & vbNullChar
'.lpstrCustomFilter = vbNullChar
.nMaxCustFilter = 0
.nFilterIndex = 1
.lpstrFile = String$(257, vbNullChar)
.nMaxFile = Len(.lpstrFile)
.lpstrFileTitle = String$(257, vbNullChar)
.nMaxFileTitle = Len(.lpstrFileTitle)
.lpstrInitialDir = "C:\" & vbNullChar
.lpstrTitle = "Select a file to open:" & vbNullChar
.flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY Or OFN_EXPLORER _
Or OFN_ENABLEHOOK
.nFileOffset = 0
.nFileExtension = 0
'.lpstrDefExt = vbNullChar
.lCustData = 0
.lpfnHook = Wrap(AddressOf OFNHookProc)
'.lpTemplateName = vbNullChar
End With
retval = GetOpenFileName(OFN)
If retval <> 0 Then
ShowOpen = Left$(OFN.lpstrFile, InStr(OFN.lpstrFile, vbNullChar) - 1)
End If
End Function
'function to hook the common dialog
Private Function OFNHookProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Static c As Long
Dim hwndParent As Long 'handle to the parent window
Dim retval As Long 'api return value
c = c + 1
Debug.Print "OFNHookProc Called " & c
Select Case uMsg
Case WM_INITDIALOG 'initilization of the file open dialog box
hwndParent = GetParent(hwnd)
'set custom text
If hwndParent <> 0 Then
retval = SendMessage(hwndParent, CDM_SETCONTROLTEXT, IDFILENAMETEXT, ByVal "File Name:")
retval = SendMessage(hwndParent, CDM_SETCONTROLTEXT, IDFILEOFTYPETEXT, ByVal "Files of Type:")
End If
Case WM_DESTROY 'sent before any child windows are destroyed yet
Case Else
OFNHookProc = 0
End Select
End Function
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Feb 15th, 2002, 09:20 AM
#3
Thread Starter
New Member
Perfect works very well!
only two constants....
IDFILENAMETEXT = ???
IDFILEOFTYPETEXT =???
THANKS!
-
Feb 15th, 2002, 11:19 AM
#4
Black Cat
VB Code:
Private Const IDFILEOFTYPETEXT As Long = &H441&
Private Const IDFILENAMETEXT As Long = &H442&
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Feb 19th, 2002, 07:51 AM
#5
Thread Starter
New Member
Thanks JoshT!
your are very good friend!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|