Announcement

Collapse
No announcement yet.

VB-style DirListbox for PB..

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

  • VB-style DirListbox for PB..

    Following code is a VB-style dir listbox that works fine. Ownerdrawn,
    so items are drawn in subclassed procedure, under %WM_DRAWITEM. One
    thing left to solve, and I can't understand how.

    It seems like I have to pass the %WM_DRAWITEM message on from parent
    dialog for it to work. Would like to make it handle all this by
    itself, without having to pass any calls on from the parent, but
    can't find a way of doing it.

    If you test the following code, all looks fine (I hope). Uncomment
    the code under %WM_DRAWITEM in main dialog callback, DlgProc, and
    nothing is drawn in the listbox. Feels like there should be an easy
    solution to this, to make the control handle all this by itself,
    but no matter how I try, I can't solve it. I'm probably stupid.. (probably?)
    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Directory listbox - by Borje Hagsten, January 2001.
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' VB style Dir listbox sample..  :-)
    '
    ' Public Domain, feel free to use and customize as you like.
    ' Code is commented, should be easy to follow. GDI stuff seems safe,
    ' no leaks. Still, as always, use at own "risk".. :-)
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Declares
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
     
    %ID_BTN1 = 10
    %ID_DIR1 = 130
     
    GLOBAL oldLBproc AS LONG 'for subclassing, to hold original window procedure address
     
    DECLARE CALLBACK FUNCTION DlgProc
    DECLARE FUNCTION LBproc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                           BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
    DECLARE SUB DirsToList(BYVAL hWnd AS LONG, BYVAL AbsPath AS STRING)
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Entrance - Create dialog and controls
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PBMAIN
      LOCAL hDlg AS LONG, hDirList AS LONG
     
      DIALOG NEW 0, "Dir List sample", , , 120, 120, %WS_SYSMENU TO hDlg
     
      CONTROL ADD BUTTON,  hDlg, %ID_BTN1, "&Close", 30, 85, 60, 14
      CONTROL ADD LISTBOX, hDlg, %ID_DIR1, , 4, 4, 108, 80, _
                  %WS_CHILD OR %LBS_OWNERDRAWFIXED OR %LBS_HASSTRINGS OR _
                  %WS_TABSTOP OR %LBS_DISABLENOSCROLL OR %WS_VSCROLL, %WS_EX_CLIENTEDGE
     
      CONTROL HANDLE hDlg, %ID_DIR1 TO hDirList        'Subclass Dirlistbox
      oldLBproc = SetWindowLong(hDirList, %GWL_WNDPROC, CODEPTR(LBproc))
     
      CALL DirsToList(hDirList, CURDIR$) 'initialize to whatever path, like CURDIR$
     
      DIALOG SHOW MODAL hDlg, CALL DlgProc
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Main dialog callback
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgProc
      SELECT CASE CBMSG
         CASE %WM_COMMAND
            SELECT CASE CBCTL
               CASE %ID_BTN1 : DIALOG END CBHNDL       'Exit
               CASE %ID_DIR1
            END SELECT
     
         CASE %WM_DESTROY 'Un-subclass listbox
            SetWindowLong GetDlgItem(CBHNDL, %ID_DIR1), %GWL_WNDPROC, oldLBproc
     
         CASE %WM_DRAWITEM 'Must pass this on to subclassed control, wonder why..?
            IF CBWPARAM = %ID_DIR1 THEN
               SendMessage GetDlgItem(CBHNDL, %ID_DIR1), CBMSG, CBWPARAM, CBLPARAM
               FUNCTION = 0: EXIT FUNCTION
            END IF
     
      END SELECT
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Subclassed DirListbox procedure
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION LBproc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                           BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
      SELECT CASE wMsg
         CASE %WM_GETDLGCODE   'make sure we get all keys
            FUNCTION = %DLGC_WANTALLKEYS : EXIT FUNCTION
            
         CASE %WM_KEYDOWN      'respond to keyboard input
            SELECT CASE wParam
               CASE %VK_RETURN 'Enter key
                  CALL DirsToList(hWnd, "")
                  FUNCTION = 0 : EXIT FUNCTION
                  
               CASE %VK_TAB    'must handle Tab ourselves, since we have taken full controll..
                  IF HIWRD(GetKeyState(%VK_SHIFT)) = 0 THEN
                     SetFocus GetNextDlgTabItem(GetParent(hWnd), hWnd, 0)  'Move focus to next control
                  ELSE                                                     'If Shift is pressed -
                     SetFocus GetNextDlgTabItem(GetParent(hWnd), hWnd, -1) 'Move focus to previous control
                  END IF
                  FUNCTION = 0 : EXIT FUNCTION
     
            END SELECT
            
         CASE %WM_LBUTTONDBLCLK 'respond to double-click
            CALL DirsToList(hWnd, "")
            FUNCTION = 0 : EXIT FUNCTION
     
         CASE %WM_DRAWITEM      'Ownerdrawn = owner draws all items self (programmer = owner)
            LOCAL lpdis  AS DRAWITEMSTRUCT PTR
            lpdis = lParam
            IF @lpdis.itemID = -1 THEN EXIT FUNCTION 'empty list, take a break..
     
            SELECT CASE @lpdis.itemAction
               CASE %ODA_DRAWENTIRE, %ODA_SELECT
                  LOCAL lpshfi AS SHFILEINFO, tm AS TEXTMETRIC, zTxt AS ASCIIZ * %MAX_PATH, rct AS RECT
                  LOCAL hBrush AS LONG, hBrushOld AS LONG, img AS LONG, it AS LONG, xPos AS LONG, y AS LONG
     
                  'CLEAR BACKGROUND
                  hBrush = CreateSolidBrush(GetSysColor(%COLOR_WINDOW)) 'Create a background brush
                  hBrushOld = SelectObject(@lpdis.hDC, hBrush)      'Select brush into device context
                  CALL FillRect(@lpdis.hDC, @lpdis.rcItem, hBrush)  'Paint background color rectangle
                  CALL SelectObject(@lpdis.hDC, hBrushOld)          'Select old brush back
                  CALL DeleteObject(hBrush)                         'Delete brush
     
                  'GET SELECTED TEXT AND CALCULATE X POSITION
                  CALL SendMessage(hWnd, %LB_GETTEXT, @lpdis.itemID, VARPTR(zTxt)) 'Get selected text
                  it = SendMessage(hWnd, %LB_GETITEMDATA, @lpdis.itemID, 0)
                  xPos = (TALLY(zTxt, "\") + it - 1) * 3 ' * 3 decides x pos between opened folders
     
                  'GET SMALL ASSOCIATED ICON AND TEXT TO DISPLAY
                  IF it <> 1 THEN
                     img = SHGetFileInfo(zTxt, 0, lpshfi, LEN(lpshfi), %SHGFI_DISPLAYNAME OR %SHGFI_ICON OR %SHGFI_SMALLICON)
                  ELSE
                     img = SHGetFileInfo(zTxt, 0, lpshfi, LEN(lpshfi), %SHGFI_DISPLAYNAME OR %SHGFI_ICON OR %SHGFI_SMALLICON OR %SHGFI_OPENICON)
                  END IF
     
                  'ADJUST ITEM HEIGHT TO FONT SIZE
                  CALL GetTextMetrics(@lpdis.hDC, tm)                                'get font size
                  y = (@lpdis.rcItem.nBottom + @lpdis.rcItem.nTop - tm.tmHeight) / 2 'Center text ypos
                  IF SendMessage(hWnd, %CB_GETITEMHEIGHT, @lpdis.itemID, 0) < tm.tmHeight + 2 THEN
                     CALL SendMessage(hWnd, %CB_SETITEMHEIGHT, @lpdis.itemID, tm.tmHeight + 2) 'adjust item height
                  END IF
     
                  'DRAW TEXT
                  CALL SetBkColor(@lpdis.hDC, GetSysColor(%COLOR_WINDOW))         'Set text Background
                  CALL SetTextColor(@lpdis.hDC, GetSysColor(%COLOR_WINDOWTEXT))   'Set text color
                  IF @lpdis.itemID = 0 THEN lpshfi.szDisplayName = UCASE$(zTxt)   'First item, drive, UCASE
                  CALL TextOut(@lpdis.hDC, xPos + 22, y, lpshfi.szDisplayName, LEN(lpshfi.szDisplayName)) 'Draw text
     
                  'SELECTED ITEM
                  IF (@lpdis.itemState AND %ODS_SELECTED) THEN      'if selected
                     CALL InvertRect(@lpdis.hDC, @lpdis.rcItem)     'invert area around text only
                  END IF
     
                  'DRAW ASSOCIATED ICON
                  DrawIconEx @lpdis.hDC, xPos + 3, @lpdis.rcItem.ntop, _
                             lpshfi.hIcon, 16, 15, 0, BYVAL %NULL, %DI_NORMAL
                  FUNCTION = %TRUE : EXIT FUNCTION
     
               CASE %ODA_FOCUS
                  CALL DrawFocusRect(@lpdis.hDC, @lpdis.rcItem) 'draw focus rectangle
     
            END SELECT
      END SELECT
      FUNCTION = CallWindowProc(oldLBproc, hWnd, wMsg, wParam, lParam) 'pass all other messages on to orig. proc.
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Populate DirListbox with available directories
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    SUB DirsToList(BYVAL hWnd AS LONG, BYVAL AbsPath AS STRING)
      LOCAL hSearch AS LONG, fRes AS LONG, Path AS STRING, s AS STRING, arr() AS STRING, dc AS LONG
      LOCAL WFD AS WIN32_FIND_DATA, I AS LONG, J AS LONG
     
      IF LEN(AbsPath) = 0 THEN 'if nothing has been passed, look for selected item
         I  = SendMessage(hWnd, %LB_GETCURSEL, 0, 0)
         J  = SendMessage(hWnd, %LB_GETTEXTLEN, I, 0)
         AbsPath = SPACE$(J)
         I  = SendMessage(hWnd, %LB_GETTEXT, I, BYVAL STRPTR(AbsPath))
      END IF
     
      IF LEN(AbsPath) = 0 THEN EXIT SUB 'if something bad has happened
     
      IF RIGHT$(AbsPath, 1) <> "\" THEN AbsPath = AbsPath & "\" 'make sure we have a trailing backslash
      Path = AbsPath            'store for later use
      AbsPath = AbsPath + "*"   'for finding all subsequent folders
     
      
      FOR I = 1 TO PARSECOUNT(Path, "\") - 1 'Parse current path and add opened folders to array
         s = s + PARSE$(Path, "\", I)
         IF LEN(s) THEN
            REDIM PRESERVE arr(dc)
            IF RIGHT$(s, 1) <> "\" THEN s = s & "\"
            arr(dc) = s
            INCR dc
         END IF
      NEXT I
      J = dc - 1
     
      hSearch = FindFirstFile(BYVAL STRPTR(AbsPath), WFD) 'Find all following non-opened sub-folders
      IF hSearch <> %INVALID_HANDLE_VALUE THEN
         CALL SendMessage(hWnd, %CB_RESETCONTENT, 0, 0)
         fRes = %TRUE
         DO WHILE fRes
            IF ASC(WFD.cFileName) <> 46 THEN      'No . or ..
               IF (WFD.dwFileAttributes AND 16) = 16 THEN 'dirs only..
                  AbsPath = TRIM$(WFD.cFileName, CHR$(0))
                  REDIM PRESERVE arr(dc)
                  arr(dc) = Path + AbsPath
                  INCR dc
                END IF
            END IF
            fRes = FindNextFile(hSearch, WFD) ' Get next
         LOOP
         fRes = FindClose(hSearch)
      END IF
     
      ARRAY SORT arr(J), COLLATE UCASE 'sort non-opened folders only
     
      CALL SendMessage(hWnd, %LB_RESETCONTENT, 0, 0) 'clear list
      FOR I = 0 TO UBOUND(arr)
         CALL SendMessage(hWnd, %LB_ADDSTRING, 0, BYVAL STRPTR(arr(I))) 'add to list
         IF I = 0 THEN  'Set item data for chosing type of *** . icon
            CALL SendMessage(hWnd, %LB_SETITEMDATA, I, 0) 'Drive
         ELSEIF I = < J THEN
            CALL SendMessage(hWnd, %LB_SETITEMDATA, I, 1) 'opened folder
         ELSE
            CALL SendMessage(hWnd, %LB_SETITEMDATA, I, 2) 'closed folder
         END IF
      NEXT
      CALL SendMessage(hWnd, %LB_SELECTSTRING, -1, BYVAL STRPTR(Path)) 'select current
      
      'Note - here is good place to fill a file listbox.
      'Can use same FindFirstFile loop as above, but use
      '"IF (WFD.dwFileAttributes AND 16) <> 16" instead,
      'to get file names for an ordinary listbox, whatever.
     
    END SUB

    ------------------

  • #2
    borje;

    don't be so hard on yourself! your'e by no means stupid. if anybody is
    stupid it's probably me.

    your'e just misinformed. the wm_drawitem message is sent to the owner window
    of an owner-drawn list box when a visual aspect of the list box has changed. all
    the painting action should take place in your parents procedure not in the listboxes
    subclass procedure. also you should add the %lbs_notify style to your listbox control.
    (in ddt, probably doesn't matter)

    i just posted an sdk sytle owner-draw example last week you can use
    as an example.

    http://www.powerbasic.com/support/pb...ad.php?t=22892

    hth
    regards,
    jules

    your solution...

    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' main dialog callback
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    callback function dlgproc
      select case cbmsg
         case %wm_command
            select case cbctl
               case %id_btn1 : dialog end cbhndl       'exit
               case %id_dir1
            end select
     
         case %wm_destroy 'un-subclass listbox
            setwindowlong getdlgitem(cbhndl, %id_dir1), %gwl_wndproc, oldlbproc
         
         case %wm_drawitem      'ownerdrawn = owner draws all items self (programmer = owner)
            if cbwparam = %id_dir1 then
            local lpdis  as drawitemstruct ptr
            lpdis = cblparam
            if @lpdis.itemid = -1 then exit function 'empty list, take a break..
     
            select case @lpdis.itemaction
               case %oda_drawentire, %oda_select
                  local lpshfi as shfileinfo, tm as textmetric, ztxt as asciiz * %max_path, rct as rect
                  local hbrush as long, hbrushold as long, img as long, it as long, xpos as long, y as long
     
                  'clear background
                  hbrush = createsolidbrush(getsyscolor(%color_window)) 'create a background brush
                  hbrushold = selectobject(@lpdis.hdc, hbrush)      'select brush into device context
                  call fillrect(@lpdis.hdc, @lpdis.rcitem, hbrush)  'paint background color rectangle
                  call selectobject(@lpdis.hdc, hbrushold)          'select old brush back
                  call deleteobject(hbrush)                         'delete brush
     
                  'get selected text and calculate x position
                  call sendmessage(ghlist, %lb_gettext, @lpdis.itemid, varptr(ztxt)) 'get selected text
                  it = sendmessage(ghlist, %lb_getitemdata, @lpdis.itemid, 0)
                  xpos = (tally(ztxt, "\") + it - 1) * 3 ' * 3 decides x pos between opened folders
     
                  'get small associated icon and text to display
                  if it <> 1 then
                     img = shgetfileinfo(ztxt, 0, lpshfi, len(lpshfi), %shgfi_displayname or %shgfi_icon or %shgfi_smallicon)
                  else
                     img = shgetfileinfo(ztxt, 0, lpshfi, len(lpshfi), %shgfi_displayname or %shgfi_icon or %shgfi_smallicon or %shgfi_openicon)
                  end if
     
                  'adjust item height to font size
                  call gettextmetrics(@lpdis.hdc, tm)                                'get font size
                  y = (@lpdis.rcitem.nbottom + @lpdis.rcitem.ntop - tm.tmheight) / 2 'center text ypos
                  if sendmessage(ghlist, %cb_getitemheight, @lpdis.itemid, 0) < tm.tmheight + 2 then
                     call sendmessage(ghlist, %cb_setitemheight, @lpdis.itemid, tm.tmheight + 2) 'adjust item height
                  end if
     
                  'draw text
                  call setbkcolor(@lpdis.hdc, getsyscolor(%color_window))         'set text background
                  call settextcolor(@lpdis.hdc, getsyscolor(%color_windowtext))   'set text color
                  if @lpdis.itemid = 0 then lpshfi.szdisplayname = ucase$(ztxt)   'first item, drive, ucase
                  call textout(@lpdis.hdc, xpos + 22, y, lpshfi.szdisplayname, len(lpshfi.szdisplayname)) 'draw text
     
                  'selected item
                  if (@lpdis.itemstate and %ods_selected) then      'if selected
                     call invertrect(@lpdis.hdc, @lpdis.rcitem)     'invert area around text only
                  end if
     
                  'draw associated icon
                  drawiconex @lpdis.hdc, xpos + 3, @lpdis.rcitem.ntop, _
                             lpshfi.hicon, 16, 15, 0, byval %null, %di_normal
                  function = %true : exit function
     
               case %oda_focus
                  call drawfocusrect(@lpdis.hdc, @lpdis.rcitem) 'draw focus rectangle
                  function=%true :exit function
     
            end select
            
               function = 0: exit function
                
            end if
     
      end select
    end function
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' subclassed dirlistbox procedure
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    function lbproc(byval hwnd as long, byval wmsg as long, _
                           byval wparam as long, byval lparam as long) as long
       
      ghlist = hwnd
       
      select case wmsg
         case %wm_getdlgcode   'make sure we get all keys
            function = %dlgc_wantallkeys : exit function
     
         case %wm_keydown      'respond to keyboard input
            select case wparam
               case %vk_return 'enter key
                  call dirstolist(hwnd, ")
                  function = 0 : exit function
     
               case %vk_tab    'must handle tab ourselves, since we have taken full controll..
                  if hiwrd(getkeystate(%vk_shift)) = 0 then
                     setfocus getnextdlgtabitem(getparent(hwnd), hwnd, 0)  'move focus to next control
                  else                                                     'if shift is pressed -
                     setfocus getnextdlgtabitem(getparent(hwnd), hwnd, -1) 'move focus to previous control
                  end if
                  function = 0 : exit function
     
            end select
     
         case %wm_lbuttondblclk 'respond to double-click
            call dirstolist(hwnd, ")
            function = 0 : exit function
     
      end select
      function = callwindowproc(oldlbproc, hwnd, wmsg, wparam, lparam) 'pass all other messages on to orig. proc.
    end function

    [this message has been edited by jules marchildon (edited january 28, 2001).]
    Best regards
    Jules
    www.rpmarchildon.com

    Comment


    • #3
      Yes Jules, I saw your sample, really nice piece of code. Thanks a
      lot for that one - excellent work. The reason for subclassing was I
      wanted to try to make it totally independent of parent. Like a custom
      control, but as include file for easy embedding into PB code.

      You are right about WM_DRAWITEM, so it seems I have to take another
      approach and paint the control in WM_PAINT instead, like I have done
      with the virtual list. No problem for listbox, but a bit trickier
      for Drive combo. I'll keep hacking for a good solution.


      ------------------

      Comment


      • #4
        Borje;

        If you want it self contained as a custom control (as an inlcude file),
        then use a child container to parent the ownerdraw listbox. This way
        your parent needs not respond to the WM_DRAWITEM.

        So when creating the control, you create the child "container" and it
        does all the magic for you.

        I think I did these awhile back for an OwnerDraw ListBox demo called Vtabs?
        A vertical tab control.

        Regards,
        Jules

        Best regards
        Jules
        www.rpmarchildon.com

        Comment


        • #5
          Yes Jules, that seems to be the way to do it. Thanks a lot for the
          tip. Toyed around a bit with it and even a simple DIALOG NEW with
          %WS_POPUP style, shown modeless with it's own callback does the trick,
          when I place the control in it. SDK style, one can probably use a
          Static control as container, but DDT seems to need modeless dialog.

          Busy week ahead, but I'll wrap it up as soon as I can. Quite useful
          to be able to include some "Visual" style Drive, Dir and File lists,
          embedded into program with just one line of code..


          ------------------

          Comment


          • #6
            Borje --
            Edwin wrote some monthes ago explorer-style dir listbox (custom control).
            You can find a code on his web site. It's much better - you can select network and so on.

            ------------------
            E-MAIL: [email protected]

            Comment


            • #7
              Yes, I have looked at Edwin's samples. Very nice. Thing is, I prefer
              embedded stuff. I like one code, one exe, no dll's. Using include
              files makes it so easy to add controls when needed.

              With this last piece of the puzzle finally solved - thank you ever
              so much for that, Jules - I can now start building up a library of
              useful include files for different types of lists and comboboxes.

              As I see it, this has finally made any need for ever having to use
              VB, Delphi or Visual C++ for anything has disappeared completely.
              I have resorted to use VB or Delphi when I have had to do some visual
              interface that was too tricky to do fast in PB. No more of that now..

              What is useful controls? Drive, Dir and File lists, of course. Color
              pick controls, both list and combo. BMP or ICO lists and combos, so
              one can include images easily via simple command? Yes. Maybe even
              a grid control or good replacement for ListView. Limit seems to be
              the sky, and time to do it. Lists and combos sure are powerful controls..


              ------------------

              Comment


              • #8
                My Drive DLL also uses 1 line of code per control.
                (Control Add stuff..)

                ------------------
                [email protected]
                hellobasic

                Comment


                • #9
                  Borje --
                  I talk about BFF (BFF.INF). There is no additional DLL.

                  ------------------
                  E-MAIL: [email protected]

                  Comment


                  • #10
                    BFF is nice code, but uses ThreeView. In other words, Commctrl.dll.

                    Edwin has done great work with his DLL's and other free stuff.
                    Would use it, if I didn't have this obsession of embedding as
                    much as I can into exe in an easy way. Also have this obsession
                    of always wanting to reinvent the wheel. Result is not always a
                    better wheel, but it makes me understand how things really works
                    and also gives me chance to do things the way I think they should
                    be done.

                    This way I'm very stupid. I can work for days on writing reusable
                    code that maybe will save me 20-30 minutes next time I need it..


                    ------------------

                    Comment


                    • #11
                      I've spent the last 18+ hours trying to figure-out how to retrofit this original source to work in a non-directory application. While I have learned some interesting and new things, all of them have ended-up WAY off-topic-- Kind of like looking for your car keys, but finding a 20-dollar bill stuffed between the cushions of the couch instead; You may be 20 bucks richer, but still can't go anywhere.

                      Anyway, what I'm trying to do is read a pre-existing ASCII file (with the standard $CRLF delimiter), assign each new line to a new Listbox item, and based on what the line of text contains, assign it one of several possible bitmaps that >>already<< exist in the .pbr file (since the bitmaps would be unique to the app, I don't have the luxury of loading a 'universal' off the harddrive). The most appealing about this approach is the speed at which it operates, and since this little app could very well have several thousand list-items/icons to deal with at one time, the faster the better.

                      I've got the ascii parsing out of the way, and have managed to make a fairly-usable, editable, multi-select listbox that nearly does what it needs to do-- I just need to attach some bitmaps (no larger than your checkbox example) to the listbox items...

                      Any help would be appreciated!

                      Once I have the thing working, I'll turn-around and post the source to the list.

                      Scott Martindale
                      DNA Productions, Inc.
                      [email protected]

                      Comment


                      • #12
                        Scott;

                        For that I would prefer to use Borje's VLIST.INC virtual ListBox control.
                        With that, no text size limit, faster painting, since no WM_DRAWITEM, paint
                        directly in the WM_PAINT. It would be very easy to do. I have enjoyed
                        that code sample Borje supplied immensely!!!

                        Does this need to show a tree or just one line/image, a single branch? I
                        guess what I am asking, does it need to look like a listview in report mode?


                        Regards,
                        Jules

                        p.s. Borje! Where the Heck are you????
                        Best regards
                        Jules
                        www.rpmarchildon.com

                        Comment


                        • #13
                          Originally posted by Jules Marchildon:
                          Scott;

                          For that I would prefer to use Borje's VLIST.INC virtual ListBox control.
                          With that, no text size limit, faster painting, since no WM_DRAWITEM, paint
                          directly in the WM_PAINT. It would be very easy to do. I have enjoyed
                          that code sample Borje supplied immensely!!!

                          Does this need to show a tree or just one line/image, a single branch? I
                          guess what I am asking, does it need to look like a listview in report mode?


                          Regards,
                          Jules

                          p.s. Borje! Where the Heck are you????
                          ---------------------

                          Hi Jules,

                          If you'd like, I could email you what I have up to this point, along with an AVI showing what I'm wanting to pull-off. I think that I'm pretty close, and I'll be more than happy to share the source with anyone interested while it's in the "work in progress" stages, and WILL post the source when finished.

                          Just email me at:
                          [email protected]

                          Look forward to hearing from you!

                          Scott Martindale

                          Comment


                          • #14
                            By the way, to answer your question; a single-line is all that is necessary.

                            Sorry for the double-post-- Netscape is behaving a little bit wierd on my machine. Will revert back to "Exploder" is this persists

                            -Scott

                            [This message has been edited by Scott Martindale (edited June 26, 2001).]

                            Comment

                            Working...
                            X