I'm doing some project on c#.
I need to get i
item from ListView
window, handle of it I got by doing something like this
IntPtr par_hWnd = API.FindWindow(null, "Form1");
IntPtr child1 = API.FindWindowEx(par_hWnd, (IntPtr)0, null, null);
API
is my static class with lots of dllimports from "user32.dll"
I am able to get count of items in this ListView:
IntPtr count = API.SendMessage(child1, API.LVM_GETITEMCOUNT, 0, 0);
Now i need to get the text of item, but the result somehow must be placed in the LVITEM
Structure, I don't know how to call SendMessage
correctly, and how to implement LVITEM
in c#. Can't find examples for c#. Any help?
I found a C# wrapper for WinAPIs that seems to provide access to the contents of an LV from any window.
ManagedWinapi
using ManagedWinapi.Windows;
using System;
namespace TestApp
{
class Program
{
static void Main(string[] args)
{
// Create a SystemWindow object from the HWND of the ListView
SystemWindow lvWindow = new SystemWindow((IntPtr)0x6d1d38);
// Create a ListView object from the SystemWindow object
var lv = SystemListView.FromSystemWindow(lvWindow);
// Read text from a row
var text = lv[0].Title;
}
}
}
Also, I have also forked mwapi here and am trying to add some new functionality - Mainly centred around colouring ListView rows, but also adding some missing p/invokes etc.