Thread View: borland.public.cppbuilder.nativeapi
14 messages
14 total messages
Started by saravanan
Wed, 08 Mar 2006 14:13
Application ProcessMessages
Author: saravanan
Date: Wed, 08 Mar 2006 14:13
Date: Wed, 08 Mar 2006 14:13
9 lines
1193 bytes
1193 bytes
Hi Is there any way to skip the message posted to a specific handle being processed, when invoking Application->ProcessMessage. In PeekMessage call, we can just filter the range of messages. Is there any way to filter out the messages not posted to a specific handle. Regards, Saravanan A
Re: Application ProcessMessages
Author: Remy Lebeau (TeamB)
Date: Wed, 08 Mar 2006 18:23
Date: Wed, 08 Mar 2006 18:23
18 lines
1452 bytes
1452 bytes
"saravanan" <asaravanan@ften.com> wrote in message news:440ee66c@newsgroups.borland.com... > Is there any way to skip the message posted to a specific > handle being processed, when invoking Application->ProcessMessage. Use the TApplication::OnMessage event. The handler handler has a Handled parameter that you can set to true on a per-message basis. > Is there any way to filter out the messages not posted to a specific handle. The hwnd member of the MSG structure should be NULL for any message being posted to the thread itself rather than a specific window. Gambit
Re: Application ProcessMessages
Author: saravanan
Date: Thu, 09 Mar 2006 10:34
Date: Thu, 09 Mar 2006 10:34
36 lines
1897 bytes
1897 bytes
Hi,
There is a thread in my application which does PostMessage to main
thread as and when new information is available from the server. In my main
thread, there are some operations which takes more time. Because of this,
screen paint was not happening. So i added Application->ProcessMessages.
For Example,
Main Thread :
void Function () {
Operation 1 --> Take 1 sec to execute
Application->ProcessMessage () ; //..This line is added to force the
screen paint
Operation 2--> Take 1 sec to execute
Application->ProcessMessage () ;
Operation 3--> Take 1 sec to execute
Application->ProcessMessage () ;
}
Seperate Thread :
{
while ( OnData () ) {
Post Message to main thread
}
}
My Problem is Application->ProcessMessage should serve only the Painting
operation and not the Data Posted from Seperate Thread. How to do this ?
Regards,
Saravanan A
Re: Application ProcessMessages
Author: Mark Jacobs
Date: Thu, 09 Mar 2006 11:11
Date: Thu, 09 Mar 2006 11:11
12 lines
1469 bytes
1469 bytes
"saravanan" <asaravanan@ften.com> wrote in message news:441004a5$1@newsgroups.borland.com... > My Problem is Application->ProcessMessage should serve only the Painting > operation and not the Data Posted from Seperate Thread. How to do this ? Use Repaint() or Update() instead of processmessages, unless you hope to catch keystrokes during these operations in case an abort is signalled. -- Mark Jacobs DK Computing http://www.dkcomputing.co.uk
Re: Application ProcessMessages
Author: saravanan
Date: Thu, 09 Mar 2006 11:37
Date: Thu, 09 Mar 2006 11:37
8 lines
1350 bytes
1350 bytes
Hi Repaint methods can be used to repaint a control but how to paint all unpainted controls? ProcessMessage will process paint messages for all control. Regards, Saravanan A
Re: Application ProcessMessages
Author: Remy Lebeau (TeamB)
Date: Thu, 09 Mar 2006 21:37
Date: Thu, 09 Mar 2006 21:37
38 lines
1971 bytes
1971 bytes
"saravanan" <asaravanan@ften.com> wrote in message
news:441004a5$1@newsgroups.borland.com...
> In my main thread, there are some operations which takes more
> time. Because of this, screen paint was not happening.
Then you should probably move those operations into their own thread as
well.
> void Function () {
>
> Operation 1 --> Take 1 sec to execute
> Application->ProcessMessage () ; //..This line is added to force the
> screen paint
If all you want to do is update the GUI display, without actually processing
user actions yet, then you can use the form's Update() method instead.
> My Problem is Application->ProcessMessage should serve only the
> Painting operation and not the Data Posted from Seperate Thread.
Then use Update() instead of ProcessMessages().
void __fastcall TForm1::Function()
{
Operation1();
Update();
Operation2();
Update();
Operation3();
Update();
}
Gambit
Re: Application ProcessMessages
Author: saravanan
Date: Fri, 10 Mar 2006 06:07
Date: Fri, 10 Mar 2006 06:07
11 lines
1298 bytes
1298 bytes
Hi > Then you should probably move those operations into their own thread as well. okay. Update function just paints the current form and not all the forms in the application. I need to paint all the forms which needs painting. Regards, Saravanan A
Re: Application ProcessMessages
Author: Remy Lebeau (TeamB)
Date: Fri, 10 Mar 2006 19:21
Date: Fri, 10 Mar 2006 19:21
34 lines
1734 bytes
1734 bytes
"saravanan" <asaravanan@ften.com> wrote in message
news:441117a4$1@newsgroups.borland.com...
> Update function just paints the current form and not all
> the forms in the application.
Correct.
> I need to paint all the forms which needs painting.
Then you would have to loop through the global TScreen::Forms[] array, ie:
void __fastcall UpdateAllForms()
{
for(int i = 0; i < Screen->FormCount; ++i)
Screen->Forms[i]->Update();
}
void __fastcall TForm1::Function()
{
Operation1();
UpdateAllForms();
Operation2();
UpdateAllForms();
Operation3();
UpdateAllForms();
}
.
Gambit
Re: Application ProcessMessages
Author: saravanan
Date: Mon, 13 Mar 2006 06:53
Date: Mon, 13 Mar 2006 06:53
9 lines
1505 bytes
1505 bytes
Hi, 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. I am repainting the 2 windows which doesn't require painting. Already OS is taking care of painting the necessary area only, i think we are ignoring that optimization or performance. Saravanan A
Re: Application ProcessMessages
Author: Mark Jacobs
Date: Mon, 13 Mar 2006 10:29
Date: Mon, 13 Mar 2006 10:29
16 lines
1788 bytes
1788 bytes
"saravanan" <asaravanan@ften.com> wrote in message news:4410136f@newsgroups.borland.com... > Repaint methods can be used to repaint a control but how to paint all > unpainted controls? ProcessMessage will process paint messages for all > control. Erm, Repaint() is called for the form and that repaints the entire form. If I had prefixed Repaint() with something like MyComponent->Repaint(), I agree, that would just repaint that component, but I didn't. Use Repaint() and the entire form will repaint. -- Nah, just fooling wiv yer! Mark Jacobs DK Computing http://www.dkcomputing.co.uk
Re: Application ProcessMessages
Author: Mark Jacobs
Date: Mon, 13 Mar 2006 10:33
Date: Mon, 13 Mar 2006 10:33
18 lines
1972 bytes
1972 bytes
"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. I am > repainting the 2 windows which doesn't require painting. Already OS is > taking care of painting the necessary area only, i think we are ignoring > that optimization or performance. Internally, Windows knows what is showing and what isn't. If you ask it repaint all your forms, it probably won't do very much for forms that aren't showing. I wouldn't worry about this optimisation. Remy's solution is correct for your problem. -- Nah, just fooling wiv yer! Mark Jacobs DK Computing http://www.dkcomputing.co.uk
Re: Application ProcessMessages
Author: Remy Lebeau (TeamB)
Date: Mon, 13 Mar 2006 22:14
Date: Mon, 13 Mar 2006 22:14
64 lines
2921 bytes
2921 bytes
"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
Re: Application ProcessMessages
Author: 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
>
>
Re: Application ProcessMessages
Author: saravanan
Date: Wed, 15 Mar 2006 13:47
Date: Wed, 15 Mar 2006 13:47
1 lines
1257 bytes
1257 bytes
Help me out to solve this problem
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads