Nick67
asked on
MS Access VBA Open Explorer.exe window to thumbnails/extra large icons view
I have a button on an MS Access 2003 form that opens a Windows Explorer window at a specified folder location.
The code works perfectly.
The folder contains JPG images.
The window opens in Details view.
I want it to open, or be changed to, thumbnails view in XP or Extra Large Icons in Windows 7
I have some familiarity with Windows API coding -- not a lot -- and not enough to figure out how to do this.
As this is a database application run on 13 units, with 10's of thousands of folders, no suggestions of going into Folder Options | View will be entertained. It must be coded. I have looked at Bags and BagsMRU in the registry and can't figure out how to make that work.
Any suggestions will be welcome.
Thanks,
Nick67
The code works perfectly.
The folder contains JPG images.
The window opens in Details view.
I want it to open, or be changed to, thumbnails view in XP or Extra Large Icons in Windows 7
I have some familiarity with Windows API coding -- not a lot -- and not enough to figure out how to do this.
As this is a database application run on 13 units, with 10's of thousands of folders, no suggestions of going into Folder Options | View will be entertained. It must be coded. I have looked at Bags and BagsMRU in the registry and can't figure out how to make that work.
Any suggestions will be welcome.
Thanks,
Nick67
Private Sub cmdOpenFolder_Click()
Dim db As Database
Dim rs As Recordset
Dim WindowState As Integer
Dim mypath As String
Set db = CurrentDb
Set rs = db.OpenRecordset("select distinct Path from tblPictures where [JobID]=" & Me.JobID & ";", dbOpenDynaset, dbSeeChanges)
'Bail on an empty recordset
If (rs.EOF And rs.BOF) = False Then
rs.MoveFirst
If rs.RecordCount > 1 Then
WindowState = vbNormalNoFocus
Else
WindowState = vbMaximizedFocus
End If
Do While rs.EOF = False
Shell "explorer.exe " & Chr(34) & rs!Path & Chr(34), WindowState
mypath = rs!Path
rs.MoveNext
Loop
End If
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't do a lot of Windows API stuff -- but I dabble in it when needful -- which in this case it is
I can get the handle, and set the window to the foreground.
Now, how do I PostMessage or SendMessage...
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
... that I want thumbnails or extra large icons.
Thumbnails is related to &H702D& or 28717
Extra Large Icons ... don't know
I can get the handle, and set the window to the foreground.
Now, how do I PostMessage or SendMessage...
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
... that I want thumbnails or extra large icons.
Thumbnails is related to &H702D& or 28717
Extra Large Icons ... don't know
Dim hWnd As Long
'all right, give 'er
'FnFindWindowLike(Something as String)is an API call that returns a windows handle
'to a window whose caption contains the string passed in, or it returns 0 if it fails
mypath = Left(mypath, Len(mypath) - 1)
MsgBox mypath
hWnd = FnFindWindowLike(mypath)
MsgBox hWnd
'similarly FnSetForegroundWindow (Something as String) is an API call that
'Brings a window whose caption contains the string passed in to the foreground
FnSetForegroundWindow (mypath)
ASKER
@LSMConsulting
The code for that question looks good -- but it just opens two windows instead of one for me.
And changes neither of them from details no matter which of the possible constants I send in.
It also takes quite some time to time out before giving up on chnaging either window.
The code for that question looks good -- but it just opens two windows instead of one for me.
And changes neither of them from details no matter which of the possible constants I send in.
It also takes quite some time to time out before giving up on chnaging either window.
ASKER
And I am definitely getting the right window when I look for its handle because if I call it via...
Shell "explorer.exe " & Chr(34) & rs!Path & Chr(34), vbNormalNoFocus
...so I can move it around...
Declare Function MoveWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Dim retval
retval = MoveWindow(hWnd, 200, 0, 800, 600, 1)
...it moves. So there is something I am not getting!
Shell "explorer.exe " & Chr(34) & rs!Path & Chr(34), vbNormalNoFocus
...so I can move it around...
Declare Function MoveWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Dim retval
retval = MoveWindow(hWnd, 200, 0, 800, 600, 1)
...it moves. So there is something I am not getting!
Can you post the full code you're using?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad you got this fixed. I got busy earlier, sorry I bailed on you.
ASKER
No Biggie.
Sometimes the act of having to post it gets the juices flowing.
That, and making sure the code I post is going to work for someone else.
I knew I was getting the right handle because I could reposition the window.
That left child windows and trial-and-error
What would you like for points for your time, and how do I get them to you while accepting my own posting as the solution.
Nick67
Sometimes the act of having to post it gets the juices flowing.
That, and making sure the code I post is going to work for someone else.
I knew I was getting the right handle because I could reposition the window.
That left child windows and trial-and-error
What would you like for points for your time, and how do I get them to you while accepting my own posting as the solution.
Nick67
You can select your own comment as the Solution, and close this. If you used any of my suggestions, then you can certainly award points to my posts, but if you didn't then please don't feel obligated to award any points.
ASKER
SendKeys technically could work, but the known Sendkeys bug makes that unworkable. LSMConsulting pointed in the right direction that there could be child windows involved
ASKER
I had to get rid of all the SendKeys code I had when Win7 came into the environment because the NumLock bug reared it's head.
SendKeys would work, in theory, but I can't use it.