Article View: borland.public.cppbuilder.nativeapi
Article #1879Re: How to be sure a window has been repainted
From: Giuliano
Date: Tue, 29 May 2007 10:20
Date: Tue, 29 May 2007 10:20
66 lines
2665 bytes
2665 bytes
Il Mon, 28 May 2007 20:02:21 +0200, Wookie <fa067235@skynet.be> ha scritto:
>Hi all,
>
>I am working inside a thread that drives a LCD screen and a camera. I
>have to synchronize the display on the LCD and the camera acquisition. I
>would like to know if there is any window message that is sent when a
>window has been repainted (a sort of WM_ENDPAINT). I do call the Repaint
>method of TWinControl but most of the time, the camera acquires a mix of
>the previous frame and the new one. How can I be sure the LCD has been
>fully repainted ?
Hi Christophe,
I'm not sure if this approach can help you, but you could try to paint
directly from (synchronized with) the thread. Then you can invoke the GDIFlush
API whenever you need to have the screen updated.
For example:
void __fastcall TYourThread::Execute()
{
while ( !Terminated ) {
TCanvas* Canvas = /* acquire here the control's canvas */
Canvas->Lock();
// Perform here the painting
Canvas->Unlock();
GdiFlush();
}
}
or, for exception safety, something like this:
class TCanvasLockManager : boost::noncopyable {
public:
TCanvasLockManager( TCanvas& Canvas )
: canvas_( Canvas ) { canvas_.Lock(); }
~TCanvasLockManager() throw() { canvas_.Unlock(); }
operator bool() const { return true; }
private:
TCanvas& canvas_;
};
#define LOCK_CANVAS( C ) \
if ( bool const & C_lk ## __LINE__ = TCanvasLockManager( ( C ) ) )
struct TGDIFlusher {
~TGDIFlusher() throw() { GdiFlush(); }
};
void __fastcall TYourThread::Execute()
{
while ( !Terminated ) {
TCanvas* Canvas = /* acquire here the control's canvas */
TGDIFlusher const GDIFlusher;
LOCK_CANVAS( *Canvas ) {
// Perform here the painting
}
}
}
Regards
Giuliano
Technical Details
Message-ID:
<k3tn53t0jd7bhqfu8c5idsca88ib4pss8e@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<465B192D.18A0FD94@skynet.be>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1db88f519055e05b X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Giuliano <> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: How to be sure a window has been repainted Date: Tue, 29 May 2007 12:20:34 +0200 Message-ID: <k3tn53t0jd7bhqfu8c5idsca88ib4pss8e@4ax.com> References: <465B192D.18A0FD94@skynet.be> X-Newsreader: Forte Agent 2.0/32.652 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.72.236.131 X-Trace: newsgroups.borland.com 1180434033 81.72.236.131 (29 May 2007 03:20:33 -0700) Lines: 66 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail