Announcement

Collapse
No announcement yet.

DlgDirList

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DlgDirList

    Hello Gents,

    I am using DlgDirList to get Folders and drives visible within a listbox.
    Unfortunately it shows me the folders and drives always at the bottom of the listbox. I would like to have it on top.
    I tried %LBS_SORT on/off without success.

    DlgDirList(GetParent(hWndLISTBOX), szFilename, %IDC_BROWSER, 0, %DDL_DIRECTORY OR %DDL_DRIVES)

    szFilename contains full path and file name like: "C:\Tmp\*.txt"

    Could you please help?

    Thank you,
    Joerg
    Joerg Koehler

  • #2
    I never used that function, but couldn't you extract the entries from the listbox yourself, re-order them the way you want (parse strings, etc.), then put them back in another ordinary list box? Just a thought!

    Added Later:

    Code:
    #Compile Exe
    #Include "Win32api.inc"
    %IDC_LABEL    = 1249
    %IDC_LISTBOX1 = 1250
    %IDC_LISTBOX2 = 1251
    
    Function WndProc(ByVal hWnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Long) As Long
      Select Case wMsg
        Case %WM_CREATE
          Register i As Long
          Local szDir As Asciiz*128,szString As Asciiz*128
          Local hListBox1,hListBox2,hLabel,hIns,dwCount As Dword
          hIns=GetWindowLong(hWnd,%GWL_HINSTANCE)
          szDir="C:\*.*"
          hLabel=CreateWindow("static","",%WS_CHILD Or %WS_VISIBLE,10,5,300,23,hWnd,%IDC_LABEL,hIns,ByVal 0)
          hListBox1=CreateWindow("listbox","",%WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %WS_VSCROLL,10,30,250,250,hWnd,%IDC_LISTBOX1,hIns,ByVal 0)
          hListBox2=CreateWindow("listbox","",%WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %WS_VSCROLL,275,30,250,250,hWnd,%IDC_LISTBOX2,hIns,ByVal 0)
          Call DlgDirList(hWnd,szDir,%IDC_LISTBOX1,%IDC_LABEL,%DDL_DRIVES Or %DDL_DIRECTORY)
          dwCount=SendMessage(hListBox1,%LB_GETCOUNT,0,0)
          For i=1 To dwCount
            Call SendMessage(hListBox1,%LB_GETTEXT,i-1,VarPtr(szString))
            If InStr(szString,"[") Then
               Call SendMessage(hListBox2,%LB_ADDSTRING,0,VarPtr(szString))
            End If
          Next i
          WndProc=0
          Exit Function
        Case %WM_DESTROY
          Call PostQuitMessage(0)
          WndProc=0
          Exit Function
      End Select
    
      WndProc=DefWindowProc(hWnd, wMsg, wParam, lParam)
    End Function
    
    Function WinMain(ByVal hIns As Long,ByVal hPrev As Long,ByVal lpCL As Asciiz Ptr,ByVal iShow As Long) As Long
      Local winclass As WndClassEx
      Local szAppName As Asciiz * 20
      Local hMainWnd As Dword
      Local Msg As tagMsg
    
      szAppName="GetDlgDir"
      winclass.cbSize=SizeOf(winclass)
      winclass.style=%CS_HREDRAW Or %CS_VREDRAW
      winclass.lpfnWndProc=CodePtr(WndProc)
      winclass.cbClsExtra=0
      winclass.cbWndExtra=0
      winclass.hInstance=hIns
      winclass.hIcon=LoadIcon(%NULL, ByVal %IDI_APPLICATION)
      winclass.hCursor=LoadCursor(%NULL, ByVal %IDC_ARROW)
      winclass.hbrBackground=%COLOR_BTNFACE+1
      winclass.lpszMenuName=%NULL
      winclass.lpszClassName=VarPtr(szAppName)
      Call RegisterClassEx(winclass)
      hMainWnd=CreateWindow(szAppName,szAppName,%WS_OVERLAPPEDWINDOW,200,100,545,380,0,0,hIns,ByVal 0)
      Call ShowWindow(hMainWnd,iShow)
      While GetMessage(Msg,%NULL,0,0)
        TranslateMessage Msg
        DispatchMessage Msg
      Wend
    
      Function=msg.wParam
    End Function
    Also, you don't have to make the listbox on the left visible. That way, all you need to do is display one listbox the way you want it.
    Last edited by Fred Harris; 17 Oct 2007, 04:07 PM.
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

    Comment


    • #3
      even better

      This works even better. Create the listbox that will filter your desires as invisible with 0,0,0,0 for locations/sizes in CreateWindow() call. Run the call to GetDlgDir() multiple times, putting the output from the invisible list box into the one you want o display. Here is the modified version...

      Code:
      #Compile Exe
      #Include "Win32api.inc"
      %IDC_LABEL    = 1249
      %IDC_LISTBOX1 = 1250
      %IDC_LISTBOX2 = 1251
      
      Function WndProc(ByVal hWnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As Long) As Long
        Select Case wMsg
          Case %WM_CREATE
            Register i As Long
            Local szDir As Asciiz*128,szString As Asciiz*128
            Local hListBox1,hListBox2,hLabel,hIns,dwCount As Dword
            hIns=GetWindowLong(hWnd,%GWL_HINSTANCE)
            szDir="C:\*.*"
            hLabel=CreateWindow("static","",%WS_CHILD Or %WS_VISIBLE,10,5,300,23,hWnd,%IDC_LABEL,hIns,ByVal 0)
            hListBox1=CreateWindow("listbox","",%WS_CHILD,0,0,0,0,hWnd,%IDC_LISTBOX1,hIns,ByVal 0)
            hListBox2=CreateWindow("listbox","",%WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %WS_VSCROLL,10,30,250,250,hWnd,%IDC_LISTBOX2,hIns,ByVal 0)
            Call DlgDirList(hWnd,szDir,%IDC_LISTBOX1,%IDC_LABEL,%DDL_DRIVES)
            dwCount=SendMessage(hListBox1,%LB_GETCOUNT,0,0)
            For i=1 To dwCount
              Call SendMessage(hListBox1,%LB_GETTEXT,i-1,VarPtr(szString))
              Call SendMessage(hListBox2,%LB_ADDSTRING,0,VarPtr(szString))
            Next i
            Call SendMessage(hListBox1,%LB_RESETCONTENT,0,0)
            Call DlgDirList(hWnd,szDir,%IDC_LISTBOX1,%IDC_LABEL,%DDL_DIRECTORY)
            dwCount=SendMessage(hListBox1,%LB_GETCOUNT,0,0)
            For i=1 To dwCount
              Call SendMessage(hListBox1,%LB_GETTEXT,i-1,VarPtr(szString))
              If InStr(szString,"[") Then
                 Call SendMessage(hListBox2,%LB_ADDSTRING,0,VarPtr(szString))
              End If
            Next i
            WndProc=0
            Exit Function
          Case %WM_DESTROY
            Call PostQuitMessage(0)
            WndProc=0
            Exit Function
        End Select
      
        WndProc=DefWindowProc(hWnd, wMsg, wParam, lParam)
      End Function
      
      Function WinMain(ByVal hIns As Long,ByVal hPrev As Long,ByVal lpCL As Asciiz Ptr,ByVal iShow As Long) As Long
        Local winclass As WndClassEx
        Local szAppName As Asciiz * 20
        Local hMainWnd As Dword
        Local Msg As tagMsg
      
        szAppName="GetDlgDir"
        winclass.cbSize=SizeOf(winclass)
        winclass.style=%CS_HREDRAW Or %CS_VREDRAW
        winclass.lpfnWndProc=CodePtr(WndProc)
        winclass.cbClsExtra=0
        winclass.cbWndExtra=0
        winclass.hInstance=hIns
        winclass.hIcon=LoadIcon(%NULL, ByVal %IDI_APPLICATION)
        winclass.hCursor=LoadCursor(%NULL, ByVal %IDC_ARROW)
        winclass.hbrBackground=%COLOR_BTNFACE+1
        winclass.lpszMenuName=%NULL
        winclass.lpszClassName=VarPtr(szAppName)
        Call RegisterClassEx(winclass)
        hMainWnd=CreateWindow(szAppName,szAppName,%WS_OVERLAPPEDWINDOW,200,100,320,340,0,0,hIns,ByVal 0)
        Call ShowWindow(hMainWnd,iShow)
        While GetMessage(Msg,%NULL,0,0)
          TranslateMessage Msg
          DispatchMessage Msg
        Wend
      
        Function=msg.wParam
      End Function
      Fred
      "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

      Comment


      • #4
        Thank you Fred,

        I also get a tip to mimic the behave of the DlgDirList by first adding drives

        ' Add the drives
        SendDlgItemMessage hWndParent, %IDC_FORM1_LIST1, %LB_DIR, %DDL_DRIVES OR %DDL_EXCLUSIVE OR &H1000, BYVAL VARPTR(szFileName)

        then adding folders

        ' Add the folders
        SendDlgItemMessage hWndParent, %IDC_FORM1_LIST1, %LB_DIR, %DDL_DIRECTORY OR %DDL_EXCLUSIVE OR &H1000, BYVAL VARPTR(szFileName)

        and finaly the files...

        This works as it should.

        Thank you for your effort,

        Joerg
        Joerg Koehler

        Comment


        • #5
          ' Add the drives
          ...
          ...then adding folders
          ...
          .. and finaly the files...
          I like this solution. It shows imagination.

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment

          Working...
          X