🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1881

Re: How to be sure a window has been repainted

#1881
From: Wookie
Date: Tue, 29 May 2007 17:10
77 lines
3269 bytes
Hi Giuliano,

Thanks for the sugestion but unfortunately it does not help. It seems that the
problem comes from the hardware driving the LCD. Altough, they ensure a refresh
rate of 60 Hz, in practice I have to wait a quite long time between the display
function and the actual display on the LCD.

Christophe



> 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: <465C5E9C.2704298B@skynet.be>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <465B192D.18A0FD94@skynet.be> <k3tn53t0jd7bhqfu8c5idsca88ib4pss8e@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1db88f519055e05b
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Message-ID: <465C5E9C.2704298B@skynet.be>
Date: Tue, 29 May 2007 19:10:52 +0200
From: Wookie <fa067235@skynet.be>
X-Mailer: Mozilla 4.74 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: How to be sure a window has been repainted
References: <465B192D.18A0FD94@skynet.be> <k3tn53t0jd7bhqfu8c5idsca88ib4pss8e@4ax.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.243.39.183
X-Trace: newsgroups.borland.com 1180458750 81.243.39.183 (29 May 2007 10:12:30 -0700)
Lines: 78
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail