Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double buffered animation

Status
Not open for further replies.

hennep

Programmer
Dec 10, 2000
429
In this thread in the Win API forum there is a example in c++ of double buffered flicker free animation.
thread713-460235 think this is msvc code, I cannot get it to work in a TImage. Can someone tell how to convert it ?
I want to draw lines in a TImage.
 
The API functions given in the thread example will be available with Borland's implementation of the WindowsAPI or even have VCL (encapsulation) equivalents to make life easier:)

I would think that the canvas of the TImage would be a good place to start, eg - Image1->Canvas->Draw(...)

My understanding of buffering is that you would need to draw on the canvas of a TBitMap (off screen) and then copy that to the TImage canvas. This is basically what the &quot;BitBlt&quot; function does for example but uses device contexts and coordinates which you could get from a TRect and the ClientRect property. You could use something like: Canvas->Handle = GetDC(<handle of control>) for device context maters.

 
hi mattcs,

I tried this:
HANDLE m_hWnd = Image1->Picture->Bitmap->Handle;
HDC hDC = ::GetDC(m_hWnd);

When there is a picture loaded in Image1 the GetDc function returns NULL
 
Hello.

Try setting the stretch property of the TImage to true. If that doesn't help. I've tried this trick to prevent flicker of some controls and it helped but it does make you app use up some more memory, place the TImage on a TPanel and set the doublebuffered property of the panel to true, that property is not a member of TImage since it is not a TWinControl descendant. You can also set the Stretch property of the TImage to true aswell.


Panel1->DoubleBuffered=true;

 
The DoubleBuffered property is not visible in the object inspector.
But it works great !

thanks BTecho,

Hennep
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top