Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Mon, 11 Feb 2008 10:45:51 -0500,    group: microsoft.public.platformsdk.shell        back       


Folder view auto arrange - IShellFolder?   
I'm wondering about how to organize a folder
view. In WinME, for instance, there's a bug that
causes the contents to often be sprawled out in
a folder, causing a horizontal scrollbar to show.
In XP there's a bug that causes Explorer to forget
view settings. (Bill G. seems to have a thing about
those giant icons, as I find that the "Large Icon"
view periodically degrades to the giant icon view...
the name of which I've forgotten.)

  There's an IShellFolder.CreateViewObject, which
takes a FOLDERFLAGS value, but it seems to only
be used for creating a new window. There also seem
to be some newer methods that might apply, but are
only available in XP+.

  What I want to to is the same as when one goes
to View -> Refresh and all the icons straighten out.
Optionally, I might also want to control the view mode.
I wonder whether maybe calling SetWindowLong on the
listview, adding the autoarrange flag to its style, might
even be a usable approach.
date: Mon, 11 Feb 2008 10:45:51 -0500   author:   mayayana

Re: Folder view auto arrange - IShellFolder?   
Woops. An addendum to that post. I've noticed
that in a folder's View menu there's Refresh,
Line Up Icons, Arrange Icons by..., and Auto Arrange!
I'm not sure which methods do what on what systems,
but what I have in mind is to (at least) control the
option to show the icons in neat rows when the
window opens.
date: Mon, 11 Feb 2008 10:54:28 -0500   author:   mayayana

Re: Folder view auto arrange - IShellFolder?   
Judging from the lack of response, there seems to
be little interest in this topic, but just in case
anyone else is curious...

  I wanted to auto-arrange the icons in icon view
when a folder is opened, to make sure they're in neat
rows and not sprawled to the right. It turns out to
be easier than I thought, as the ShellFolderView is
actually a basic ListView window. So given the IE
handle of a folder window, the following VB module
seems to do the job. (So far only tested on Win98.)

Private Const LVM_FIRST As Long = &H1000    ' ListView messages
Private Const LVM_ARRANGE As Long = (LVM_FIRST + 22)
Private Const LVA_DEFAULT As Long = &H0
Private Const LVA_ALIGNLEFT As Long = &H1
Private Const LVA_ALIGNTOP As Long = &H2
Private Const LVA_SNAPTOGRID As Long = &H5

Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA"
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)
As Long
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As
Long, ByVal lpEnumFunc As Long, lParam As Long) As Long
Private Declare Function SendMessageLong Lib "user32.dll" Alias
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As
Long, ByVal lParam As Long) As Long

Private sClassName As String
Private HCur As Long

 Public Sub ArrangeFolderView(ByVal hIE As Long)
   Dim hLV As Long
   Dim LRet As Long
    hLV = GetListViewWindow(hIE)
      If hLV = 0 Then Exit Sub
    LRet = SendMessageLong(hLV, LVM_ARRANGE, LVA_ALIGNLEFT, 0)
 End Sub

'-- return handle for ListView window in folder. H1 is IE hWnd.
 Private Function GetListViewWindow(ByVal H1 As Long) As Long
   Dim LRet As Long
    HCur = 0
    GetListViewWindow = 0
    sClassName = "SysListView" 'SysListView32
    LRet = EnumChildWindows(H1, AddressOf EnumChildProc, 0)
      GetListViewWindow = HCur  '-- either 0 or handle of listview window.
 End Function

  '-- callback for function above.
Private Function EnumChildProc(ByVal hwnd As Long, lParam As Long) As Long
   Dim s2 As String
     s2 = GetWinClass(hwnd)
    If InStr(1, s2, sClassName, 1) > 0 Then
      HCur = hwnd
      EnumChildProc = 0
    Else
      EnumChildProc = 1
    End If
End Function

  '-- get the class name for a window, given the hWnd.
Private Function GetWinClass(ByVal H1 As Long) As String
  Dim sBuf As String
  Dim LRet As Long
     On Error Resume Next
       GetWinClass = ""
    sBuf = String$(256, 0)
    LRet = GetClassName(H1, sBuf, Len(sBuf))
     If (LRet > 0) Then GetWinClass = Left$(sBuf, LRet)
End Function
date: Wed, 13 Feb 2008 00:18:47 -0500   author:   mayayana

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us