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!!
Printable View
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!!
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
Perfect works very well!
only two constants....
IDFILENAMETEXT = ???
IDFILEOFTYPETEXT =???
THANKS!
VB Code:
Private Const IDFILEOFTYPETEXT As Long = &H441& Private Const IDFILENAMETEXT As Long = &H442&
:)
Thanks JoshT!
your are very good friend!