want to read text from ListView control with class style LVS_OWNERDATA

 

hi dear friends.

i have deals with MT5 open positions list that is implemented as ListView control with class style LVS_OWNERDATA.

i enjected into MT5 own DLL and try to read text for <item,subutem> but failed, need help or advice...

here is my DLL part of code:

        NMLVCACHEHINT k_NMLVCACHEHINT;
        memset(&k_NMLVCACHEHINT,0,sizeof(k_NMLVCACHEHINT));
        k_NMLVCACHEHINT.hdr.hwndFrom = h_SysListView32;
        k_NMLVCACHEHINT.hdr.idFrom   = GetDlgCtrlID(h_SysListView32);
        k_NMLVCACHEHINT.hdr.code     = LVN_ODCACHEHINT;
        k_NMLVCACHEHINT.iFrom     = 0;
        k_NMLVCACHEHINT.iTo       = 3;
        SendMessage(GetParent(h_SysListView32),WM_NOTIFY,(WPARAM)k_NMLVCACHEHINT.hdr.idFrom,(LPARAM)&k_NMLVCACHEHINT);


        TCHAR  t_LVtext[200];
        memset(t_LVtext,0,sizeof(t_LVtext));
        int    i_LVtextMax = 200;

        NMLVDISPINFO k_NMLVDISPINFO;
        memset(&k_NMLVDISPINFO,0,sizeof(k_NMLVDISPINFO));
        wcscpy(t_LVtext,TEXT("Initialcontent ")); 

        k_NMLVDISPINFO.hdr.hwndFrom = h_SysListView32;
        k_NMLVDISPINFO.hdr.idFrom   = GetDlgCtrlID(h_SysListView32);
        k_NMLVDISPINFO.hdr.code     = LVN_GETDISPINFO;

        k_NMLVDISPINFO.item.mask       = LVIF_TEXT;
        k_NMLVDISPINFO.item.state      = 0;
        k_NMLVDISPINFO.item.stateMask  = 0;
        k_NMLVDISPINFO.item.pszText    = (LPTSTR)t_LVtext;
        k_NMLVDISPINFO.item.cchTextMax = i_LVtextMax;

        k_NMLVDISPINFO.item.iItem    = 1;
        k_NMLVDISPINFO.item.iSubItem = 3;

        ListView_SetItemState(h_SysListView32, -1, 0, LVIS_SELECTED); // deselect all items
        SendMessage(h_SysListView32,LVM_ENSUREVISIBLE,(WPARAM)k_NMLVDISPINFO.item.iItem,FALSE); // if item is far, scroll to it
        ListView_SetItemState(h_SysListView32,k_NMLVDISPINFO.item.iItem,LVIS_SELECTED,LVIS_SELECTED); // select item
        ListView_SetItemState(h_SysListView32,k_NMLVDISPINFO.item.iItem,LVIS_FOCUSED,LVIS_FOCUSED); // optional

        wcscpy(pt_Result,TEXT("<iItem,iSubItem> = ")); 
        SendMessage(GetParent(h_SysListView32),WM_NOTIFY,(WPARAM)k_NMLVDISPINFO.hdr.idFrom,(LPARAM)&k_NMLVDISPINFO);
        wcscat(pt_Result,t_LVtext); 
        SendMessage(GetParent(h_SysListView32),WM_NOTIFY,(WPARAM)LVN_GETDISPINFO,(LPARAM)&k_NMLVDISPINFO);
        wcscat(pt_Result,t_LVtext); 
 
Denis Sartakov :

hi dear friends.

i have deals with MT5 open positions list that is implemented as ListView control with class style LVS_OWNERDATA.

i enjected into MT5 own DLL and try to read text for <item, subutem> but failed, need help or advice ...

here is my DLL part of code:

You need to see if this listview control uses the lvs_ownerdrawfixed style. If you use this style, you don't need to implement the corresponding function of lvn_getdispinfo in the program. MT4 does this. When you send the lvm_getitemtext message, the system It sends the lvn_getdispinfo notification to the control to get the content (text and picture) of a column and field in a row in the list, so your code above can't get the text content at all. Of course, there are other methods to get it, but that way It is complicated, it is better to use EA script to obtain the order data directly

At the same time, give you an exe file, this file, your code above can not get the contents of the list

Files: