roox_3000
سه شنبه 31 اردیبهشت 1392, 14:02 عصر
با سلام
دوستان من هندل یک List View رو در یک برنامه دیگه میگیرم و با این کد آیتم شو را میگیرم و میخوام اونارو در یک List view در برنامه خودم قرار دهم
private const int LVM_FIRST = 0x1000;
private const int LVM_GETITEMCOUNT = LVM_FIRST + 4;
private const int LVM_GETITEM = LVM_FIRST + 75;
private const int LVIF_TEXT = 0x0001;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,IntPtr lParam);
[StructLayoutAttribute(LayoutKind.Sequential)]
private struct LVITEM
{
public uint mask;
public int iItem;
public int iSubItem;
public uint state;
public uint stateMask;
public IntPtr pszText;
public int cchTextMax;
public int iImage;
public IntPtr lParam;
}
و در قسمت رویداد باتن :
LVITEM lvi = new LVITEM();
lvi.mask = LVIF_TEXT;
lvi.cchTextMax = 512;
lvi.iItem = 1; // the zero-based index of the ListView item
lvi.iSubItem = 0; // the one-based index of the subitem, or 0 if this
// structure refers to an item rather than a subitem
lvi.pszText = Marshal.AllocHGlobal(512);
// Send the LVM_GETITEM message to fill the LVITEM structure
IntPtr ptrLvi = Marshal.AllocHGlobal(Marshal.SizeOf(lvi));
Marshal.StructureToPtr(lvi, ptrLvi, false);
SendMessage(hListView, LVM_GETITEM, IntPtr.Zero, ptrLvi);
// Extract the text of the specified item
string itemText = Marshal.PtrToStringAuto(lvi.pszText);
اما در قسمت آخر که Item بصورت string دریافت میشه هیچ Item رو از برنامه نمیگیره !!!
در این مورد راهنمایی میخواستم
با تشکر
دوستان من هندل یک List View رو در یک برنامه دیگه میگیرم و با این کد آیتم شو را میگیرم و میخوام اونارو در یک List view در برنامه خودم قرار دهم
private const int LVM_FIRST = 0x1000;
private const int LVM_GETITEMCOUNT = LVM_FIRST + 4;
private const int LVM_GETITEM = LVM_FIRST + 75;
private const int LVIF_TEXT = 0x0001;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam,IntPtr lParam);
[StructLayoutAttribute(LayoutKind.Sequential)]
private struct LVITEM
{
public uint mask;
public int iItem;
public int iSubItem;
public uint state;
public uint stateMask;
public IntPtr pszText;
public int cchTextMax;
public int iImage;
public IntPtr lParam;
}
و در قسمت رویداد باتن :
LVITEM lvi = new LVITEM();
lvi.mask = LVIF_TEXT;
lvi.cchTextMax = 512;
lvi.iItem = 1; // the zero-based index of the ListView item
lvi.iSubItem = 0; // the one-based index of the subitem, or 0 if this
// structure refers to an item rather than a subitem
lvi.pszText = Marshal.AllocHGlobal(512);
// Send the LVM_GETITEM message to fill the LVITEM structure
IntPtr ptrLvi = Marshal.AllocHGlobal(Marshal.SizeOf(lvi));
Marshal.StructureToPtr(lvi, ptrLvi, false);
SendMessage(hListView, LVM_GETITEM, IntPtr.Zero, ptrLvi);
// Extract the text of the specified item
string itemText = Marshal.PtrToStringAuto(lvi.pszText);
اما در قسمت آخر که Item بصورت string دریافت میشه هیچ Item رو از برنامه نمیگیره !!!
در این مورد راهنمایی میخواستم
با تشکر