Announcement

Collapse
No announcement yet.

TREEVIEW SET CHECK problem

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

  • Ari Savola
    replied
    Yes, if you mean this kind of code:
    Code:
     
          FOR i = 1 TO 10
            TREEVIEW INSERT ITEM CB.HNDL,%IDC_TV, 0, %TVI_LAST, 0, 0, "List " & FORMAT$(i) TO hTV1
            IF i=4 THEN
              #DEBUG PRINT "-- i=4: should be checked here"
              TREEVIEW SET CHECK CB.HNDL, %IDC_TV, hTV1, 1
              TREEVIEW SET BOLD CB.HNDL, %IDC_TV, hTV1, 1
              hTV1_line4 = hTV1
            END IF
          NEXT
          TREEVIEW SET CHECK CB.HNDL, %IDC_TV, hTV1_line4, 0
    Check no4 will not go off.

    I also noticed that I had to remove %TVS_HASLINES to make the full row select functional for the treeview. Maybe PB help should have that mentioned too (as it is printed in MSDN for the %TVS_FULLROWSELECT: "This style cannot be used in conjunction with the %TVS_HASLINES style")

    Another problem for me is that clicking at checkbox will not generate %WM_NOTIFY as clicking at other part of the line will. But these are still in study process.

    cheers.. aSa

    Leave a comment:


  • Cliff Nichols
    replied
    There is still a problem though, cause if you change
    Code:
    TREEVIEW SET CHECK CB.HNDL, %IDC_TV, hTV1, 1
    to
    Code:
    TREEVIEW SET CHECK CB.HNDL, %IDC_TV, hTV1, 0
    Item 4 is not Unchecked

    Leave a comment:


  • Ari Savola
    replied
    Thank You MCM and Cliff. I'm pleased to see good examples with your suggestions. Excellent.

    For the test program MCM's suggestions seems the help, thank you. I would have never been able to figure it out.

    I'll see how it will work in my real target. But here's the resulting/working sample:

    Code:
     
    #COMPILE EXE
    #DIM ALL
     
    #INCLUDE "WIN32API.INC"
     
    %IDD_dlgDIALOG1 =  101
    %IDC_TV         = 1001
     
    FUNCTION PBMAIN()
      ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
     
    CALLBACK FUNCTION ShowDIALOG1Proc()
      LOCAL i, hTV1, hCtrl AS LONG
     
      SELECT CASE AS LONG CB.MSG
     
        CASE %WM_INITDIALOG
          CONTROL HANDLE  CB.HNDL, %IDC_TV TO hCtrl                 'MCM get handle
          SetWindowLong hCtrl, %GWL_STYLE, _                        'MCM
               GetWindowLong(hCtrl, %GWL_STYLE) OR %TVS_CHECKBOXES  'MCM add checkbox style
          TREEVIEW RESET CB.HNDL,%IDC_TV
          FOR i = 1 TO 10
            TREEVIEW INSERT ITEM CB.HNDL,%IDC_TV, 0, %TVI_LAST, 0, 0, "List " & FORMAT$(i) TO hTV1
            IF i=4 THEN
              #DEBUG PRINT "-- i=4: should be checked here"
              TREEVIEW SET CHECK CB.HNDL, %IDC_TV, hTV1, 1
              TREEVIEW SET BOLD CB.HNDL, %IDC_TV, hTV1, 1
            END IF
          NEXT
     
        CASE %WM_NCACTIVATE
          STATIC hWndSaveFocus AS DWORD
          IF ISFALSE CB.WPARAM THEN
            ' Save control focus
            hWndSaveFocus = GetFocus()
          ELSEIF hWndSaveFocus THEN
            ' Restore control focus
            SetFocus(hWndSaveFocus)
            hWndSaveFocus = 0
          END IF
     
        CASE %WM_COMMAND
          ' Process control notifications
          SELECT CASE AS LONG CB.CTL
            CASE %IDC_TV
          END SELECT
     
      END SELECT
    END FUNCTION
     
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
      LOCAL lRslt AS LONG
      LOCAL hDlg  AS DWORD
     
      DIALOG NEW hParent, "Dialog1", 70, 70, 151, 158, %WS_POPUP OR %WS_BORDER OR _
        %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR _
        %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
        %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR, TO hDlg
      CONTROL ADD TREEVIEW, hDlg, %IDC_TV, "TreeViewControl_1", 15, 15, _
        115, 120, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
        %TVS_HASLINES OR %TVS_DISABLEDRAGDROP OR %TVS_SHOWSELALWAYS OR _
        %TVS_NOTOOLTIPS OR %TVS_FULLROWSELECT, _
        %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR                                       ' removed %TVS_CHECKBOXES
     
      DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
     
      FUNCTION = lRslt
     
    END FUNCTION
    cheers.. aSa C[_]

    Leave a comment:


  • Cliff Nichols
    replied
    Already tried the Redraw, and moving the check to a different area MCM

    But I think I found it, the problem most likely lays with (from the Docs)

    TREEVIEW INSERT ITEM hDlg, id&, hPrnt, hIAftr, image&, selimage&, txt$ TO hItem


    in which the comment of


    If an IMAGELIST has been attached, the parameters image& and selimage& specify which image should be displayed (1=first, 2=second, etc.)
    Keyword IF

    Which I found no reference to a Imagelist being assigned (although found it funny that a box shows up if one has not been assigned???)

    Maybe there are some "Default" images that show but from the post Ari made, I bet the problem lays with display and not actual value....aka: No Display checkbox because no Imagelist to display it as checked

    Leave a comment:


  • Michael Mattias
    replied
    I should have RTFM.

    This is from Windows SDK, not from PB help...
    TVS_CHECKBOXES
    .....

    If you want to use this style, you must set the TVS_CHECKBOXES style with SetWindowLong after you create the treeview control, and before you populate the tree. Otherwise, the checkboxes might appear unchecked, depending on timing issues.
    There is also a warning about Common Controls level installed but it only applies with version 4.70, which I think was what came with the original Windows/98. But you can read all about it anyway in yoiur personal favorite reference.

    I think in this case the SDK doc does count because CONTROL ADD TREEVIEW in help says...
    Purpose
    Add a TreeView control to a dialog.
    ...
    .. which I think I would interpret as "a standard Microsoft Common Controls 'systreeview32' control", there being nothing to the contrary on that help file page.

    IF that is the case on WM_INITDIALOG first thing you want to do is:
    Code:
     
      CASE   %WM_INITDIALOG
        CONTROL HANDLE  CNHNDL, %ID_TV TO hCtrl   ' get handle
        SetWindowLong _  
              hCtrl, _ 
              %GWL_STYLE, _
             GetWindowLong(hCtrl, %GWL_STYLE) OR %TVS_CHECKBOXES '   add checkbox style
    MCM

    Leave a comment:


  • Michael Mattias
    replied
    Try forcing a redraw after it's been checked

    If checking on WM_INITDIALOG, try posting a user message to redraw, eg
    Code:
    %PWM_REDRAW =   %WM_USER 
    
       CASE %WM_INITDIALOG
           stuff
           DIALOG POST CBHNDL, %PWM_REDRAW, %NULL, %NULL 
           (end WM_INITDIALOG processing)
       CASE %PWM_REDRAW
           DIALOG REDRAW  CBHNDL 
    
    ...
    Maybe it needs this forced redraw.. after all, WM_INITDIALOG is processed BEFORE the dialog is ever shown.

    Worth a shot.

    MCM

    Leave a comment:


  • Cliff Nichols
    replied
    OOooops....Here is how I know it is checked
    Code:
    #COMPILE EXE
    #DIM ALL
    #TOOLS ON
    #INCLUDE "WIN32API.INC"
    
    %IDD_dlgDIALOG1 =  101
    %IDC_TV         = 1001
    
    FUNCTION PBMAIN()
      ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    
    CALLBACK FUNCTION ShowDIALOG1Proc()
      LOCAL i AS LONG
      STATIC hTV1 AS LONG
    
      SELECT CASE AS LONG CB.MSG
    
        CASE %WM_INITDIALOG
          TREEVIEW RESET CB.HNDL,%IDC_TV
          FOR i = 1 TO 10
            TREEVIEW INSERT ITEM CB.HNDL,%IDC_TV, 0, %TVI_LAST, 0, 0, "List " & FORMAT$(i) TO hTV1
    'msgbox str$(hTv1)
            IF i=4 THEN
              #DEBUG PRINT "-- i=4: should be checked here"
              TREEVIEW SET CHECK CB.HNDL, %IDC_TV, hTV1, 1
              TREEVIEW SET BOLD CB.HNDL, %IDC_TV, hTV1, 1
    LOCAL CheckVal AS LONG
    TREEVIEW GET CHECK CB.HNDL, %IDC_TV, hTV1 TO CheckVal
    MSGBOX STR$(CheckVal)
            END IF
          NEXT
    CONTROL REDRAW CB.HNDL, %IDC_TV
    
        CASE %WM_NCACTIVATE
          STATIC hWndSaveFocus AS DWORD
          IF ISFALSE CB.WPARAM THEN
            ' Save control focus
            hWndSaveFocus = GetFocus()
          ELSEIF hWndSaveFocus THEN
            ' Restore control focus
            SetFocus(hWndSaveFocus)
            hWndSaveFocus = 0
          END IF
    
        CASE %WM_COMMAND
          ' Process control notifications
          SELECT CASE AS LONG CB.CTL
            'CASE %IDC_TV
          END SELECT
    
      END SELECT
    END FUNCTION
    
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
      LOCAL lRslt AS LONG
      LOCAL hDlg  AS DWORD
    
      DIALOG NEW hParent, "Dialog1", 70, 70, 151, 158, %WS_POPUP OR %WS_BORDER OR _
        %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR _
        %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
        %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR, TO hDlg
      CONTROL ADD TREEVIEW, hDlg, %IDC_TV, "TreeViewControl_1", 15, 15, _
        115, 120, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
        %TVS_HASLINES OR %TVS_DISABLEDRAGDROP OR %TVS_SHOWSELALWAYS OR _
        %TVS_NOTOOLTIPS OR %TVS_CHECKBOXES OR %TVS_FULLROWSELECT, _
        %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR
    
    'local i as long
    'local hTV1 as long
    '      FOR i = 1 TO 10
    '        TREEVIEW INSERT ITEM hDlg,%IDC_TV, 0, %TVI_LAST, 0, 0, "List " & FORMAT$(i) TO hTV1
    '        IF i=4 THEN
    '          #DEBUG PRINT "-- i=4: should be checked here"
    '          TREEVIEW SET CHECK hDlg, %IDC_TV, hTV1, 1
    '          TREEVIEW SET BOLD hDlg, %IDC_TV, hTV1, 1
    'LOCAL CheckVal AS LONG
    'TREEVIEW GET CHECK hDlg, %IDC_TV, 0 TO CheckVal
    'MSGBOX STR$(CheckVal)
    '        END IF
    '      NEXT
      DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
      FUNCTION = lRslt
    
    END FUNCTION

    Leave a comment:


  • Cliff Nichols
    replied
    I have found that the item is checked, but does not show as it being checked.

    Any documentation as to what images are used? (As I read it, the image is either before or after, but not what the image is???? so I assume the only image is a square?????)

    This is my 1st experience with PB9 Treeview, but there is plenty of code prior 9 that does the same.

    May not yet be a bug, but more a misunderstanding how the new TreeView works????

    Leave a comment:


  • Ari Savola
    started a topic TREEVIEW SET CHECK problem

    TREEVIEW SET CHECK problem

    This time my problem is that this "TREEVIEW SET CHECK" isn't working for me. Please let me know if you can pinpoint something that shouldn't be there. Otherwise I'll file a bug report..

    Example:
    Code:
    #COMPILE EXE
    #DIM ALL
     
    #INCLUDE "WIN32API.INC"
     
    %IDD_dlgDIALOG1 =  101
    %IDC_TV         = 1001
     
    FUNCTION PBMAIN()
      ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
     
    CALLBACK FUNCTION ShowDIALOG1Proc()
      LOCAL i, hTV1 AS LONG
     
      SELECT CASE AS LONG CB.MSG
     
        CASE %WM_INITDIALOG
          TREEVIEW RESET CB.HNDL,%IDC_TV
          FOR i = 1 TO 10
            TREEVIEW INSERT ITEM CB.HNDL,%IDC_TV, 0, %TVI_LAST, 0, 0, "List " & FORMAT$(i) TO hTV1
            IF i=4 THEN
              #DEBUG PRINT "-- i=4: should be checked here"
              TREEVIEW SET CHECK CB.HNDL, %IDC_TV, hTV1, 1
              TREEVIEW SET BOLD CB.HNDL, %IDC_TV, hTV1, 1
            END IF
          NEXT
     
        CASE %WM_NCACTIVATE
          STATIC hWndSaveFocus AS DWORD
          IF ISFALSE CB.WPARAM THEN
            ' Save control focus
            hWndSaveFocus = GetFocus()
          ELSEIF hWndSaveFocus THEN
            ' Restore control focus
            SetFocus(hWndSaveFocus)
            hWndSaveFocus = 0
          END IF
     
        CASE %WM_COMMAND
          ' Process control notifications
          SELECT CASE AS LONG CB.CTL
            'CASE %IDC_TV
          END SELECT
     
      END SELECT
    END FUNCTION
     
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
      LOCAL lRslt AS LONG
      LOCAL hDlg  AS DWORD
     
      DIALOG NEW hParent, "Dialog1", 70, 70, 151, 158, %WS_POPUP OR %WS_BORDER OR _
        %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR _
        %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR _
        %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR, TO hDlg
      CONTROL ADD TREEVIEW, hDlg, %IDC_TV, "TreeViewControl_1", 15, 15, _
        115, 120, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
        %TVS_HASLINES OR %TVS_DISABLEDRAGDROP OR %TVS_SHOWSELALWAYS OR _
        %TVS_NOTOOLTIPS OR %TVS_CHECKBOXES OR %TVS_FULLROWSELECT, _
        %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR
      DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
     
      FUNCTION = lRslt
     
    END FUNCTION
    cheers.. aSa C[_]
Working...
X