Article View: borland.public.cppbuilder.nativeapi
Article #17754Re: OnPaint with Semaphore seems not working...
From: Phuoc Can HUA
Date: Tue, 04 Mar 2003 22:03
Date: Tue, 04 Mar 2003 22:03
60 lines
3678 bytes
3678 bytes
Oliver, You are ABSOLUTELY right. Canvas is a pain in thread :-( I just found out that it wasn't the (only) problem that the unfinished image is copied. It's simply the CopyRect gets crazy. Before, I was moving some windows around while my program was running. Therefore I assumed that the OnPaint came in place. But then I found out that also happens even I just move the mouse pointer around, which is not triggering the OnPaint event at all. The funny thing is if I leave my program running without any movement the graphic is fine. Luckily, I found someone has experienced the same thing :-) I used to use WinAPI to draw. But then I thought that's the time of Win3.x and it's no long up-to-date :-) So, I tried the BCB lib. Can you give me any advice to convert my CopyRect to WinAPI? Is there a similar function and with binary operation (CopyMode)? Since I also plan to compile my program with Kylix for Linux (maybe one day) :-) shouldn't I avoid to use too many WinAPI's, what do you think? Should I have a look in SDL (www.libsdl.org)? Will I have the same problem with SDL? Vielen Dank Phuoc Can HUA "Oliver Rutsch" <nospam@sympatec.com> wrote in message news:1046770772.980524@post.sympatec.net... > Hi Phuoc, > [...] > > > > Normally you should use the Canvas->Lock(), Canvas->Unlock() and > Canvas->TryLock() for this purpose. If you don't trust it, you can also > use a TCriticalSection (i think the VCL locking functions are using > critical sections internally, too) for your locking mechanism. Although > you can use a semaphore for this purpose, it is more likely designed for > instance or resource counters from different processes (global sync > object like a named mutex). > But as I wrote before I don't think that it will help to solve your > problem. I tried every known locking mechanism in the Paint() function > of my component and nothing helped. The Canvas->Handle sometimes got > invalid (the VCL throws NO exception in that case, it just does > something stupid...) and then you're lost. Using the Win32 API functions > for drawing looks like a bad idea, but once started it is not too much > work, because you have a lot of functions you can use nearly in the same > way as the Canvas does. > Again, the GUI functions of the VCL are not designed for multithreading, > so I would check if it is really neccessary to use multithreaded visual > components. Keep your main thread free to update your user interface and > start some worker threads for the rest. > > Hope that helps. > > Bye, > > -- > Dipl. Ing. Oliver Rutsch > EMail: orutsch at sympatec.com > Sympatec GmbH Germany >
Technical Details
Message-ID:
<3e652410$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e63f403$1@newsgroups.borland.com> <1046770772.980524@post.sympatec.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7b93bd55840acb0 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-03-04 15:21:17 PST From: "Phuoc Can HUA" <home+a+t+huaonline.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3e63f403$1@newsgroups.borland.com> <1046770772.980524@post.sympatec.net> Subject: Re: OnPaint with Semaphore seems not working... Date: Wed, 5 Mar 2003 09:03:57 +1100 Lines: 62 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 210.9.89.210 Message-ID: <3e652410$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1046815760 210.9.89.210 (4 Mar 2003 14:09:20 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail