求获取执行文件里二维控件数据的方法.
别人做的软件(a.exe)里面用了Listview,stringgrid,datagrid等控件。
我想在这些控件里面取得第1列或第二列的全部数据不知道怎样得到?
或者这些控件的全部数据怎样得到呢?
我做过获取edit控件或combobox控件数据,但是获取这些二维控件的数据没有做过。
请csdn的高手帮忙解答。
我先谢谢了。
[解决办法]
本帖最后由 bdmh 于 2012-11-07 18:09:39 编辑 用钩子
function HookProc(code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
var
MouseHookStruct: ^TMOUSEHOOKSTRUCT;
WC: TWinControl;
classname: array [0..99] of char;
i:Integer;
begin
Result := 0;
if code < 0 then
Result := CallNextHookEx(NextHook,code,wParam,lParam);
case wParam of
WM_LBUTTONDOWN:
begin
end;
WM_LBUTTONUP:
begin
end;
WM_LBUTTONDBLCLK:
begin
end;
WM_RBUTTONDOWN:
begin
MouseHookStruct := Pointer(LParam);
//MouseHookStruct.hwnd为所点击组件的句柄,通过它得到它的类名
GetClassName(MouseHookStruct.hwnd,classname,100);
//如果是TLitView
if StrPas(classname) = 'TListView' then
begin
//获取该组件
WC := TListView(PInteger(Integer(GetWindowLong(MouseHookStruct.hwnd, GWL_WNDPROC)) + 9)^);
//循环显示item的Caption
for i := 0 to TListView(WC).Items.Count - 1 do
begin
ShowMessage(TListView(WC).Items[i].Caption);
end;
end;
end;
WM_RBUTTONUP:
begin
end;
WM_NCMOUSEMOVE,WM_MOUSEMOVE:
begin
//给调用者发消息
SendMessage(CallHandle,MessageID,pMouseHookStruct(lParam)^.hwnd,Integer(@pMouseHookStruct(lParam)^));
end;
end;
end;