BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TDrawGrid Access Violation

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Mark Payton
Guest





PostPosted: Thu Aug 07, 2003 10:56 am    Post subject: TDrawGrid Access Violation Reply with quote



Dear All,

I hope you can point me in the right direction. (I Can provide source if you
like) D6

I have a Grid component descended from TDrawGrid.

It consists of overridden procedures

constructor create(AOwner: TComponent); override;
Destructor Destroy; Override;
Procedure SizeChanged(OldColCount, OldRowCount:integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;

and other custom procedures

each of which has the "inherited" in front of the code before my code
starts

Intermittently I experience Access Violations when I move my mouse "OUT" of
the control (even when the control is invisible).
Looking at the map file for my exe it points to CONTROLS.PAS -
ScreenToClient (or ClientToScreen?).

As it is extremely unlikely CONTROLS.PAS is faulty I am looking into any of
my code that is faulty (as this is my first component I reckon its a fair
bet!)

I really can't explain this.

Can anyone point me in the right direction.

Thanks in complete Desperation.

p.s. I can provide the source code on request.

Regards

Mark



Back to top
Kurt Barthelmess
Guest





PostPosted: Thu Aug 07, 2003 4:03 pm    Post subject: Re: TDrawGrid Access Violation Reply with quote



"Mark Payton" <mark.payton (AT) derbyshire (DOT) gov.uk> wrote:

Quote:
p.s. I can provide the source code on request.

Why don;t you post the code for your MouseMove method if it is
reasonable short. Or to save time, look at the Call stack to see where
Controls.pas has been called from and exactly what the AV is about.
Make sure you are compiling with the debug dcu's.

Good luck.

Kurt



Back to top
Mark Payton
Guest





PostPosted: Thu Aug 07, 2003 4:35 pm    Post subject: Re: TDrawGrid Access Violation Reply with quote



Many Thanks

Here Goes, the wierd thing is this NEVER happens in the IDE environment, how
would I debug it then?

procedure TMarkPaytonGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
var
Column,Row: Integer;
T: TRect;
APoint: TPoint;
txt: textfile;
begin
try
inherited mousemove(Shift, X, Y);
APoint:=Point(X,Y);
MouseToCell(X, Y, Column, Row);
if (Column>=0) or (Row>=0) then
begin
t:=CellRect(Column,Row);
RCellRecord:=CellPointers[(Row*ColCount)+(Column)];
Hint:=RCellRecord^.Hint;
Application.ShowHint:=True;
GetCursorPos(aPoint);
Application.ActivateHint(APoint);
end;
except on E: Exception do
begin
assignfile(txt,'c:TMarkPaytonGridMouseMove.txt');
ReWrite(txt);
Writeln(txt,e.message);
CloseFile(txt);
end;
end;

end;







"Kurt Barthelmess (TeamB)" <kbarthelmess (AT) compuserve (DOT) com> wrote

Quote:
"Mark Payton" <mark.payton (AT) derbyshire (DOT) gov.uk> wrote:

p.s. I can provide the source code on request.

Why don;t you post the code for your MouseMove method if it is
reasonable short. Or to save time, look at the Call stack to see where
Controls.pas has been called from and exactly what the AV is about.
Make sure you are compiling with the debug dcu's.

Good luck.

Kurt





Back to top
Marc Rohloff
Guest





PostPosted: Thu Aug 07, 2003 5:17 pm    Post subject: Re: TDrawGrid Access Violation Reply with quote

Why don't you comment out sections of your code until the error
dissappears or add logging to a text file?
Off hand I would suspect that CellPointers or RCellRecord is not valid
(You didn't show all the rest of your code)
I have also found that the Row and Column values in a grid aren't always
valid (for example while deleting or inserting rows).

Marc



Back to top
Michael Mount
Guest





PostPosted: Thu Aug 07, 2003 6:34 pm    Post subject: Re: TDrawGrid Access Violation Reply with quote

Mark,

Quote:
if (Column>=0) or (Row>=0) then

This may be stupid but shouldn't this comparison be "AND" ? Seems to me
that if the MouseMove happens to fire in the border then either the Row or
Column may be returned as a -1...

HTH - Mike




Back to top
Mark Payton
Guest





PostPosted: Fri Aug 08, 2003 8:03 am    Post subject: Re: TDrawGrid Access Violation Reply with quote

Thanks to all, I'll give all suggestions a try!

I'll report back and let you know

Regards

Mark

"Michael Mount" <mmount (AT) turbont (DOT) net> wrote

Quote:
Mark,

if (Column>=0) or (Row>=0) then

This may be stupid but shouldn't this comparison be "AND" ? Seems to me
that if the MouseMove happens to fire in the border then either the Row or
Column may be returned as a -1...

HTH - Mike






Back to top
Mark Payton
Guest





PostPosted: Fri Aug 08, 2003 8:32 am    Post subject: Re: TDrawGrid Access Violation Reply with quote

Ok, now this has got me confused!

I have checked that the debug DCU's had been included in the project and
noticed that it wasn;t.

The only change I made was to include them.

Now I can't get it to fall over (so far), weird!

I'm pleased, but I would like to pin down the bit of code that caused the
error.

How should I proceed? or shall I leave it?

Regards


Mark


"Mark Payton" <mark.payton (AT) derbyshire (DOT) gov.uk> wrote

Quote:
Thanks to all, I'll give all suggestions a try!

I'll report back and let you know

Regards

Mark

"Michael Mount" <mmount (AT) turbont (DOT) net> wrote in message
news:3f329b5a (AT) newsgroups (DOT) borland.com...
Mark,

if (Column>=0) or (Row>=0) then

This may be stupid but shouldn't this comparison be "AND" ? Seems to me
that if the MouseMove happens to fire in the border then either the Row
or
Column may be returned as a -1...

HTH - Mike








Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.