Announcement

Collapse
No announcement yet.

multiline text in listview column

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

  • multiline text in listview column

    I'm aiming to show a date/time stamp in the first column and some related multiline text in the second (and last) column, with some way of selecting a row (i.e. date plus multine text) and showing that it is selected. Can't work out how to do the multiline bit though, any offers?


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


    [This message has been edited by Chris Holbrook (edited March 08, 2006).]

  • #2
    Don't try multiline. (He, said, even though that is exactly what he was just trying himself)

    Instead, do multiple rows for each "item".
    Code:
    Col 1     Col 2     Col3
      X        Y        First line of   <<, row 0
                        Three line      <<  row 1
                        text item 1    <<  row 2
      A        B        First line of   <<, row 3
                        Three line      <<  row 4
                        text item 2     <<  row 5
    That is, just leave all the column text empty when you need a second or third line.

    As I said, I have been working on this today myself, but for that application I always have EXACTLY two lines of text pre "item"

    But I think I'm going to give up on that and do the above myself.

    MCM

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

    Comment


    • #3
      Since your are doing custom draw, displaying multiline text is relatively
      straightforward. You first have to get the listview control to size the rows
      to the height you require.
      There are two ways to do this. The first method uses WM_SETFONT to size the rows. You
      would, however, use a different font to draw the text during the draw cycle. This method
      will size both the column headers and rows. If you don't want the column headers resized,
      use the next method.
      The second method uses the LVM_SETIMAGELIST(LVSIL_SMALL) to size the rows. You add an image
      of the appropriate size to an imagelist and then associate the imagelist to the listview.

      And the rest is simple. You can use DrawTextEx without DT_SINGLELINE or TextOut for complete
      control to draw the text.

      If you have trouble following this, I can post a sample.


      ------------------
      Dominic Mitchell
      Phoenix Visual Designer
      http://www.phnxthunder.com
      Dominic Mitchell
      Phoenix Visual Designer
      http://www.phnxthunder.com

      Comment


      • #4
        Dominic,

        Can you use this approach to do other drawing (besides text)? I
        saw an old source code posting that showed progress bars in the
        listview, but it would not be repainted. Would that be an issue?

        I think I understand the multiline flow you described, but if you
        have any examples already made I'd love to see one.

        Thanks either way!

        John

        ------------------
        LOCAL MyEMail AS STRING , MySkype AS STRING
        MyEmail = STRREVERSE$("letnitj") & CHR$(64) & STRREVERSE$("liamg") & CHR$(46) & STRREVERSE$("moc")
        MySkype = STRREVERSE$("adirolftj")
        LOCAL MyEMail AS STRING
        MyEmail = STRREVERSE$("53pmohtj") & CHR$(64) & STRREVERSE$("liamg") & CHR$(46) & STRREVERSE$("moc")

        Comment


        • #5
          Dominic,

          Would both of these approaches result in equal height rows in the listview? With listview, are all the rows limited to the same height?

          Please do post an example if you have one to hand.

          Thanks,

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

          Comment


          • #6
            Originally posted by Michael Mattias:

            Instead, do multiple rows for each "item".


            Michael, I did look at at an example of this in the forums (I think it was one of yours), and it would work OK if there were a small fixed number of lines to each text record, but I could have 1..dozens of lines in each one, so a scrolling control would be more appropriate, whether to do this by scrolling the whole listview, inserting a text control into the listview cell (if that is possible) or popping up a scrolling text box for the selected cell, I am undecided, it is a vector of my competence and wieldliness of the resulting UI.

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

            Comment


            • #7
              >but I could have 1..dozens of lines in each one, so a scrolling control...

              ???

              Code:
               Listview                     Read-only edit control
               Col 0   Col 1     Col2     |                       |
               A       B         C        |                       |
               X       Y         Z        |                       |
               X       Y         Z        |                       |
               X       Y         Z        |                       |
               X       Y         Z        |                       |
               X       Y         Z        |                       |
               X       Y         Z        |                       |
               X       Y         Z        |                       |
               X       Y         Z        |                       |
              Change text of Edit control (with scrollbars) as user selects different rows of listview?



              [This message has been edited by Michael Mattias (edited March 09, 2006).]
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                [quote]originally posted by michael mattias:
                [b]>
                Code:
                 listview                     read-only edit control
                 col 0   col 1     col2     |                       |
                 a       b         c        |                       |
                    |
                thanks michael,i will probably try all the alternatives until i get one that's nice to use.
                currently experiencing click sickness.

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

                Comment


                • #9
                  finally took michael mitchell's advice and did it this way instead.


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

                  Comment


                  • #10
                    Interesting approach.

                    I'm used to modifying postings for PB/WIn 7x and my header files (compiler and windows header files used not shown), but this one really had me going.

                    Once I got the displays to come up, I felt sure I had missed something because none of the displays were real sentences.

                    Then I saw your 'sentences' were deliberately formed as collections of random words.

                    You know, with that writing style you might do well in the Chicago Public Schools

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

                    Comment


                    • #11
                      >modifying postings for PB/WIn 7x and my header files

                      For the interested users of 7x and other versions of both WIN32API.INC and COMMCTRL.INC..

                      Subject post uses..
                      Code:
                       LOCAL  x, Y, Z AS LONG
                      .. which must be changed to
                      Code:
                       LOCAL  x AS LONG, Y AS LONG, Z AS LONG
                      And on the WM_NOTIFY handling, the notify codes may have LONG/DWORD mismatches and because most of the Listview (and treeview) notification codes are in the range x'8000000' to x'FFFFFFFF' (negative when cast as LONG integers), you have to change the code from
                      Code:
                       
                        SELECT CASE  @pnmh.code  (something like that anyway)
                      to
                      Code:
                       
                        SELECT CASE AS LONG @pnmh.code
                      (In 7x, SELECT CASE AS LONG does full 32-bit compares whereas SELECT CASE does signed compares).

                      MCM

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

                      Comment


                      • #12
                        Originally posted by Michael Mattias:
                        You know, with that writing style you might do well in the Chicago Public Schools

                        Perhaps that's where my English master studied, I never dared to ask...

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

                        Comment


                        • #13
                          Originally posted by Michael Mattias:
                          >modifying postings for PB/WIn 7x and my header files

                          Thanks Michael, have edited it accordingly & it still works on V8, but I can't test on V7.



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

                          Comment


                          • #14
                            Call me Chicken Little, but when I install version N, I do <U>not</U> uninstall version N-1.

                            Not anymore, anyway. Too many service packs and undocumented backward incompatibilities.

                            I finally have all of my stuff off 6x, but I had to leave that installed because I ocassionally update ddoc Print and Preview, which is written with 6.10

                            Now I have a ton of stuff in 7x and an email from yesterday warning me that my compiler is out of date! But it's hard to believe it's <U>really</U> out of date... everything I compile with it still works!

                            But I digress.. under 7x (and maybe under 8x, but I can't test that), the both the main listview area and the yellow "text highlight" screen include a bunch of 'funky' characters... looks like what you get when the strings contain 'unprintables' such as $CR or $LF.

                            Is that just me or do others notice that, too?

                            MCM


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

                            Comment


                            • #15
                              Originally posted by Michael Mattias:
                              Call me Chicken Little, but when I install version N, I do <U>not</U> uninstall version N-1.

                              never used anything but 8
                              the main listview area and the yellow "text highlight" screen include a bunch of 'funky' characters... looks like what you get when the strings contain 'unprintables' such as $CR or $LF.

                              Is that just me or do others notice that, too?
                              Invisible on my setup, (version 8 on XP), I wonder why?


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

                              Comment


                              • #16
                                Why not put the text box below or to the side?
                                You can use a splitter to adjust the view.

                                Code:
                                'will compile on PBWin 7.04
                                '
                                #PBFORMS CREATED V1.51
                                #COMPILE EXE
                                #DIM ALL
                                #PBFORMS BEGIN INCLUDES
                                #IF NOT %DEF(%WINAPI)
                                    #INCLUDE "WIN32API.INC"
                                #ENDIF
                                #IF NOT %DEF(%COMMCTRL_INC)
                                    #INCLUDE "COMMCTRL.INC"
                                #ENDIF
                                #INCLUDE "PBForms.INC"
                                #PBFORMS END INCLUDES
                                
                                #PBFORMS BEGIN CONSTANTS
                                %Dialog1     =  101
                                %lblSplitter = 1002
                                %lv1         = 1001
                                %txt1        = 1003
                                #PBFORMS END CONSTANTS
                                
                                DECLARE CALLBACK FUNCTION ShowDialog1Proc()
                                DECLARE FUNCTION SampleListView(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL lColCnt AS LONG, BYVAL lRowCnt AS LONG) AS LONG
                                DECLARE FUNCTION ShowDialog1(BYVAL hParent AS DWORD) AS LONG
                                #PBFORMS DECLARATIONS
                                
                                %LISTVIEW_TEXT_MAX = 32000
                                
                                GLOBAL ghDlg AS LONG
                                
                                DECLARE FUNCTION splitMessageConsumed( hDlg&, ID&, DlgCBMSG&, DlgCBLPARAM&, LineIsVertica&, MoveStatus&, Limit_Left_Or_Top&, Limit_Right_Or_Bttm&, ptrSubToCall& ) AS LONG
                                DECLARE FUNCTION splitMouseOnMe_InternalUse( hDlg&, ID&, pxFL&, pxFT& ) AS LONG
                                DECLARE SUB splitMouseMoveHrzLine_InternalUse( hDlg&, ID&, pxFL&, pxFT&, maxUp&, maxDown&, ptrSubToCall& )
                                DECLARE SUB splitMouseMoveVrtLine_InternalUse( hDlg&, ID&, pxFL&, pxFT&, maxLeft&, maxRight&, ptrSubToCall& )
                                DECLARE FUNCTION ddtClientH(hDlg&) AS LONG
                                DECLARE FUNCTION ddtClientW(hDlg&) AS LONG
                                '
                                DECLARE FUNCTION lv_hWnd(hDlg&, ID&) AS LONG
                                DECLARE SUB lv_StyleFullRowGrid( BYVAL hDlg&, BYVAL ID& )
                                DECLARE SUB lv_SetItemCount( hDlg&, ID&, ItemCount& )
                                DECLARE SUB lv_RowAppend( hDlg&, ID& )
                                DECLARE SUB lv_RowInsert( hDlg&, ID&, rowNo& )
                                DECLARE SUB lv_RowSelect( hDlg&, ID&, Row& )
                                DECLARE FUNCTION lv_RowSelected( hDlg&, ID& ) AS LONG
                                DECLARE SUB lv_RowDelSelected( hDlg&, ID& )
                                DECLARE SUB lv_RowDel( hDlg&, ID&, rowNo& )
                                DECLARE SUB lv_RowDelAll( hDlg&, ID& )
                                DECLARE SUB lv_RowEnsureVisible( hDlg&, ID&, rowNo& )
                                DECLARE FUNCTION lv_RowCount( hDlg&, ID& ) AS LONG
                                DECLARE FUNCTION lv_ColCount( hDlg&, ID& ) AS LONG
                                DECLARE FUNCTION lv_ColGet( hDlg&, ID&, lCol& ) AS STRING
                                DECLARE SUB lv_ColDel( hDlg&, ID&, colNo& )
                                DECLARE SUB lv_ColDelAll( hDlg&, ID& )
                                DECLARE SUB lv_ColInsert( hDlg&, ID&, colNo&, sTitle$ )
                                DECLARE SUB lv_ColWidthSet( hDlg&, ID&, colNo&, colWidth& )
                                DECLARE FUNCTION lv_ColWidthGet( hDlg&, ID&, colNo& ) AS LONG
                                DECLARE SUB lv_Zap( hDlg&, ID& )
                                DECLARE FUNCTION lv_FindItem( hDlg&, ID&, startAt&, sValue$ ) AS LONG
                                DECLARE FUNCTION lv_TextGet( hDlg&, ID&, rowNo&, colNo& ) AS STRING
                                DECLARE SUB lv_TextSet( hDlg&, ID&, Row&, Col&, Value$ )
                                DECLARE FUNCTION lv_TextGetSelected( hDlg&, ID&, Col& ) AS STRING
                                DECLARE SUB lv_TextSetSelected( hDlg&, ID&, Col&, Value$ )
                                
                                
                                FUNCTION PBMAIN()
                                    PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES)
                                    ShowDialog1 %HWND_DESKTOP
                                END FUNCTION
                                
                                
                                CALLBACK FUNCTION ShowDialog1Proc()
                                    LOCAL pNmLv AS NM_LISTVIEW PTR
                                    STATIC MoveStatus1&
                                
                                    IF splitMessageConsumed(CBHNDL, %lblSplitter, CBMSG, CBLPARAM, 0, MoveStatus1&, 0, 0, CODEPTR(Splitter1)) THEN EXIT FUNCTION
                                    SELECT CASE AS LONG CBMSG
                                        CASE %WM_INITDIALOG
                                            CALL Dislog1_WM_INITDIALOG()
                                        CASE %WM_NOTIFY
                                            SELECT CASE CBCTL
                                                CASE %lv1
                                                    pNmLv = CBLPARAM
                                                    SELECT CASE @pNmLv.hdr.code
                                                        CASE %NM_CLICK
                                                            CALL lv1_RowClicked(@pNmLv.iSubItem)
                                                        CASE %LVN_COLUMNCLICK
                                                            CALL lv1_ColClicked(@pNmLv.iSubItem)
                                                    END SELECT
                                            END SELECT
                                        CASE %WM_NCACTIVATE
                                            STATIC hWndSaveFocus AS DWORD
                                            IF ISFALSE CBWPARAM THEN
                                                hWndSaveFocus = GetFocus()
                                            ELSEIF hWndSaveFocus THEN
                                                SetFocus(hWndSaveFocus)
                                                hWndSaveFocus = 0
                                            END IF
                                        CASE %WM_COMMAND
                                            SELECT CASE AS LONG CBCTL
                                            END SELECT
                                    END SELECT
                                END FUNCTION
                                
                                SUB Dislog1_WM_INITDIALOG()
                                    LOCAL i AS LONG
                                    LOCAL j AS LONG
                                    LOCAL k AS LONG
                                    LOCAL s AS STRING
                                    lv_ColInsert ghDlg, %lv1, 0, "Number"
                                    lv_ColInsert ghDlg, %lv1, 1, "Words"
                                    lv_ColWidthSet ghDlg, %lv1, 0, 100
                                    lv_ColWidthSet ghDlg, %lv1, 1, 500
                                    'dummy text
                                    FOR i=1 TO 100
                                        s=""
                                        FOR j=1 TO 10
                                            FOR k=ASC("A") TO ASC("G")
                                                s = s + CHR$(k) + FORMAT$(RND()*10,"###")
                                            NEXT k
                                            s = s + $CRLF
                                        NEXT j
                                        lv_RowAppend ghDlg, %lv1
                                        lv_TextSet ghDlg, %lv1, i-1, 0, FORMAT$(RND()*1000,"###.###")
                                        lv_TextSet ghDlg, %lv1, i-1, 1, s
                                    NEXT i
                                END SUB
                                
                                SUB lv1_RowClicked(colNo&)
                                    LOCAL rowNo&
                                    rowNo& = lv_RowSelected(ghDlg, %lv1)
                                    CONTROL SET TEXT ghDlg, %txt1, lv_TextGet(ghDlg, %lv1, rowNo&, colNo&)
                                END SUB
                                SUB lv1_ColClicked(colNo&)
                                END SUB
                                
                                FUNCTION ShowDialog1(BYVAL hParent AS DWORD) AS LONG
                                    LOCAL lRslt AS LONG
                                
                                #PBFORMS BEGIN DIALOG %Dialog1->->
                                    LOCAL hDlg  AS DWORD
                                
                                    DIALOG NEW hParent, "ListView with Splitter and TextBox", 89, 90, 326, 163, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_CENTER 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 "SysListView32", hDlg, %lv1, "", 0, 0, 327, 105, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %LVS_REPORT OR %LVS_SINGLESEL OR %LVS_SHOWSELALWAYS, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_RIGHTSCROLLBAR
                                    CONTROL ADD LABEL,   hDlg, %lblSplitter, "", 0, 105, 327, 3
                                    CONTROL ADD TEXTBOX, hDlg, %txt1, "", 0, 108, 327, 54, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOVSCROLL OR %ES_NOHIDESEL OR %ES_READONLY OR %ES_WANTRETURN, %WS_EX_CLIENTEDGE OR _
                                        %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
                                #PBFORMS END DIALOG
                                    ghDlg = hDlg
                                    lv_StyleFullRowGrid hDlg, %lv1
                                    DIALOG SHOW MODAL hDlg, CALL ShowDialog1Proc TO lRslt
                                
                                #PBFORMS BEGIN CLEANUP %Dialog1
                                #PBFORMS END CLEANUP
                                
                                    FUNCTION = lRslt
                                END FUNCTION
                                
                                SUB Splitter1()
                                    LOCAL cw&, ch&
                                    LOCAL splitterTop AS LONG, splitterBttm AS LONG
                                    LOCAL  fl&, ft&, W&, H& 'from left/top, width height
                                    LOCAL rowNo&
                                
                                    DIALOG GET CLIENT ghDlg TO cw&, ch&
                                    'splitter
                                    CONTROL GET LOC ghDlg, %lblSplitter TO fl&, ft&
                                    splitterTop = ft&
                                    splitterBttm = splitterTop + 3
                                    'listview
                                    CONTROL GET LOC ghDlg, %lv1 TO fl&, ft&
                                    CONTROL GET SIZE ghDlg, %lv1 TO  W&, H&
                                    H& = splitterTop-ft&
                                    CONTROL SET SIZE ghDlg, %lv1, W&, H&
                                    CONTROL REDRAW ghDlg, %lv1
                                    'textbox
                                    CONTROL GET LOC ghDlg, %txt1 TO fl&, ft&
                                    CONTROL GET SIZE ghDlg, %txt1 TO  W&, H&
                                    ft& = splitterBttm
                                    H& = ch& - 3 - splitterBttm
                                    CONTROL SET SIZE ghDlg, %txt1, W&, H&
                                    CONTROL SET LOC ghDlg, %txt1, fl&, ft&
                                    CONTROL REDRAW ghDlg, %txt1
                                    'make sure row visible
                                    rowNo& = lv_RowSelected(ghDlg, %lv1)
                                    lv_RowEnsureVisible ghDlg, %lv1, rowNo&
                                END SUB
                                
                                ' --------------------------------------------------
                                FUNCTION splitMessageConsumed( hDlg&, ID&, DlgCBMSG&, DlgCBLPARAM&, LineIsVertica&, MoveStatus&, Limit_Left_Or_Top&, Limit_Right_Or_Bttm&, ptrSubToCall& ) AS LONG
                                    LOCAL x&, y&
                                    '
                                    ' call for each splitter
                                    '
                                    ' hDlg&                  - dialog handle
                                    ' ID&                    - control ID
                                    ' DlgCBMSG&              - CBMSG
                                    ' DlgCBLPARAM&           - CBLPARAM
                                    ' LineIsVertica&         - 1 = vertical LINE  -  0 = horizontal LINE
                                    ' MoveStatus&            - static or global long - keep track of move mode
                                    ' Limit_Left_Or_Top&     - limit left for vertical LINE  | limit top for horizontal LINE
                                    ' Limit_Right_Or_Bttm&   - limit right for vertical LINE | limit bottom for horizontal LINE
                                    ' ptrSubToCall&           - if this is set, this SUB will be called when bar moves
                                    '
                                    x& = LOWRD(DlgCBLPARAM&)
                                    y& = HIWRD(DlgCBLPARAM&)
                                
                                    IF DlgCBMSG&=%WM_LBUTTONUP AND MoveStatus& THEN
                                            ReleaseCapture()
                                            MOUSEPTR 1
                                            MoveStatus&=0
                                            FUNCTION = -1
                                    ELSEIF DlgCBMSG&=%WM_MOUSEMOVE THEN
                                        IF MoveStatus& THEN
                                            IF LineIsVertica& THEN
                                                splitMouseMoveVrtLine_InternalUse(hDlg&, ID&, x&, y&, Limit_Left_Or_Top&, Limit_Right_Or_Bttm&, ptrSubToCall&)
                                            ELSE
                                                splitMouseMoveHrzLine_InternalUse(hDlg&, ID&, x&, y&, Limit_Left_Or_Top&, Limit_Right_Or_Bttm&, ptrSubToCall&)
                                            END IF
                                            FUNCTION = -1
                                            EXIT FUNCTION
                                        ELSEIF splitMouseOnMe_InternalUse(hDlg&, ID&, x&, y&) THEN
                                            MOUSEPTR IIF&(LineIsVertica&, 9, 7)
                                        END IF
                                    ELSEIF DlgCBMSG&=%WM_LBUTTONDOWN AND splitMouseOnMe_InternalUse(hDlg&, ID&, x&, y&) THEN
                                        MOUSEPTR IIF&(LineIsVertica&, 9, 7)
                                        MoveStatus& = -1
                                        SetCapture(hDlg&)
                                        FUNCTION = -1
                                    END IF
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION splitMouseOnMe_InternalUse( hDlg&, ID&, pxFL&, pxFT& ) AS LONG
                                    LOCAL MouseFL&, MouseFT& 'DDT from left, from top
                                    LOCAL MyLft&, MyTop&, MyWdth&, MyHght&, MyRght&, MyBttm&
                                
                                    'convert mouse to DDT
                                    DIALOG PIXELS hDlg&, pxFL&, pxFT& TO UNITS MouseFL&, MouseFT&
                                
                                    'my location
                                    CONTROL GET LOC hDlg&, ID& TO MyLft&, MyTop&
                                    CONTROL GET SIZE hDlg&, ID& TO MyWdth&, MyHght&
                                    MyRght& = MyLft& + MyWdth&
                                    MyBttm& = MyTop& + MyHght&
                                
                                    IF MouseFL&>=MyLft& AND MouseFL&<=MyRght& AND MouseFT&>=MyTop& AND MouseFT&<=MyBttm THEN FUNCTION = -1
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB splitMouseMoveHrzLine_InternalUse( hDlg&, ID&, pxFL&, pxFT&, maxUp&, maxDown&, ptrSubToCall& )
                                    LOCAL MouseFL&, MouseFT&'DDT from left, from top
                                    LOCAL MyLft&, MyTop&, MyWdth&, MyHght&, MyCenter&
                                
                                    IF ISFALSE maxDown& THEN maxDown& = ddtClientH(hDlg&)-MyHght&-2
                                    IF pxFT&>30000 THEN pxFT&=0 'over top
                                
                                    'convert mouse to DDT
                                    DIALOG PIXELS hDlg&, pxFL&, pxFT& TO UNITS MouseFL&, MouseFT&
                                
                                    IF MouseFT&<maxUp& THEN MouseFT&=maxUp&
                                    IF MouseFT&>maxDown& THEN MouseFT&=maxDown&
                                    CONTROL GET LOC hDlg&, ID& TO MyLft&, MyTop&
                                    CONTROL SET LOC hDlg&, ID&, MyLft&, MouseFT&
                                    'call this SUB when bar moves
                                    IF ptrSubToCall& THEN CALL DWORD ptrSubToCall&
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB splitMouseMoveVrtLine_InternalUse( hDlg&, ID&, pxFL&, pxFT&, maxLeft&, maxRight&, ptrSubToCall& )
                                    LOCAL MouseFL&, MouseFT&'DDT from left, from top
                                    LOCAL MyLft&, MyTop&, MyWdth&, MyHght&, MyCenter&
                                
                                    IF ISFALSE maxLeft& THEN maxLeft&=2
                                    IF ISFALSE maxRight& THEN maxRight& = ddtClientW(hDlg&)-MyWdth&-2
                                    IF pxFL&>30000 THEN pxFL&=0 'pass left
                                
                                    'convert mouse to DDT
                                    DIALOG PIXELS hDlg&, pxFL&, pxFT& TO UNITS MouseFL&, MouseFT&
                                    IF MouseFL&<maxLeft& THEN MouseFL&=maxLeft&
                                    IF MouseFL&>maxRight& THEN MouseFL&=maxRight&
                                    CONTROL GET LOC hDlg&, ID& TO MyLft&, MyTop&
                                    CONTROL SET LOC hDlg&, ID&, MouseFL&, MyTop&
                                    'call this SUB when bar moves
                                    IF ptrSubToCall& THEN CALL DWORD ptrSubToCall&
                                END SUB
                                ' --------------------------------------------------
                                
                                '================
                                ' --------------------------------------------------
                                FUNCTION ddtClientH(hDlg&) AS LONG
                                    'dialog client height
                                    LOCAL wide&, high&
                                    DIALOG GET CLIENT hDlg& TO wide&, high&
                                    FUNCTION = high&
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION ddtClientW(hDlg&) AS LONG
                                    'dialog client width
                                    LOCAL wide&, high&
                                    DIALOG GET CLIENT hDlg& TO wide&, high&
                                    FUNCTION = wide&
                                END FUNCTION
                                ' --------------------------------------------------
                                '=====================
                                ' --------------------------------------------------
                                FUNCTION lv_hWnd(hDlg&, ID&) AS LONG
                                    LOCAL h&
                                    CONTROL HANDLE hDlg&,ID& TO h&
                                    FUNCTION = h&
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_StyleFullRowGrid( BYVAL hDlg&, BYVAL ID& )
                                    ListView_SetExtendedListViewStyle lv_hWnd(hDlg&,ID&), ListView_GetExtendedListViewStyle(lv_hWnd(hDlg&,ID&)) OR %LVS_EX_FULLROWSELECT OR %LVS_EX_GRIDLINES
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_SetItemCount( hDlg&, ID&, ItemCount& )
                                    ListView_SetItemCount lv_hWnd(hDlg&,ID&), ItemCount&
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_RowAppend( hDlg&, ID& )
                                    LOCAL tLVI AS LV_ITEM
                                    LOCAL szBuf AS ASCIIZ * 1
                                
                                    szBuf = ""
                                    tLVI.stateMask  = %LVIS_FOCUSED
                                    tLVI.pszText = VARPTR(szBuf)
                                    tLVI.iItem = lv_RowCount( hDlg&, ID& )
                                    tLVI.iSubItem = 0
                                
                                    tLVI.mask = %LVIF_TEXT OR %LVIF_PARAM OR %LVIF_STATE
                                    ListView_InsertItem(lv_hWnd(hDlg&,ID&), tLVI)
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_RowInsert( hDlg&, ID&, rowNo& )
                                    LOCAL tLVI AS LV_ITEM
                                    LOCAL szBuf AS ASCIIZ * 1
                                
                                    szBuf = ""
                                    tLVI.stateMask  = %LVIS_FOCUSED
                                    tLVI.pszText = VARPTR(szBuf)
                                    tLVI.iItem = rowNo&
                                    tLVI.iSubItem = 0
                                
                                    tLVI.mask = %LVIF_TEXT OR %LVIF_PARAM OR %LVIF_STATE
                                    ListView_InsertItem(lv_hWnd(hDlg&,ID&), tLVI)
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_RowSelect( hDlg&, ID&, Row& )
                                    'select Row&
                                    ListView_SetItemState lv_hWnd(hDlg&,ID&), Row&, %LVIS_SELECTED, %LVIS_SELECTED
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_RowSelected( hDlg&, ID& ) AS LONG
                                    FUNCTION = ListView_GetNextItem(lv_hWnd(hDlg&,ID&), -1, %LVNI_SELECTED)
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_RowDelSelected( hDlg&, ID& )
                                    CALL lv_RowDel( hDlg&, ID&, lv_RowSelected(hDlg&,ID&) )
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_RowDel( hDlg&, ID&, rowNo& )
                                    ListView_DeleteItem ( lv_hWnd(hDlg&,ID&), rowNo& )
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_RowDelAll( hDlg&, ID& )
                                    ListView_DeleteAllItems( lv_hWnd(hDlg&,ID&) )
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_RowEnsureVisible( hDlg&, ID&, rowNo& )
                                    ListView_EnsureVisible ( lv_hWnd(hDlg&,ID&), rowNo&, 0 )
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_RowCount( hDlg&, ID& ) AS LONG
                                    FUNCTION = ListView_GetItemCount(lv_hWnd(hDlg&,ID&))
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_ColCount( hDlg&, ID& ) AS LONG
                                    LOCAL hHead&
                                    hHead& = SendMessage(lv_hWnd(hDlg&,ID&),%LVM_GETHEADER,0,0)
                                    FUNCTION = SendMessage( hHead&, %HDM_GETITEMCOUNT, 0, 0 )
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_ColGet( hDlg&, ID&, lCol& ) AS STRING
                                    LOCAL szText AS ASCIIZ * 255
                                    LOCAL lvc AS LV_COLUMN
                                
                                    lvc.mask = %LVCF_TEXT OR %LVCF_SUBITEM
                                    lvc.pszText = VARPTR(szText)
                                    lvc.cchTextMax = SIZEOF(szText)
                                    lvc.iSubItem = lCol&
                                    SendMessage( lv_hWnd(hDlg&,ID&), %LVM_GETCOLUMN, lCol&, VARPTR(lvc) )
                                    FUNCTION = szText
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_ColDel( hDlg&, ID&, colNo& )
                                    ListView_DeleteColumn( lv_hWnd(hDlg&,ID&), colNo& )
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_ColDelAll( hDlg&, ID& )
                                    DO WHILE ListView_DeleteColumn( lv_hWnd(hDlg&,ID&), 0 )
                                    LOOP
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_ColInsert( hDlg&, ID&, colNo&, sTitle$ )
                                    LOCAL tLVC  AS LV_COLUMN
                                    LOCAL hWnd AS LONG
                                
                                    tLVC.mask    = %LVCF_FMT OR %LVCF_TEXT OR %LVCF_SUBITEM
                                    tLVC.fmt     = %LVCFMT_LEFT
                                    tLVC.pszText = STRPTR(sTitle$)
                                
                                    ListView_InsertColumn( lv_hWnd(hDlg&,ID&),  colNo&, tLVC)
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_ColWidthSet( hDlg&, ID&, colNo&, colWidth& )
                                    ListView_SetColumnWidth lv_hWnd(hDlg&,ID&), colNo&,  colWidth&
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_ColWidthGet( hDlg&, ID&, colNo& ) AS LONG
                                    FUNCTION = ListView_GetColumnWidth (lv_hWnd(hDlg&,ID&),colNo&)
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_Zap( hDlg&, ID& )
                                    lv_RowDelAll( hDlg&, ID& )
                                    lv_ColDelAll( hDlg&, ID& )
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_FindItem( hDlg&, ID&, startAt&, sValue$ ) AS LONG
                                    LOCAL x&, lvfi AS LV_FINDINFO
                                    'thanks Borje Hagsten
                                    '-1 to start from first row
                                
                                    IF LEN(sValue$) = 0 THEN EXIT FUNCTION
                                
                                    lvfi.flags = %LVFI_PARTIAL OR %LVFI_STRING
                                    lvfi.psz   = STRPTR(sValue$)
                                    FUNCTION =  ListView_FindItem(lv_hWnd(hDlg&,ID&), -1, lvfi)
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_TextGet( hDlg&, ID&, rowNo&, colNo& ) AS STRING
                                    LOCAL szBuf AS ASCIIZ * %LISTVIEW_TEXT_MAX
                                    ListView_GetItemText lv_hWnd(hDlg&,ID&), rowNo&, colNo&, szBuf, SIZEOF(szBuf)
                                    FUNCTION = szBuf
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                FUNCTION lv_TextGetSelected(  hDlg&, ID&, Col& ) AS STRING
                                    LOCAL szBuf AS ASCIIZ * %LISTVIEW_TEXT_MAX
                                    ListView_GetItemText lv_hWnd(hDlg&,ID&), lv_RowSelected(hDlg&,ID&), Col&, szBuf, SIZEOF(szBuf)
                                    FUNCTION = szBuf
                                END FUNCTION
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_TextSet( hDlg&, ID&, Row&, Col&, Value$ )
                                    LOCAL tLVI AS LV_ITEM
                                '    LOCAL szBuf AS ASCIIZ * %LISTVIEW_TEXT_MAX
                                
                                '    szBuf = Value$
                                
                                    tLVI.stateMask  = %LVIS_FOCUSED
                                    'tLVI.pszText = VARPTR(szBuf)
                                    tLVI.pszText = STRPTR(Value$)
                                    tLVI.iItem = Row&
                                    tLVI.iSubItem = Col&
                                
                                    tLVI.mask = %LVIF_TEXT
                                    ListView_SetItem(lv_hWnd(hDlg&,ID&), tLVI)
                                END SUB
                                ' --------------------------------------------------
                                ' --------------------------------------------------
                                SUB lv_TextSetSelected( hDlg&, ID&, Col&, Value$ )
                                    LOCAL tLVI AS LV_ITEM
                                '    LOCAL szBuf AS ASCIIZ * %LISTVIEW_TEXT_MAX
                                
                                    tLVI.stateMask  = %LVIS_FOCUSED
                                    'tLVI.pszText = VARPTR(szBuf)
                                    tLVI.pszText = STRPTR(Value$)
                                    tLVI.iItem = lv_RowSelected( hDlg&, ID& )
                                    tLVI.iSubItem = Col&
                                
                                '    szBuf = Value$
                                
                                    tLVI.mask = %LVIF_TEXT
                                    ListView_SetItem(lv_hWnd(hDlg&,ID&), tLVI)
                                END SUB
                                ' --------------------------------------------------

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

                                Comment


                                • #17
                                  Just wondering...
                                  Can you have a Textbox control inside a listview cell?

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

                                  Comment


                                  • #18
                                    >Can you have a Textbox control inside a listview cell?
                                    That would be the standard way of doing it but it can get tricky if you have paragraphs of text.


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

                                    Comment


                                    • #19
                                      Originally posted by Stan Durham:
                                      Why not put the text box below or to the side?
                                      You can use a splitter to adjust the view.

                                      [CODE]
                                      Thanks Stan for the nice example, now I know how to do a splitter! I had tried side by side & underneath but felt that the draggable popup was more flexible.



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

                                      Comment


                                      • #20
                                        The funky characters are only on the main listview, not in the yellow help/hilite screen.

                                        Can be removed thusly:
                                        Code:
                                        FUNCTION arcLViewCustomDraw ( BYVAL ptlvcd AS NMLVCUSTOMDRAW PTR ) AS LONG
                                        ' MCM note 3/12/06 should remove the $CRLFs (added when built) 
                                        ' when painting the listview rows
                                          .....
                                          tlv_item.cchTextMax = %MAX_PATH
                                          SendMessage @ptlvcd.nmcd.hdr.hwndFrom, %LVM_GETITEM, 0, BYVAL VARPTR(tlv_item)
                                          
                                          ' add by MCM 3/12/06 Did not change anything
                                          'szItem  =  RTRIM$(szItem, ANY $CRLF)
                                          ' Ok lets try this instead
                                          ' this works
                                          REPLACE ANY $CRLF WITH CHR$(&h20,&h20) IN szItem
                                        
                                          ' Get the bounding rectangle of the subitem(cell)
                                          trcItem.nLeft = %LVIR_BOUNDS
                                          ....
                                        (Don't know why removing $CRLF didn't work, but it didn't)

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

                                        Comment

                                        Working...
                                        X