Announcement

Collapse
No announcement yet.

Capture Gridviev/Listview text

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

  • Capture Gridviev/Listview text

    Hi guys,

    I have a proggie with a list or a gridview that has adress-data in it, the only way i can get the data out atm is bye Snagit, (amazing proggie).

    So for me the prob is solved, BUT there are a lot of customers of this proggie, that have the same problem, and the compagny is gone!
    (no export and the data is encrypted until it is loaded in the grid or list view)

    So i wonder is this done before in PB, a textbox OK but a grid or a listview I could not find something to get me going?


    Thanks in advance
    To Ask or Not To Ask ?

  • #2
    You 'can' do it "if" the data are retained as the text of a control. But you'll have to figure that out, probably by enumerating all the child windows of the application and getting the text.

    There are examples here of using Enum[Child]Windows; in your callback procedure you'll have to get the window class, and based on that class use the correct WinAPI functions to get the text for that child control. If the child controls are standard windows' controls AND the program author is NOT 'owner-drawing' everything, you should be able to do this.

    If the author is owner-drawing everything, it's probably not do-able... e.g, I have an application where the data are proprietary and were a hell of a lot of work to create, so I owner-draw everything specifically to defeat attempts to extract it.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      FWIW, if these data are permanently stored on disk, it might be a lot easier to try to extract it from the data file(s).
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Adrian,

        I see your problem, extracting data from
        an encrypted file is not really an option.

        If you can get text via Snagit then I guess
        it's not owner-drawn so probably a look at the following will help a little...

        ListView spy
        Treeview spy
        Add text to a Listview

        Have a great day...
        Last edited by Pierre Bellisle; 29 Apr 2008, 10:07 AM.

        Comment


        • #5
          Hehe thanks Pierre and Michael ,

          And some folks read to FAST

          He MM now I Know that it is a subclassed gridview and still Snagit get's the goodies out, so maybe give it a try on your ownerdraw one.

          Still I wonder how they do it, there must be some way to know what type a control is when enummerating without knowing the name.


          Any clue someone?
          To Ask or Not To Ask ?

          Comment


          • #6
            Hey Adrian,

            In case you are not aware of it, you may download Microsoft Spy++
            from the net and see what your application is made of.

            You may also experiment with EnumWindows and EnumChildWindows

            If you tried "ListView spy" then where did it failed ?

            Comment


            • #7
              I did Pierre,

              It does not fail, only then for the Ucase

              But the prob is you have to know the name off the class.

              Not all listview are called SysListView32 and so my question was is there some kind of control ID , so

              If found a child then
              if type is listview then
              do stuff...
              ??
              end if
              end if
              To Ask or Not To Ask ?

              Comment


              • #8
                Hi Adrian,

                Probably, before going deeper in code experimentation,
                the easiest way to find the class is to use Microsoft Spy++

                What class do you get on your control if you do so ?

                [Added]
                Good news, I did some test on ownerdrawn listview with <ListView spy>
                and had no problem reading data from it
                Last edited by Pierre Bellisle; 30 Apr 2008, 04:13 PM.

                Comment


                • #9
                  Yep that goes Pierre i did some to on ownerdraw, but still have the prob that I first have to tell the listview-spy the name of the class!!
                  So what i want is a proggie that just takes a dialog header and then find the listview(s) under that dialog, and that wont work becuase of funny names used when the have subclassed a listview.

                  So how can we discover in code that mylv133 is actually a listview?
                  To Ask or Not To Ask ?

                  Comment


                  • #10
                    So how can we discover in code that mylv133 is actually a listview?
                    You can't.

                    FWIW, that's also a useful way to defeat attempts to extract data... you just superclass a standard control and then don't do anything in the window procedure except call the base window class' procedure.

                    The would-be extracter can't tell that, say "mylv1333" is actually a superclassed "Syslistview32"

                    But it could be worse: it could be a sub-classed "syslistview32" which uses the subclass procedure to change the standard behavior of a "syslistview32". Now that would be really devious, huh?

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

                    Comment


                    • #11
                      >Good news, I did some test on ownerdrawn listview with <ListView spy>...

                      That's because the author carelessly (foolishly?) forgot to 'eat' the WM_NOTIFY/LVN_GETDISPINFO notification.

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

                      Comment


                      • #12
                        Just one more thing... with listviews, "Owner-Draw" is more or less automatic.. you don't need to use any special style when creating the control, you just have to intercept the WM_NOTIFY/NM_CUSTOMDRAW notification and either tell it to "do the default action" or "do something yourself."

                        This is demo'd here: Listview with Multiple Checkbox Columns Demo 2-20-05

                        Some columns are drawn manually, but some for some columns Windows is allowed to perform the default action. And in any event, even for the owner-drawn columns (the checkboxes), the control stores text for the items. (I store "Y" or "N" for the checkbox columns so I know if I should draw the check box in a checked or unchecked state).

                        Contrast this with using the LVS_OWNERDATA style... when this is used, the control stores essentially nothing, and Windows asks for display info via the WM_NOTIFY/LVN_GETDISPINFO message whenever a row or column needs to be repainted. In this case you are responsible for storing all the info necessary to effect a redraw when required, such storage being outside the control. Yes, in this case you can tell Windows to do the default drawing on NM_CUSTOMDRAW, but when you do that windows says, "Ok, fine, I'll draw it.. but you will have to give me the icon handle and the text when I send you WM_NOTIFY/LVN_GETDISPINFO"

                        i.e., handling "systlistview32" controls is not quite as simple as using a text control.. all that power comes at the cost of more programming.


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

                        Comment


                        • #13
                          Hi MM,

                          Still I wonder how Snagit does it , it managed to get data out of a listview with a funny name "datv123lst" so somehow they manage to do a enum and find out what a control is bye code!!

                          Nah, when more time I will try if you can try setting's that if TRUE tell you what kind off control your code is looking at. I think thats the way they do it.
                          To Ask or Not To Ask ?

                          Comment


                          • #14
                            Well, "Snagit" is currently on my personal to-do list (buy, install, test).

                            I thought Snagit just did screen captures with annotations and draw circles around pieces of screen captures..., which is all I want it for.

                            I never thought it could return "control text" to, say, .. where? the clipboard? An edit control?
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              MM,

                              This tool is super, there is a thread somewhere on this forum about it.

                              I use it for ... years, is a must have tool, will get anything, well almost I guess

                              For example getting text from a listview, select capture text and dont forget to set the autoscroll on, then simple point at the box and YES a txt file as result, how they do it ?? somehow they get what a control is about in their enum no matter what it is called, not sure if it can capture all , but the one I needed was a funny name and a superclassed one at least winspy told me that.

                              Good Luck,

                              You will like it , can do a lot more then only capture.
                              To Ask or Not To Ask ?

                              Comment


                              • #16
                                Originally posted by Michael Mattias View Post
                                Just one more thing... with listviews, "Owner-Draw" is more or less automatic.. you don't need to use any special style when creating the control, you just have to intercept the WM_NOTIFY/NM_CUSTOMDRAW notification and either tell it to "do the default action" or "do something yourself."

                                This is demo'd here: Listview with Multiple Checkbox Columns Demo 2-20-05

                                MCM
                                If I understood you correctly, using WM_NOTYFY/NM_CUSTROMDRAW as described should prevent another program (e.g. Listview Spy) from reading the listview data.

                                I tried your demo and could extract the data right away.

                                Code:
                                hDlgSource = B07AA
                                hListview = E074C
                                lvCount = 12
                                hThread = BFC
                                pid = D08
                                hProcess = C4
                                pListviewItem = B00000
                                pzItem = B10000
                                pHdItem = B20000
                                lvColumnCount =  9
                                
                                
                                Name    Height    Weight    Hair Color    Eye Color    Cycle    Trk/Lt    Trk/Hvy    Boat    
                                
                                
                                Smith, John    5-10    145    BLD    BLUE    Y    N    N    N    
                                
                                Jones, Mary    5-2    121    BRN    BRN    N    Y    Y    N    
                                
                                Kane, Horatio    6-0    175    BLD    BLUE    Y    N    N    Y    
                                
                                O'Neal, Shaquille    7-1    325    SHAVED    BRN    Y    Y    N    N    
                                
                                Gordon, Flash    6-1    210    BLD    BLUE    N    Y    N    N    
                                
                                Kent, Clark    6-2    225    BLK    GRN    Y    Y    Y    Y    
                                
                                Lane, Lois    5-5    134    BLK    BRN    N    Y    Y    Y    
                                
                                Olson, Jimmy    5-8    155    RED    GRN    N    Y    Y    N    
                                
                                Wayne, Bruce    6-1    195    BLD    BLUE    Y    N    Y    Y    
                                
                                Parker, Peter    5-10    168    BLK    GRN    Y    N    N    N    
                                
                                Cartwright, Hoss    6-2    307    BLD    BLUE    N    Y    N    N    
                                
                                Banner, Dr. David    5-11    180    BRN    BRN    N    Y    N    Y
                                Francisco J Castanedo
                                Software Developer
                                Distribuidora 3HP, C.A.
                                [URL]http://www.distribuidora3hp.com[/URL]

                                Comment


                                • #17
                                  If I understood you correctly, using WM_NOTYFY/NM_CUSTROMDRAW as described should prevent another program (e.g. Listview Spy) from reading the listview data
                                  I hope I did not leave that impression, because that alone is insufficient.

                                  The control has to also 'eat' WM_NOTIFY/LVN_GETDISPINFO, which I think is only sent when the control is either style LVS_OWNERDATA or the lvitem.pszText is set to LPSTR_TEXTCALLBACK.

                                  Effectively the ONLY way to do it is to ensure that Windows - or another process - is never given the text when it asks...which means you must refuse to supply the text on WM_NOTIFY/LVN_GETDISPINFO .. which further means you will have to draw each item yourself on WM_NOTIFY/NM_CUSTOMDRAW, since Windows does not have what it needs to do that drawing.
                                  Michael Mattias
                                  Tal Systems (retired)
                                  Port Washington WI USA
                                  [email protected]
                                  http://www.talsystems.com

                                  Comment


                                  • #18
                                    I have an application that uses WM_NOTIFY/LVN_GETDISPINFO, WM_NOTIFY/NM_CUSTOMDRAW and is an LVS_OWNERDATA Listview.

                                    The Listview Spy reads it right "out of the box" (I mean after copying and pasting the code into de PB editor).

                                    I´m going to encrypt the data before it is placed in the listview so I will know (more or less) how the hacking routines work.
                                    Francisco J Castanedo
                                    Software Developer
                                    Distribuidora 3HP, C.A.
                                    [URL]http://www.distribuidora3hp.com[/URL]

                                    Comment


                                    • #19
                                      > have an application that uses WM_NOTIFY/LVN_GETDISPINFO

                                      Are you eating this notification? Code not shown. (Just return a null string). (Or maybe cooler: "NO HACKING PLEASE")

                                      I have no idea how this listview spy app works, other than it sending a LVM_GETITEM to the control, requesting text. If this is a virtual or LPSTR_CALLBACK item, WM_NOTIFY/LVN_GETDISPINFO is generated to ask control for that text.

                                      If LVN_GETDISPINFO returns nothing, the requester gets nothing.
                                      Michael Mattias
                                      Tal Systems (retired)
                                      Port Washington WI USA
                                      [email protected]
                                      http://www.talsystems.com

                                      Comment


                                      • #20
                                        I encrypted the data but Listview Spy reads it directly from the listview already unencrypted.

                                        I put a decrypt routine in the %WM_NOTIFY/%LVN_GETDISPINFO in order to hand the data readable for the listview. So I infer that listview Spy commands and extracts the data directly from the control, and the control puts the data inside itself using the routines provided by the original program. Very sneaky!.


                                        Here is the relevant code in the callback that handles the listview data:
                                        (without the decrypt thingy)

                                        Code:
                                            LOCAL  pNMLV              AS NM_LISTVIEW PTR
                                            LOCAL  pLVDI              AS LV_DISPINFO PTR
                                            LOCAL  lpLVCD             AS NMLVCUSTOMDRAW PTR
                                            LOCAL  szName             AS ASCIIZ * 256
                                            LOCAL  KeyDown            AS LV_KEYDOWN PTR
                                        
                                        '   pGuia$() is a global string arrary that contains the listview data. All fields within each element (record) are sparate by the "ÏÏÏ" string
                                        
                                                  CASE %WM_NOTIFY
                                        
                                        
                                                       ' The WM_NOTIFY message informs the parent window of a control that an event has
                                                       ' occurred in the control or that the control requires some kind of information.
                                        
                                                       ' Handle ListView notifications only
                                        
                                        
                                                       IF LOWRD(CBWPARAM) <> %IDC_VLV_PARTIDAS THEN EXIT SELECT
                                        
                                        
                                                            ' Obtain the NM_LISTVIEW pointer from CBLPARAM
                                                            pNMLV = CBLPARAM
                                        
                                                            ' Obtain the LV_KEYDOWN pointer from CBLPARAM
                                                            KeyDown = CBLPARAM
                                        
                                                            SELECT CASE @pNMLV.hdr.code
                                        
                                        
                                                                   CASE %NM_CUSTOMDRAW
                                                                        IF SelectFunc.MostrarLineasguia& = 0 THEN
                                                                             lpLVCD = CBLPARAM
                                                                             IF(@lpLVCD.nmcd.dwDrawStage = %CDDS_PREPAINT) THEN
                                                                                 FUNCTION = %CDRF_NOTIFYITEMDRAW
                                                                                 EXIT FUNCTION
                                                                             END IF
                                                                             IF(@lpLVCD.nmcd.dwDrawStage =  %CDDS_ITEMPREPAINT)  THEN
                                                                                 IF (@lpLVCD.nmcd.dwItemSpec MOD 2) = 0 THEN
                                                                                 ' Linea Guia
                                                                                  @lpLVCD.clrTextBk = RGB(225,225,225)        'Item Text Background Color
                                                                                 END IF
                                        
                                                                                 FUNCTION = %CDRF_NEWFONT                        'Return CDRF_NOTIFYSUBITEMREDRAW
                                                                                                                                 'to customize the item's subitems individually then
                                                                                                                                 'case CDDS_SUBITEM | CDDS_ITEMPREPAINT
                                                                                 EXIT FUNCTION
                                                                             END IF
                                                                        END IF
                                        
                                        
                                                                    CASE %LVN_GETDISPINFO
                                        
                                        
                                                                         ' Obtain the LV_DISPINFO pointer from CBLPARAM
                                                                         pLVDI = CBLPARAM
                                        
                                                                         'virtual ListView asks for Item text
                                                                         IF (@pLVDI.item.mask AND %LVIF_TEXT) THEN
                                        
                                                                                 ' Recalcular Precio Unitario
                                                                                 IF @pLVDI.item.iSubItem = 7 AND TRIM$(PARSE$(pGuia$(@pLVDI.item.iItem), "ÏÏÏ", @pLVDI.item.iSubItem)) = "0,00" THEN
                                                                                      PrecioUnitarioLV (@pLVDI.item.iItem)  ' External SUB that calculates a value
                                                                                 END IF
                                        
                                                                                 ' Recalcular Precio Unitario si ha habido exclusion/sustitucion de insumo
                                                                                 IF @pLVDI.item.iSubItem = 7 AND CambioInsumo = 1 THEN
                                        
                                                                                      PrecioUnitarioLV (@pLVDI.item.iItem)  ' External SUB that calculates a value
                                                                                 END IF
                                        
                                                                                 szName = PARSE$(pGuia$(@pLVDI.item.iItem), "ÏÏÏ", @pLVDI.item.iSubItem)
                                                                                 @pLVDI.item.pszText = VARPTR(szName)
                                        
                                                                         END IF
                                        
                                        
                                                                         ' Here we notify the listview that this item has a state image
                                                                         IF (@pLVDI.item.mask AND %LVIF_IMAGE) THEN
                                        
                                                                              ' in order for the listview to show the state images
                                                                              ' the mask and statemask must be set to the following
                                                                              ' parameters
                                        
                                                                              @pLVDI.item.mask =%LVIF_STATE OR %LVIF_TEXT
                                                                              @pLVDI.item.statemask =%LVIS_STATEIMAGEMASK
                                                                         END IF
                                        
                                                                         'virtual ListView asks for Item state image
                                                                         IF (@pLVDI.item.mask AND %LVIF_STATE) THEN
                                        
                                                                              SELECT CASE VAL(PARSE$ (pGuia$(@pLVDI.item.iItem), "ÏÏÏ", lColCount))
                                                                                   CASE 0
                                                                                        @pLVDI.item.state = INDEXTOSTATEIMAGEMASK(1)
                                                                                   CASE 1
                                                                                        @pLVDI.item.state = INDEXTOSTATEIMAGEMASK(2)
                                                                              END SELECT
                                        
                                                                         END IF
                                        
                                        
                                                            END SELECT
                                        Francisco J Castanedo
                                        Software Developer
                                        Distribuidora 3HP, C.A.
                                        [URL]http://www.distribuidora3hp.com[/URL]

                                        Comment

                                        Working...
                                        X