Article View: borland.public.cppbuilder.nativeapi
Article #4087Re: Application ProcessMessages
From: saravanan
Date: Tue, 14 Mar 2006 06:19
Date: Tue, 14 Mar 2006 06:19
120 lines
4661 bytes
4661 bytes
Hi
Thanx Remy Lebeau. I am using ksdev SkinEngine to provide skining
feature to my Application. I found that in his source code he is using
timer to paint the caption bar and other skin controls. If i use just Form
update, then i think, skin will not be painted until it receives the Timer
message. So i have some idea shown below
(Modified ProcessMessage method to read messages other than my application
defined messages)
function ProcessMyMessage(var Msg: TMsg): Boolean;
var
Handled: Boolean;
begin
Result := False;
if PeekMessage(Msg, 0, 0, 100000, PM_REMOVE) then //..Assuming other
controls will send messages < 1,00,000 ( 1 lakh )
begin
Result := True;
if Msg.Message <> WM_QUIT then
begin
Handled := False;
if Assigned(FOnMessage) then FOnMessage(Msg, Handled);
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else
FTerminate := True;
end;
end;
procedure ProcessMyMessages;
var
Msg: TMsg;
begin
while ProcessMessage(Msg) do {loop};
end;
So invoke ProcessMyMessages method whenever painting needed. Assumption
here is no other control should use message id greater than 1,00,000. My
user defined messages will have message id greater than 1,00,000.
Remy Lebeau will there be any side affects to this code ?
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4415eebd$1@newsgroups.borland.com...
>
> "saravanan" <asaravanan@ften.com> wrote in message
> news:441516f5$1@newsgroups.borland.com...
>
> > Consider i have 5 windows in my application and only 3 of
> > them requires painting, in this case i will try to paint all the 5
> windows.
>
> Then you need to selectively choose which forms to repaint, instead of
> repainting all of them unconditionally. If you only have 5, then
hard-code
> the pointers instead of using a loop:.
>
> void __fastcall UpdateAppropriateForms()
> {
> Form1->Update();
> Form3->Update();
> Form5->Update();
> }
>
> void __fastcall TForm1::Function()
> {
> Operation1();
> UpdateAppropriateForms();
>
> Operation2();
> UpdateAppropriateForms();
>
> Operation3();
> UpdateAppropriateForms();
> }
>
>
> Otherwise, you'll have to set up some kind of list that the loop can use
to
> decide which forms to repaint, ie:
>
> void __fastcall UpdateForms(TForm **Forms, int FormCountHigh)
> {
> for(int i = 0; i <= FormCountHigh; ++i)
> Forms[i]->Update();
> }
>
> void __fastcall TForm1::Function()
> {
> Operation1();
> UpdateForms( OPENARRAY(TForm, (Form1, Form3, Form5)) );
>
> Operation2();
> UpdateForms( OPENARRAY(TForm, (Form2, Form4)) );
>
> Operation3();
> UpdateForms(OPENARRAY(TForm, (Form1)) );
> }
>
>
> > Already OS is taking care of painting the necessary area only, i think
> > we are ignoring that optimization or performance.
>
> Not true. Update() only repaints the areas that actually need repainting,
> in other words the areas that have pending WM_PAINT and related messages
> already in the message queue. Repaint() on the other hand, is a full
> repainting regardless of the current queue status.
>
>
> Gambit
>
>
Technical Details
Message-ID:
<4416608c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<440ee66c@newsgroups.borland.com> <440f21ca$1@newsgroups.borland.com> <441004a5$1@newsgroups.borland.com> <44109fc6$1@newsgroups.borland.com> <441117a4$1@newsgroups.borland.com> <4411d170$1@newsgroups.borland.com> <441516f5$1@newsgroups.borland.com> <4415eebd$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,bb5b2339083fb22b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "saravanan" <asaravanan@ften.com> From: "saravanan" <asaravanan@ften.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <440ee66c@newsgroups.borland.com> <440f21ca$1@newsgroups.borland.com> <441004a5$1@newsgroups.borland.com> <44109fc6$1@newsgroups.borland.com> <441117a4$1@newsgroups.borland.com> <4411d170$1@newsgroups.borland.com> <441516f5$1@newsgroups.borland.com> <4415eebd$1@newsgroups.borland.com> Subject: Re: Application ProcessMessages Date: Mon, 13 Mar 2006 22:19:57 -0800 Lines: 122 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 NNTP-Posting-Host: 203.199.207.189 Message-ID: <4416608c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1142317196 203.199.207.189 (13 Mar 2006 22:19:56 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail