 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rob Kennedy Guest
|
Posted: Wed Nov 12, 2003 5:34 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
chenchang wrote:
| Quote: | now i am writting a Control descendant component,when i debug paint
message,i do not look at paint funciton result immediately!
for example:
i call TCanvas.LineTo procedure,i want to determine whether it is a right
calculated point . so i want to look at result immediately! but i alwarys
look at the result after some codes .
|
First, make sure the DoubleBuffered property is False for all components
involved. Also, make sure that your form and your component are not
covered by any part of the debugger. Otherwise, the debugger will hide
the very painting effects you're trying to debug. I usually start my
program without any breakpoints set, resize the form to be along the
edge of the screen (usually where the Object Inspector used to be) and
then re-set the breakpoints and make my component visible.
--
Rob
|
|
| Back to top |
|
 |
Robert Cerny Guest
|
Posted: Wed Nov 12, 2003 11:18 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
Do not use breakpoints at all.
Use OutputDebugString() and monitor what comes out.
--
Robert Cerny
DelphiShaman
"chenchang" <baibaichen (AT) sohu (DOT) com> wrote
| Quote: | now i am writting a Control descendant component,when i debug paint
message,i do not look at paint funciton result immediately!
for example:
i call TCanvas.LineTo procedure,i want to determine whether it is a right
calculated point . so i want to look at result immediately! but i alwarys
look at the result after some codes .
why?
how to look at paint funciton result immediately?
thanks!!!
|
|
|
| Back to top |
|
 |
