获取 DBGrid/dxDBGrid 的当前选中字符串

之前编写数据查询程序,需获取 DBGrid/dxDBGrid 中 焦点“单元格” 的选中字符串,折腾良久,终发现一简单方法...

    var
      hDBGrid: HWND;

    begin
      hDBGrid:= WindowFromPoint(Mouse.CursorPos);
      SendMessage(hDBGrid, WM_COPY, 0, 0);
      edt_SelTxtTmp.Clear; //edt_SelTxtTmp: TEdit;
      SendMessage(edt_SelTxtTmp.Handle, WM_PASTE, 0, 0);

    end;

    若欲通过 VCL 源码来寻求解决之道,貌似不会简单;以简如 SendMessage 之法搞定某些 简单却又繁琐 的问题,不失为妙方...

你可能感兴趣的:(职场,休闲)