delphi获取其他外部程序中TDBGridEh控件中的数据
2013-02-08 09:02
417 查看
使用钩子原理+dll注入。首先使用FindwindowEx能获取到表格的句柄,再转化为表格,将表格的内容赋值给你的新表格。 function MsgWndProc(hwnd: HWND; Msg: UINT; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall; var // SG: TStringGrid; SG:TDrawgrid; X, Y: Integer; begin case Msg of CM_QUERYROW: begin Result := -1; if P^.DestWnd <> 0 then begin SG := Pointer(FindControl(P^.DestWnd)); if SG <> nil then Result := SG.RowCount; end; Exit; end; CM_QUERYCOL: begin Result := -1; if P^.DestWnd <> 0 then begin SG := Pointer(FindControl(P^.DestWnd)); if SG <> nil then Result := SG.ColCount; end; Exit; end; CM_HOOKCELL: begin Result := -1; P^.Text[0] := #0; if P^.DestWnd <> 0 then begin SG := Pointer(FindControl(P^.DestWnd)); if SG <> nil then begin X := WParam; Y := LParam; if (X >= 0) and (X < SG.ColCount) and (Y >= 0) and (Y < SG.RowCount) then begin Result := Length(SG.Cells[X, Y]);//就是这里 获取不到它的单元格值? if Result > 0 then begin StrPLCopy(P^.Text, SG.Cells[X, Y], 1024); end; end; end; end; Exit; end; end; Result := DefWindowProc(hwnd, Msg, WParam, LParam); end; 这个我已经测试通过。
相关文章推荐
- delphi有关获取其他程序的窗口及对窗口内控件的操作
- C#获取外部程序ListView中的数据
- dsp控制DM9000实现802.3数据收发第三篇,调试过程程序第三版;采用外部引脚中断方式获取中断,优化掉帧现象
- delphi mysql adbquery数据提供程序或其他服务返回 E_FAIL 状态
- C#如何获取其他程序ListView控件中的内容 含源码
- abap submit用法(一)调用外部程序(abap内存获取数据)
- DELPHI 跨进程获取其他程序的DBGrid内容
- DELPHI 跨进程获取其他程序的DBGrid内容
- 用CImage在picture控件上显示外部图片,并获取各像素颜色数据
- Delphi通过管道执行外部命令行程序(cmd)并获取返回结果
- Delphi获取其他exe程序版本号
- Delphi中如何控制其他程序窗体上的窗口控件
- abap submit用法(一)调用外部程序(abap内存获取数据) 收藏
- C#如何获取其他程序ListView控件中的内容
- Delphi 实现获取其他程序的子窗体
- DELPHI 跨进程获取其他程序的DBGrid内容
- Delphi 如何操作外部程序的控件(如按钮,文本框,单选按钮等)
- Delphi 获取外部程序句柄与发送消息
- 页面单击按钮弹出modaldialog然后调用ajax处理程序获取数据,给父级页面控件赋值
- Delphi中如何控制其他程序窗体上的窗口控件