如何用钩子函数获得一个对话框中列表框的数据

rdqjuven 2006-08-22 10:22:18
有一个编译好的应用程序,运行的时候就是一个对话框,其中包含一个列表框控件,列表框控件的内容在不断刷新。现在想通过编写一个钩子程序的方法,获得列表框中的数据。已经通过Spy++监视到哪个程序在运行的时候有LB_ADDSTRING的消息,但是怎么用钩子函数实现呢?特别是,如何监视到这个应用程序的关于此列表框的消息。谢谢
...全文
309 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
rdqjuven 2006-08-22
  • 打赏
  • 举报
回复
目标列表框不是Windows标准控件,这种方法还行吗?
muroachanf 2006-08-22
  • 打赏
  • 举报
回复
1 获得句柄,一般可以用FindWindow,如果你一定要用钩子,也不是不行,就是增加点代码量.可以首先Find它的父窗口,再Enum子窗口来获得Listbox
2 做个Timer来循环发LB_GETTEXT来获得数据.
3 LB_GETTEXT的用法:打开ie,输入www.baidu.com,输入LB_GETTEXT,点搜索.........嘿嘿,就不说了


现在的年轻人,都这么懒:(
rdqjuven 2006-08-22
  • 打赏
  • 举报
回复
楼上的楼上,功能不能把过程大概讲一下,谢谢
asdwwe2004 2006-08-22
  • 打赏
  • 举报
回复
楼上 好强啊

学习了
muroachanf 2006-08-22
  • 打赏
  • 举报
回复
首先要有句柄,然后
你用LB_GETTEXT来获取,


LB_ADDFILE
An application sends an LB_ADDFILE message to add the specified filename to a list box that contains a directory listing.

LB_ADDSTRING
An application sends an LB_ADDSTRING message to add a string to a list box. If the list box does not have the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list and the list is sorted.

LB_DELETESTRING
An application sends an LB_DELETESTRING message to delete a string in a list box.

LB_DIR
An application sends an LB_DIR message to a list box to add names to the list displayed by the list box. The message adds the names of directories and files that match a specified string and set of file attributes. LB_DIR can also add mapped drive letters to the list box.

LB_FINDSTRING
An application sends an LB_FINDSTRING message to find the first string in a list box that begins with the specified string.

LB_FINDSTRINGEXACT
An application sends a LB_FINDSTRINGEXACT message to find the first list box string that exactly matches the specified string, except that the search is not case sensitive.

LB_GETANCHORINDEX
An application sends an LB_GETANCHORINDEX message to retrieve the index of the anchor item

LB_GETCARETINDEX
An application sends an LB_GETCARETINDEX message to determine the index of the item that has the focus rectangle in a multiple-selection list box. The item may or may not be selected.

LB_GETCOUNT
An application sends an LB_GETCOUNT message to retrieve the number of items in a list box.

LB_GETCURSEL
Send an LB_GETCURSEL message to retrieve the index of the currently selected item, if any, in a single-selection list box.

LB_GETHORIZONTALEXTENT
An application sends an LB_GETHORIZONTALEXTENT message to retrieve from a list box the width, in pixels, by which the list box can be scrolled horizontally (the scrollable width) if the list box has a horizontal scroll bar.

LB_GETITEMDATA
An application sends an LB_GETITEMDATA message to retrieve the application-defined value associated with the specified list box item.

LB_GETITEMHEIGHT
An application sends an LB_GETITEMHEIGHT message to retrieve the height of items in a list box.

LB_GETITEMRECT
An application sends an LB_GETITEMRECT message to retrieve the dimensions of the rectangle that bounds a list box item as it is currently displayed in the list box.

LB_GETLISTBOXINFO
An application sends an LB_GETLISTBOXINFO message to retrieve the number of items per column in a specified list box.

LB_GETLOCALE
An application sends an LB_GETLOCALE message to retrieve the current locale of the list box. You can use the locale to determine the correct sorting order of displayed text (for list boxes with the LBS_SORT style) and of text added by the LB_ADDSTRING message.

LB_GETSEL
An application sends an LB_GETSEL message to retrieve the selection state of an item.

LB_GETSELCOUNT
An application sends an LB_GETSELCOUNT message to retrieve the total number of selected items in a multiple-selection list box.

LB_GETSELITEMS
An application sends an LB_GETSELITEMS message to fill a buffer with an array of integers that specify the item numbers of selected items in a multiple-selection list box.

LB_GETTEXT
An application sends an LB_GETTEXT message to retrieve a string from a list box.

LB_GETTEXTLEN
An application sends an LB_GETTEXTLEN message to retrieve the length of a string in a list box.

LB_GETTOPINDEX
An application sends an LB_GETTOPINDEX message to retrieve the index of the first visible item in a list box. Initially the item with index 0 is at the top of the list box, but if the list box contents have been scrolled another item may be at the top.

LB_INITSTORAGE
An application sends the LB_INITSTORAGE message before adding a large number of items to a list box. This message allocates memory for storing list box items.

LB_INSERTSTRING
An application sends an LB_INSERTSTRING message to insert a string into a list box. Unlike the LB_ADDSTRING message, the LB_INSERTSTRING message does not cause a list with the LBS_SORT style to be sorted.

LB_ITEMFROMPOINT
An application sends the LB_ITEMFROMPOINT message to retrieve the zero-based index of the item nearest the specified point in a list box.

LB_RESETCONTENT
An application sends an LB_RESETCONTENT message to remove all items from a list box.

LB_SELECTSTRING
An application sends an LB_SELECTSTRING message to search a list box for an item that begins with the characters in a specified string. If a matching item is found, the item is selected.

LB_SELITEMRANGE
An application sends an LB_SELITEMRANGE message to select one or more consecutive items in a multiple-selection list box.

LB_SELITEMRANGEEX
An application sends an LB_SELITEMRANGEEX message to select one or more consecutive items in a multiple-selection list box.

LB_SETANCHORINDEX
An application sends an LB_SETANCHORINDEX message to set the anchor item

LB_SETCARETINDEX
An application sends an LB_SETCARETINDEX message to set the focus rectangle to the item at the specified index in a multiple-selection list box. If the item is not visible, it is scrolled into view.

LB_SETCOLUMNWIDTH
An application sends an LB_SETCOLUMNWIDTH message to a multiple-column list box (created with the LBS_MULTICOLUMN style) to set the width, in pixels, of all columns in the list box.

LB_SETCOUNT
An application sends an LB_SETCOUNT message to set the count of items in a list box created with the LBS_NODATA style and not created with the LBS_HASSTRINGS style.

LB_SETCURSEL
An application sends an LB_SETCURSEL message to select a string and scroll it into view, if necessary. When the new string is selected, the list box removes the highlight from the previously selected string.

LB_SETHORIZONTALEXTENT
An application sends an LB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden.

LB_SETITEMDATA
An application sends an LB_SETITEMDATA message to set a value associated with the specified item in a list box.

LB_SETITEMHEIGHT
An application sends an LB_SETITEMHEIGHT message to set the height, in pixels, of items in a list box. If the list box has the LBS_OWNERDRAWVARIABLE style, this message sets the height of the item specified by the wParam parameter. Otherwise, this message sets the height of all items in the list box.

LB_SETLOCALE
An application sends an LB_SETLOCALE message to set the current locale of the list box. You can use the locale to determine the correct sorting order of displayed text (for list boxes with the LBS_SORT style) and of text added by the LB_ADDSTRING message.

LB_SETSEL
An application sends an LB_SETSEL message to select a string in a multiple-selection list box.

LB_SETTABSTOPS
An application sends an LB_SETTABSTOPS message to set the tab-stop positions in a list box.

LB_SETTOPINDEX
An application sends an LB_SETTOPINDEX message to ensure that a particular item in a list box is visible.

Seu_why 2006-08-22
  • 打赏
  • 举报
回复
发送LB_GETITEMDATA消息?

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