Update - would you believe Im "this" close?
Heres all the code for the entire class that I have so far (in 2 posts)...
Imports System
Imports System.Text
Imports Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Public Class OpenFilename
Inherits CommonDialog
Declare a bunch of APIs, hoping some will work...
Declare Auto Function GetOpenFileName Lib "Comdlg32.dll" (<[In](), Out()> ByVal ofn As OpenFileName) As Boolean
Declare Function GetParent Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As IntPtr) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String) As Long
Declare Auto Function SetDlgItemText Lib "user32" (ByVal hDlg As IntPtr, ByVal nIDDlgItem As Long, ByVal lpString As String) As Long
Declare the Hook delegate so we can "hook" to it later.
Delegate Function OFNHookProc(ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
If you dont persist the hook procedure, it will be GCd before the call gets to it.
Private HookProcSub As OFNHookProc = AddressOf HookProc
Set the initial view - Thumbnail, Icons, Details, etc. (yeah, right!)
Private lngInitialView As Long
Set all possible constants Ive found so far.
Hook constants
Const WM_SETFOCUS = &H7
Const WM_INITDIALOG = &H110
Const WM_LBUTTONDOWN = &H201
Const WM_RBUTTONDOWN = &H204
Const WM_MOVE = &H3
Const WM_COMMAND = &H111
Const WM_NOTIFY As Long = &H4E&
Flags for OpenFileName
Const OFN_ALLOWMULTISELECT As Long = &H200
Const OFN_CREATEPROMPT As Long = &H2000
Const OFN_ENABLEHOOK As Long = &H20
Const OFN_ENABLETEMPLATE As Long = &H40
Const OFN_ENABLETEMPLATEHANDLE As Long = &H80
Const OFN_EXPLORER As Long = &H80000
Const OFN_EXTENSIONDIFFERENT As Long = &H400
Const OFN_FILEMUSTEXIST As Long = &H1000
Const OFN_HIDEREADONLY As Long = &H4
Const OFN_LONGNAMES As Long = &H200000
Const OFN_NOCHANGEDIR As Long = &H8
Const OFN_NODEREFERENCELINKS As Long = &H100000
Const OFN_NOLONGNAMES As Long = &H40000
Const OFN_NONETWORKBUTTON As Long = &H20000
Const OFN_NOREADONLYRETURN As Long = &H8000&
Const OFN_NOTESTFILECREATE As Long = &H10000
Const OFN_NOVALIDATE As Long = &H100
Const OFN_OVERWRITEPROMPT As Long = &H2
Const OFN_PATHMUSTEXIST As Long = &H800
Const OFN_READONLY As Long = &H1
Const OFN_SHAREAWARE As Long = &H4000
Const OFN_SHAREFALLTHROUGH As Long = 2
Const OFN_SHAREWARN As Long = 0
Const OFN_SHARENOWARN As Long = 1
Const OFN_SHOWHELP As Long = &H10
Const OFS_MAXPATHNAME As Long = 260
ToolbarWindow32 buttons. Ive actually only found the first two, and Im guessing at the FileView button.
Const TB_BTN_UPONELEVEL = 40961
Const TB_BTN_NEWFOLDER = 40962
Const TB_BTN_FILEVIEW = 40963
Const BM_SETSTATE = &HF3
Constants on the dialog window.
Const IDOK As Long = 1
Const IDCANCEL As Long = 2
Const IDFILEOFTYPETEXT As Long = &H441
Const IDFILENAMETEXT As Long = &H442
Const IDLOOKINTEXT As Long = &H443
Const WM_USER = &H400
Const CDM_FIRST = (WM_USER + 100)
Const CDM_SETCONTROLTEXT As Long = CDM_FIRST + &H4
Const CDM_HIDECONTROL As Long = (CDM_FIRST + &H5)
Const EM_GETTEXTRANGE = (WM_USER + 75)
Const TB_GETBUTTON = (WM_USER + 23)
View constants.
Public Const SHVIEW_ICON As Long = &H7029
Public Const SHVIEW_LIST As Long = &H702B
Public Const SHVIEW_REPORT As Long = &H702C
Public Const SHVIEW_THUMBNAIL As Long = &H702D
Public Const SHVIEW_TILE As Long = &H702E
Dont know what this is for, but it looked good
Public Structure TBBUTTON
Dim iBitmap As Integer
Dim idCommand As Integer
Dim fsState As Byte
Dim fsStyle As Byte
Dim bReserved1 As Byte
Dim bReserved2 As Byte
Dim dwData As Integer
Dim iString As Integer
End Structure
Dont know what this is for, but it looked good
Public Structure LHDR
Public hwndFrom As IntPtr
Public idFrom As Integer
Public code As Integer
End Structure
Dont know what this is for, but it looked good
Private Structure TEXTRANGE
Dim cpMin As Long
Dim cpMax As Long
Dim lpstrText As Long
End Structure
(rest of code to follow)