问题描述
我的列表视图包含3列的名称,地址和电话号码。
My list view contains 3 columns Name, address and phone number.
我要检索特定名称的索引。
I want to retrieve an index for a particular name.
我用 ListView_FindItem
宏找到索引号,但是当我的code谈到此行崩溃的程序。
I'm using ListView_FindItem
macro to find the index number but when my code comes to this line it crashes the program.
它只是说工资已停止工作。 Windows可以在网上查了解决问题的办法。
It just says Payroll has stopped working. Windows can check online for a solution to the problem.
我敢肯定,我已经通过正确的处理对 ListView_FindItem
宏,但我不知道有关 LVFINDINFO
结构。
I'm sure I have passed right handle to the ListView_FindItem
macro but I'm not sure about the LVFINDINFO
structure.
下面是我的code
WCHAR szProcess[80] = {0};
LVFINDINFO item = {LVFI_STRING, (LPCTSTR) szProcess};
//code to find parent handles
...
//code to find index
index = ListView_FindItem(hwndListView, -1, &item);
我不知道有关 LVFI_STRING
标记,我甚至试图通过一个恒定的 LVFINDINFO
结构 ListView_FindItem
宏还是我的程序崩溃。
I'm not sure about the LVFI_STRING
flag and I have even tried passing a constant LVFINDINFO
structure to ListView_FindItem
macro still my program crashes.
注:以上code不是的一部分
工资单应用程序。我的意思是说
工资单应用程序有
ListView和我试图搜索
从其他应用程序的项目。
有人能指出我在正确的方向?
Can some one point me in a right direction ?
感谢。
推荐答案
您的描述是有点不清楚,但我间preT它,你要发送 LVM_FINDITEM
消息(通过 ListView_FindItem()
宏)在一个不同的进程的一个窗口。
Your description is a little unclear, but I interpret it that you are sending LVM_FINDITEM
message (via the ListView_FindItem()
macro) to a window in a different process.
这只是因为它传递一个指向调用进程一个结构时,除$ P $在其他进程(拥有列表视图中的工资单应用程序上下文PTED这是毫无意义的没有为这个特殊的Windows消息工作)。
This simply does not work for this particular Windows message since it passes a pointer to a struct in the calling process which is meaningless when interpreted in the context of the other process (the payroll app that owns the list view).
要解决你的问题,你可以在其他进程分配内存,虽然这是一个相当复杂的任务。通常提到的例子中,技术是code项目的文章中被发现,的。
To solve your problem you could allocate memory in the other process although this is quite a complex task. A commonly cited example of the technique is to be found in the Code Project article, Stealing Program's Memory.
也许一个简单的方法是使用WM_COPYDATA将编组进程之间的字符串数据。如果没有足够的灵活性,那么你需要找到另一种IPC机制,例如命名管道。
Perhaps a simpler approach would be to use WM_COPYDATA which will marshal string data between processes. If that doesn't have enough flexibility then you'd need to find another IPC mechanism, e.g. named pipes.
这篇关于如何找到在ListView控件一个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!