Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. get text of SysListView32(LVS_OWNERDATA+LVS_OWNERDRAWFIXED) items from other applications

get text of SysListView32(LVS_OWNERDATA+LVS_OWNERDRAWFIXED) items from other applications

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionwpfhelp
5 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ilqar Sadiqov
    wrote on last edited by
    #1

    Hello. I apologize in advance if I created the topic in the wrong place, because I think that my task is directly or indirectly related to WinApi. I will describe the task: I am programming an imitation of manual work in applications for working on financial markets (Metatrader 4 and 5). I use AutoIt for this. I need to read the text of the SysListView32 items .I wrote the following code for this purpose .

    #include #include #include Local $pid= ; here i write id of needed process
    Local $hwnd= ; here i write handle of SysListView32
    Local $maxtext= ;here i write max number of chars
    Local $hprocess=_WinAPI_OpenProcess($PROCESS_ALL_ACCESS,False,$pid)
    Local $plv=_MemVirtualAllocEx($hprocess,Null,$maxtext+60,$MEM_COMMIT,$PAGE_READWRITE)
    Local $rectext=DllStructCreate("char ["&$maxtext&"]")
    Local $lv=DllStructCreate($tagLVITEM)
    $lv.Mask=$LVIF_TEXT
    $lv.Item=0
    $lv.SubItem=0
    $lv.Text=$plv+60
    $lv.TextMax=$maxtext
    _WinAPI_WriteProcessMemory($hprocess,$plv,DllStructGetPtr($lv),60,Null)
    _SendMessageA($hwnd,$LVM_GETITEMA,0,$plv)
    _WinAPI_ReadProcessMemory($hprocess,$lv.Text,DllStructGetPtr($rectext),$maxtext,Null)
    _MemVirtualFreeEx($hprocess,$plv,0,$MEM_RELEASE)
    ConsoleWrite(DllStructGetData($rectext,1))

    The problem is that the above code only gets text of items if the SysListView32 has either LVS_OWNERDATA or LVS_OWNERDRAWFIXED style. I have checked above code on different applications with SysListView32 that only had style LVS_OWNERDATA and checked above code on different applications with SysListView32 that only had style LVS_OWNERDRAWFIXED. In both cases i was able to get text from SysListView32 items. But above code is not getting text of SysListView32 items with combined LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles . The SysListView32 of Metatrader application have combined styles LVS_OWNERDATA+LVS_OWNERDRAWFIXED. Well here's the question: How to get item text from SysListView32 from another application with both LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles at the same time? I would like to get some direction of action or example code (doesn't matter on AutoIt). Thank you.

    L 1 Reply Last reply
    0
    • I Ilqar Sadiqov

      Hello. I apologize in advance if I created the topic in the wrong place, because I think that my task is directly or indirectly related to WinApi. I will describe the task: I am programming an imitation of manual work in applications for working on financial markets (Metatrader 4 and 5). I use AutoIt for this. I need to read the text of the SysListView32 items .I wrote the following code for this purpose .

      #include #include #include Local $pid= ; here i write id of needed process
      Local $hwnd= ; here i write handle of SysListView32
      Local $maxtext= ;here i write max number of chars
      Local $hprocess=_WinAPI_OpenProcess($PROCESS_ALL_ACCESS,False,$pid)
      Local $plv=_MemVirtualAllocEx($hprocess,Null,$maxtext+60,$MEM_COMMIT,$PAGE_READWRITE)
      Local $rectext=DllStructCreate("char ["&$maxtext&"]")
      Local $lv=DllStructCreate($tagLVITEM)
      $lv.Mask=$LVIF_TEXT
      $lv.Item=0
      $lv.SubItem=0
      $lv.Text=$plv+60
      $lv.TextMax=$maxtext
      _WinAPI_WriteProcessMemory($hprocess,$plv,DllStructGetPtr($lv),60,Null)
      _SendMessageA($hwnd,$LVM_GETITEMA,0,$plv)
      _WinAPI_ReadProcessMemory($hprocess,$lv.Text,DllStructGetPtr($rectext),$maxtext,Null)
      _MemVirtualFreeEx($hprocess,$plv,0,$MEM_RELEASE)
      ConsoleWrite(DllStructGetData($rectext,1))

      The problem is that the above code only gets text of items if the SysListView32 has either LVS_OWNERDATA or LVS_OWNERDRAWFIXED style. I have checked above code on different applications with SysListView32 that only had style LVS_OWNERDATA and checked above code on different applications with SysListView32 that only had style LVS_OWNERDRAWFIXED. In both cases i was able to get text from SysListView32 items. But above code is not getting text of SysListView32 items with combined LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles . The SysListView32 of Metatrader application have combined styles LVS_OWNERDATA+LVS_OWNERDRAWFIXED. Well here's the question: How to get item text from SysListView32 from another application with both LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles at the same time? I would like to get some direction of action or example code (doesn't matter on AutoIt). Thank you.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I am not sure that you can get the information. When a view has one of the OWNERDRAW settings it does not have a backing list of items. As the view tries to display its contents it sends a message to the parent Window which tells the application to return the text for each item. So it is the application that holds the actual data, not the ListView.

      I 1 Reply Last reply
      0
      • L Lost User

        I am not sure that you can get the information. When a view has one of the OWNERDRAW settings it does not have a backing list of items. As the view tries to display its contents it sends a message to the parent Window which tells the application to return the text for each item. So it is the application that holds the actual data, not the ListView.

        I Offline
        I Offline
        Ilqar Sadiqov
        wrote on last edited by
        #3

        And how i can get actual ListView's data from application ?

        L D 2 Replies Last reply
        0
        • I Ilqar Sadiqov

          And how i can get actual ListView's data from application ?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          The only person who could answer that question is the one who owns the application. For future reference see also About List-View Controls - Win32 apps | Microsoft Learn[^].

          1 Reply Last reply
          0
          • I Ilqar Sadiqov

            And how i can get actual ListView's data from application ?

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            There is no standard way of doing that. The data backing the owner-draw can be stored any way the application needs. It can be, literally, stored anywhere, in any format, with no public API to get at it. Think of how you store data in your own applications. Do you expose that data in standardized ways across all of your applications? Do you expose that data in a public API? Of course not!

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
            Dave Kreskowiak

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups