Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple pointer question

Status
Not open for further replies.

Zoilus

Programmer
Jun 19, 2001
5
CA
Hi,

I have a problem with some pointer. I want to have access to some component of a Form within a thread, and to do so, I initialise the pointer in my Thread to the component of my form. Here's that small part of my code:

// The part from my form where I create, initialise and start my thread
th:=THitRatioThread.Create(true);
th.SendData(qryHitRatio); // Here is the problem
th.resume;

_____________

// The thread where I set my pointer
var
FqryHitRatio : ^TOCIQuery;

procedure THitRatioThread.sendData( var qryHitRatio : TOCIQuery);
begin
new(fQryHitRatio);
fQryHitRatio^:=qryHitRatio;
end;
_____________

When I follow my program, the 'new' method initialise the pointer, but the line 'fQryHitRatio^:=qryHitRatio;' does nothing at all... Anyone knows why?

Thanks a lot,
 
I don't think you should need to do such complex pointer manipulations! If it was a normal TQuery you would need to make sure it has it's own session - see Borland's BKQuery demo for more details on that.

You might be able to do it like this:


// The thread where I set my pointer
var
   FqryHitRatio : TOCIQuery;

procedure THitRatioThread.sendData( var qryHitRatio : TOCIQuery);
begin
  fQryHitRatio:=qryHitRatio;
end;


Since FQryHitRatio is a pointer anyway, and qryHitRation that you are passing in is a pointer, this should do what you are attempting I think!

Good Luck! TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top