G
gzbxmcx
Unregistered / Unconfirmed
GUEST, unregistred user!
已得到对象实例但不能Next数据, 只能读出第一条数据, 只要进行Next或Edit或Insert都是报地址冲突...
核心代码如下:
function FindControl(hwnd: HWND): TWinControl;
type
PObjectInstance = ^TObjectInstance;
TObjectInstance = packed record
Code: Byte; // 0xE8 { CALL NEAR PTR Offset } 相对短跳转
Offset: Integer; // CalcJmpOffset(Instance, @Block^.Code)
Method: Pointer; // WndMethod地址
Self: Pointer; // 对象实例
end;
var
Instance: PObjectInstance;
begin
Instance := Pointer(GetWindowLong(hwnd, GWL_WNDPROC));
if Instance <> nil then
Result := Instance.Self
else
Result := nil;
end;
//自定义消息在隐藏窗口中, 用来接收调用程序发来的消息.
function MsgWndProc(hwnd: HWND; Msg: UINT; WParam: WPARAM; LParam: LPARAM):
LRESULT; stdcall;
var
Str: string;
TempQry: TAdoQuery;
begin
case Msg of
CM_QUERYGRID:
begin
Result := -1;
if P^.DestWnd <> 0 then
begin
ResDataSet := TDBGrid(FindControl(P^.DestWnd)).DataSource.DataSet;
if ResDataSet.RecordCount > 0 then
begin
Result := 1;
end;
end;
Exit;
end;
end;
Result := DefWindowProc(hwnd, Msg, WParam, LParam);
end;
核心代码如下:
function FindControl(hwnd: HWND): TWinControl;
type
PObjectInstance = ^TObjectInstance;
TObjectInstance = packed record
Code: Byte; // 0xE8 { CALL NEAR PTR Offset } 相对短跳转
Offset: Integer; // CalcJmpOffset(Instance, @Block^.Code)
Method: Pointer; // WndMethod地址
Self: Pointer; // 对象实例
end;
var
Instance: PObjectInstance;
begin
Instance := Pointer(GetWindowLong(hwnd, GWL_WNDPROC));
if Instance <> nil then
Result := Instance.Self
else
Result := nil;
end;
//自定义消息在隐藏窗口中, 用来接收调用程序发来的消息.
function MsgWndProc(hwnd: HWND; Msg: UINT; WParam: WPARAM; LParam: LPARAM):
LRESULT; stdcall;
var
Str: string;
TempQry: TAdoQuery;
begin
case Msg of
CM_QUERYGRID:
begin
Result := -1;
if P^.DestWnd <> 0 then
begin
ResDataSet := TDBGrid(FindControl(P^.DestWnd)).DataSource.DataSet;
if ResDataSet.RecordCount > 0 then
begin
Result := 1;
end;
end;
Exit;
end;
end;
Result := DefWindowProc(hwnd, Msg, WParam, LParam);
end;