Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: MFC VC++
hi guys,

i am using one while loop that should run till i press another button. that button member variable of type CButton ,and member variable name is m_stopvoice .
so i am writing like

if i press that button my execution should break from the while loop ...Is it the correct approach ....thanks in advance for valuable comment .....
Posted 20-Jun-12 21:54pm
Member 9102753 at 21-Jun-12 4:00am
Please Reply for the above query ...
Richard MacCutchan at 21-Jun-12 4:02am
Be patient, people answer in their own time and at no cost to you.
Richard MacCutchan at 21-Jun-12 4:03am
Why are you checking for the Window's enabled status rather than reacting when it's pressed?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

When using infinite loops with Windows GUI application, you must ensure that Windows messages are processed during loop execution. If not, you can't check for events like pressed button.
The common approach to realize such loops is using them inside an own thread (worker thread if no GUI operations must be performed from inside the loop). While the worker thread is running it should check for a terminate event that is signaled by the main thread when the button is pressed or your application terminates.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web04 | 2.8.150302.1 | Last Updated 21 Jun 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100