Kurt Barthelmess Guest
|
Posted: Wed Nov 12, 2003 1:14 pm Post subject: Re: how to look at paint funciton result immediately when de |
|
|
"chenchang" <baibaichen (AT) sohu (DOT) com> wrote:
| Quote: | now i am writting a Control descendant component,when i debug paint
message,i do not look at paint funciton result immediately!
for example:
i call TCanvas.LineTo procedure,i want to determine whether it is a right
calculated point . so i want to look at result immediately! but i alwarys
look at the result after some codes .
|
Are you looking with your eyes at the screen, or looking
programmatically at a pixel on the display? Under some conditions,
Windows will cache drawing requests, so you may not see them appear
(with your eyes) immediately. Also, as Rob points out, the debugger
can interfere with this.
Good luck.
Kurt
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Wed Nov 12, 2003 3:45 pm Post subject: Re: how to look at paint funciton result immediately when de |
|
|
| Quote: | now i am writting a Control descendant component,when i debug paint
message,i do not look at paint funciton result immediately!
|
Debugging painting (as well as Windows messages) can be difficult. Often
debugging influences the painting itself (remember Heisenberg ,
especially in timing issues.
Jens
|
|
| Back to top |
|
 |
Chris Morgan Guest
|
Posted: Wed Nov 12, 2003 3:55 pm Post subject: Re: how to look at paint funciton result immediately when de |
|
|
| Quote: | now i am writting a Control descendant component,when i debug
paint
message,i do not look at paint funciton result immediately!
Debugging painting (as well as Windows messages) can be difficult.
Often
debugging influences the painting itself (remember Heisenberg ,
especially in timing issues.
|
When debugging OnPaint events or paint messages you need to arrange
your
Delphi windows so that they do not overlap at all with your
application window, otherwise you will get into a loop where the
paint event is fired every time the application window is shown,
which will bring your Delphi code window to the front...
The other thing you need is lots of patience. OnPaint events get
fired A LOT!
Cheers,
Chris
|
|
| Back to top |
|
 |
chenchang Guest
|
Posted: Wed Nov 12, 2003 5:22 pm Post subject: how to look at paint funciton result immediately when debug |
|
|
now i am writting a Control descendant component,when i debug paint
message,i do not look at paint funciton result immediately!
for example:
i call TCanvas.LineTo procedure,i want to determine whether it is a right
calculated point . so i want to look at result immediately! but i alwarys
look at the result after some codes .
why?
how to look at paint funciton result immediately?
thanks!!!
|
|
| Back to top |
|
 |
chenchang Guest
|
Posted: Thu Nov 13, 2003 3:57 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
hi kurt,of course,
1 i set doublebuffered to false
2 do not overlap with other window. it is the top window
3 if possible, i can use remote debug to prevent more paint messages
so ,how to eliminate windows cache?
"Kurt Barthelmess (TeamB)" <kbarthelmess (AT) compuserve (DOT) com> wrote
| Quote: | "chenchang" <baibaichen (AT) sohu (DOT) com> wrote:
now i am writting a Control descendant component,when i debug paint
message,i do not look at paint funciton result immediately!
for example:
i call TCanvas.LineTo procedure,i want to determine whether it is a right
calculated point . so i want to look at result immediately! but i alwarys
look at the result after some codes .
Are you looking with your eyes at the screen, or looking
programmatically at a pixel on the display? Under some conditions,
Windows will cache drawing requests, so you may not see them appear
(with your eyes) immediately. Also, as Rob points out, the debugger
can interfere with this.
Good luck.
Kurt
|
|
|
| Back to top |
|
 |
Kurt Barthelmess Guest
|
Posted: Thu Nov 13, 2003 11:47 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
"chenchang" <baibaichen (AT) sohu (DOT) com> wrote:
| Quote: | hi kurt,of course,
1 i set doublebuffered to false
2 do not overlap with other window. it is the top window
3 if possible, i can use remote debug to prevent more paint messages
so ,how to eliminate windows cache?
|
You can not prevent Windows caching. I suspect that is the problem
here. I can reproduce the problem even when I am painting direcly to
the canvas/screen:
procedure TForm1.Button1Click(Sender: TObject);
begin
with Canvas do
begin
if B then Brush.Color := clRed
else Brush.Color := clBlue;
FillRect(ClientRect);
end;
B := not B;
end;
Setting a breakpoint on the FillRect statement and stepping does not
cause the painting to occur until I let it run. It does happen
eventually, but there is no other painting code, so Windows is caching
on me.
I can force an immediate update of the display by calling Update right
after the call to FillRect. You might want to do that for debugging
your painting code, but I would not leave it in for production.
Good luck.
Kurt
|
|
| Back to top |
|
 |
chenchang Guest
|
Posted: Fri Nov 14, 2003 12:31 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
i doubt this is causeed by TCancas?
and what do u think?
"Kurt Barthelmess (TeamB)" <kbarthelmess (AT) compuserve (DOT) com> wrote
| Quote: | "chenchang" <baibaichen (AT) sohu (DOT) com> wrote:
hi kurt,of course,
1 i set doublebuffered to false
2 do not overlap with other window. it is the top window
3 if possible, i can use remote debug to prevent more paint messages
so ,how to eliminate windows cache?
You can not prevent Windows caching. I suspect that is the problem
here. I can reproduce the problem even when I am painting direcly to
the canvas/screen:
procedure TForm1.Button1Click(Sender: TObject);
begin
with Canvas do
begin
if B then Brush.Color := clRed
else Brush.Color := clBlue;
FillRect(ClientRect);
end;
B := not B;
end;
Setting a breakpoint on the FillRect statement and stepping does not
cause the painting to occur until I let it run. It does happen
eventually, but there is no other painting code, so Windows is caching
on me.
I can force an immediate update of the display by calling Update right
after the call to FillRect. You might want to do that for debugging
your painting code, but I would not leave it in for production.
Good luck.
Kurt
|
|
|
| Back to top |
|
 |
Kurt Barthelmess Guest
|
Posted: Fri Nov 14, 2003 1:14 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
"chenchang" <baibaichen (AT) sohu (DOT) com> wrote:
| Quote: | i doubt this is causeed by TCancas?
and what do u think?
|
It has nothing to do with TCanvas. You'll get the same caching doing
operations with the HDC directly.
Good luck.
Kurt
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Fri Nov 14, 2003 1:17 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
Kurt Barthelmess (TeamB) wrote:
| Quote: | It has nothing to do with TCanvas. You'll get the same caching doing
operations with the HDC directly.
|
Do you suppose the GDIFlush API function would be of any use?
--
Rob
|
|
| Back to top |
|
 |
chenchang Guest
|
Posted: Fri Nov 14, 2003 6:48 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
what's mean? rob
"Rob Kennedy" <.> wrote
| Quote: | Kurt Barthelmess (TeamB) wrote:
It has nothing to do with TCanvas. You'll get the same caching doing
operations with the HDC directly.
Do you suppose the GDIFlush API function would be of any use?
--
Rob
|
|
|
| Back to top |
|
 |
chenchang Guest
|
Posted: Fri Nov 14, 2003 8:42 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
oh, rob, i know what u say!!!
if i want to look at result immeduately, i can call
Windows.GDiSetBatchLimit(1). that will disable Cache!!!!!!
thanks !!!!!!!!!!
"Rob Kennedy" <.> wrote
| Quote: | Kurt Barthelmess (TeamB) wrote:
It has nothing to do with TCanvas. You'll get the same caching doing
operations with the HDC directly.
Do you suppose the GDIFlush API function would be of any use?
--
Rob
|
|
|
| Back to top |
|
 |
Kurt Barthelmess Guest
|
Posted: Fri Nov 14, 2003 11:30 am Post subject: Re: how to look at paint funciton result immediately when de |
|
|
Rob Kennedy <.> wrote:
| Quote: | Do you suppose the GDIFlush API function would be of any use?
|
Yes, it might. It certainly will cause Windows to flush the cache. Or
you could disable the caching. I'd think you'd only want to do that
when debugging, to avoid the loss to drawing optimizations though.
Then the question becomes one of "Does flushing the cache so as to
observe the effect of an operation interfere with the operation
itself?" Sort of a Heisenberg Uncertainty Principle as applied to
GDI<g>.
Kurt
|
|
| Back to top |
|
 |
|
|
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
|
|