|
Mmh, yes, I was not sure about this so thanks for correcting me (in fact I never really played directly with WM_PAINT messages).
Well, then I think a better approach would be to send a user defined message and in the handler of this message, call Invalidate() to force the redraw.
|
|
|
|
|
Cedric Moonen wrote: I think a better approach would be to send a user defined message and in the handler of this message, call Invalidate() to force the redraw.
Absolutely.
But, as Luc also made a point of, it's not necessary to update the UI faster than the user can cope with.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
IMO my timer-based GUI update suggestion did not get adopted because it got called "polling" at one point (mind you, not by me) and "polling is bad" as we all know. But I would rather do something every 100 msec all the time, than have it requested by some background threads as often as they can.
And obviously, one can start and stop the "polling" timer at a higher level (say when the background threads start/stop). So "smart polling" could avoid a lot of trouble and save many many CPU cycles.
|
|
|
|
|
Luc Pattyn wrote: IMO my timer-based GUI update suggestion did not get adopted because it got called "polling" at one point (mind you, not by me) and "polling is bad" as we all know. But I would rather do something every 100 msec all the time, than have it requested by some background threads as often as they can.
Agreed.
I suggested something similar in this post above[^] where I actually used the phrase "poll".
There's no point in updating the UI faster than the user has a remote chance of keeping up with. I would have the worker thread do more work before it "reports"; I mean if you hire a carpenter to do a job, you don't expect him to tell you "now I've picked up my screwdriver" and so on. You want to know when the job is done, or if he for some reason cannot do the job.
(Another one of my carpenter analogies.... )
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Cedric,
Thanks for the response. When I wrote, reapint the window, I meant by that was to generate a WM_PAINT message. Polling seems inefficient to me and some what backwards. However, I suspect that in many cases it is the way to go.
Bob
|
|
|
|
|
Okay, but I think you should think real hard about what a "simulation" is.
Again, this is based on the little information you've given, but I would consider the process of doing the 10,000 times repetitive thing a "simulation". When that work is done, in the worker thread, you alert the UI thread and display the results. During the computation you have some UI object, such as a progress bar, to inform the user that his "financial process" is being simulated.
Regarding your question about problems with your code snippet, I think Cédric made a good point, apart from the WM_PAINT stuff.
But while we're at it, I recommend you to not use the MFC versions of synchronisation objects like CCriticalSection, read more here[^].
And you would also benefit from reading this[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Windows 2000/XP: There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.
MSDN - PostMessage
|
|
|
|
|
Thanks for the response. On my system, there is no registry key: USERPostMessageLimit. By any chance, do you know what the default value for the size of the queue. It really seems that their should be a call to find out how big it is, and how many messages are currently in it.
In any case, I have decided to use a different approach in returning results from my threads.
Bob
|
|
|
|
|
I once worked on a project where we used the message queue for sending results to the GUI thread.
We first tried to use an atomic counter to control how many results there was in the message queue (max 1000). And then throttled the worker threads when they were sending results faster than the GUI thread could handle. This also ensured that we wouldn't take all memory available when there was many results.
We ended up with creating a special container, where one could push and pop resuls atomicly. And instead used the message queue to signal that the container changed state from empty to containing messages. And container stopped the worker threads with an event mutex, when the message limit (1000) was reached, and this event-mutex was signalled when the GUI thread had got the message count below 500. We changed to this solution because it was kind of a misuse of the message queue to contain our results, eventhough it was an easy way to get a thread-safe queue.
Guess right solution is not use the message queue at all, but check another queue when the GUI thread is in idle-state. And an even faster solution would be to let the container to have its own memory ¨
manager, where it reuses the allocated results, instead of constantly releasing and allocating results when popping and pushing.
|
|
|
|
|
I want to display HTML links inside edit control.
Single control need to have few hyperlinks separated for which display text is different from target URL.
While right clicking on it, it need to launch default browser.
Thanks in Advance
|
|
|
|
|
Not quite sure where the question is here. It sounds like you're telling us about your day.
Assuming you're needing some help with this...
http://www.codeproject.com/KB/static/pphtmlstatic.aspx[^] should be of some help to you.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi Thanks for quick help!!
I think the same can be done in edit control.
Will check it.
Thanks!!
|
|
|
|
|
sabapathy_80 wrote: I think the same can be done in edit control.
Not with a normal edit control. You'll need to use a rich edit control instead.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi, I can display a single link now by that article, but I am trying to display more than one "HTML" link in single control.
Is there any article on the same?
Thanks..
|
|
|
|
|
sabapathy_80 wrote: ...but I am trying to display more than one "HTML" link in single control.
Is there any article on the same?
See here.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks.. I'll look in it..
|
|
|
|
|
Take a look at this[^], might be usefull.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
|
found florin visalescu's code on the screen color picker: http://www.codeproject.com/KB/GDI/screencolorpicker.aspx?msg=2871007#xx2871007xx
what code do i use to actually "show" the color that the pointer is over?
Thank you!
|
|
|
|
|
|
I did. I just wanted to increase my chances of a response.
|
|
|
|
|
this is called cross-posting, and generally not well seen.
moreover, you had all the infos you needed, if only you'd read the article entierly...
|
|
|
|
|
You have to combine the code snippets provided in article.
HDC hDC;
hDC = CreateDC("DISPLAY",0,0,0);
CPoint point;
GetCursorPos(&point);
COLORREF color;
color = GetPixel(hDC,point.x,point.y);
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
I want to Invoking a Web Service using Visual C++ .NET. Please provide me with information.
I have sample code to invoke web service using c#. The web service method has complex data as input. Please reply.
|
|
|
|