Board index » delphi » Re: Updating the screen regularly in Internet Explorer from an ActiveX control

Re: Updating the screen regularly in Internet Explorer from an ActiveX control


2004-11-30 04:19:57 AM
delphi71
Quote
I'm writing an ActiveX control that does a "marquee" effect to slide
text right to left. This control will be embedded in a frame in an
HTML layout that is running in Internet Explorer.

I've got it working, sort of. That part that is challenging now is to
get the screen to update on a regular basis. I have got a TTimer that's
set up to fire periodically, and on each firing of the timer, I
update the text area (BitBlt from an off-screen graphic to a TImage
that's on the control), and then Invalidate the Image.

I think I am hitting the standard problem - stuff happening in other
frames can take up time that makes the marquee appear to stall, so
that the text scroll is not smooth. A big problem can be the display
of Flash files.

I tried using some other routines instead of Invalidate: Repaint,
Update, etc. No improvement.

Is there some other approach to take? Am I hitting a problem in the
threading model of IE 6 (which is actually a TWebBrowser in another
application I am running)?
Is the problem that the timer is not firing on a (somewhat) regular
basis or that the TImage is not being redrawn when you ask it to? If
you don't know you could let the program create a log file with the
times (GetTickCount) the timer fired.
If the timer is not firing regularily it don't think there's much you
could do. Normally you could create a secundairy thread, let it sleep
most of the times and let it synchronize a method call when it wakes
up, but i don't think that is a good idea here. Synchronizing in a DLL
is (in my experience at least) horrible, let alone in an ActiveX DLL
running in IE, especially if it is not properly handling Windows
messages in time either.
If there's no problem with the timer i think the easiest solution would
be to replace the TImage with a custom-made TCustomControl. This will
not only drop some overhead, but also makes it possible for you to
directly call the Paint method.
An alternative (possibly working in both cases and likely to result in
better responsiveness) is to directly use the Windows API to draw your
marqee. In this case you could use the secondairy thread approach
without the synchronize, since the Windows API is threadsafe. You could
still make a TCustomControl, which uses Canvas.Handle to get a DC
handle, which is required for the Windows API drawing functions. You
then implement the Paint method without using any VCL methods (which
means you should also get the handle in advance) and you could call
that directly from the secundairy thread.
 
 

Re: Updating the screen regularly in Internet Explorer from an ActiveX control

(Tried this a week ago in the activex.writing group and got no replies.
Maybe someone here has some ideas...)
I'm writing an ActiveX control that does a "marquee" effect to slide text
right to left. This control will be embedded in a frame in an HTML layout
that's running in Internet Explorer.
I've got it working, sort of. That part that is challenging now is to get the
screen to update on a regular basis. I have got a TTimer that is set up to fire
periodically, and on each firing of the timer, I update the text area
(BitBlt from an off-screen graphic to a TImage that is on the control), and
then Invalidate the Image.
I think I am hitting the standard problem - stuff happening in other frames
can take up time that makes the marquee appear to stall, so that the text
scroll is not smooth. A big problem can be the display of Flash files.
I tried using some other routines instead of Invalidate: Repaint, Update,
etc. No improvement.
Is there some other approach to take? Am I hitting a problem in the
threading model of IE 6 (which is actually a TWebBrowser in another
application I am running)?
Thanks.