Click here to Skip to main content
16,006,001 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WM_MENUCOMMAND and menu items with no ID Pin
ns23-Jan-03 6:02
ns23-Jan-03 6:02 
GeneralRe: WM_MENUCOMMAND and menu items with no ID Pin
Roger Allen23-Jan-03 6:24
Roger Allen23-Jan-03 6:24 
GeneralRe: WM_MENUCOMMAND and menu items with no ID Pin
ns23-Jan-03 6:38
ns23-Jan-03 6:38 
GeneralRe: WM_MENUCOMMAND and menu items with no ID Pin
KaЯl23-Jan-03 23:17
KaЯl23-Jan-03 23:17 
GeneralThank you!!!! Pin
ns24-Jan-03 3:03
ns24-Jan-03 3:03 
GeneralARGH! trying to add a combobox Pin
Ron H.23-Jan-03 5:33
Ron H.23-Jan-03 5:33 
QuestionWM_TIMER in a MFC Console App.. Possible? Pin
RobJones23-Jan-03 5:23
RobJones23-Jan-03 5:23 
AnswerRe: WM_TIMER in a MFC Console App.. Possible? Pin
Gary R. Wheeler23-Jan-03 6:04
Gary R. Wheeler23-Jan-03 6:04 
In order to use WM_TIMER in a console app, you would need to create a hidden window and run a message loop. In other words, it wouldn't really be a console app; it would be a Windows application, whose main window was hidden.

A simpler solution that can be used in a console application is to use a thread that blocks on an event. The event is used to signal the thread to exit. When you block on the event (see WaitForSingleObject), specify a timeout period. The wait function returns what caused the wait to expire. In this case, the timeout is what you're interested in.

Here's an example:
static CEvent ThreadTerminate;
...
<this is the main line code>
...
UINT ThreadFunction(LPVOID parameter)
{
    CSyncObject     *wait_list[] = { &ThreadTerminate };

    for ( ; ; ) {

        CMultiLock wait(wait_list,countof(wait_list));

        DWORD wait_object = wait.Lock(1000,FALSE);

        if      (wait_object == WAIT_OBJECT_0) {

            // in this case, the thread should exit
            break;

        }

        else if (wait_object == WAIT_TIMEOUT) {

            // in here, do whatever needs doing on
            // the basis of the timer

        }

    }

    return 0;
}



Software Zen: delete this;
Generalwhat header do I use for countof() Pin
Anonymous23-Jan-03 7:52
Anonymous23-Jan-03 7:52 
GeneralRe: what header do I use for countof() Pin
Gary R. Wheeler23-Jan-03 10:21
Gary R. Wheeler23-Jan-03 10:21 
GeneralRe: what header do I use for countof() Pin
RobJones24-Jan-03 4:28
RobJones24-Jan-03 4:28 
GeneralOne more quick question.. Pin
RobJones24-Jan-03 7:01
RobJones24-Jan-03 7:01 
GeneralRe: One more quick question.. Pin
Gary R. Wheeler25-Jan-03 0:23
Gary R. Wheeler25-Jan-03 0:23 
GeneralKilling Connections Pin
OBRon23-Jan-03 5:01
OBRon23-Jan-03 5:01 
GeneralRe: Killing Connections Pin
Gary R. Wheeler23-Jan-03 6:19
Gary R. Wheeler23-Jan-03 6:19 
GeneralCapture screen Pin
jeremysay23-Jan-03 4:37
jeremysay23-Jan-03 4:37 
GeneralRe: Capture screen Pin
Paul M Watt23-Jan-03 5:05
mentorPaul M Watt23-Jan-03 5:05 
GeneralRe: Capture screen Pin
jeremysay23-Jan-03 5:26
jeremysay23-Jan-03 5:26 
GeneralRe: Capture screen Pin
Gary Kirkham23-Jan-03 6:05
Gary Kirkham23-Jan-03 6:05 
GeneralRe: Capture screen Pin
jeremysay23-Jan-03 21:14
jeremysay23-Jan-03 21:14 
GeneralRe: Capture screen Pin
Gary R. Wheeler23-Jan-03 6:24
Gary R. Wheeler23-Jan-03 6:24 
GeneralRe: Capture screen Pin
jeremysay23-Jan-03 21:15
jeremysay23-Jan-03 21:15 
GeneralWHQL: ChkINF fails with unknown error Pin
peterchen23-Jan-03 4:31
peterchen23-Jan-03 4:31 
GeneralRe: WHQL: ChkINF fails with unknown error Pin
Andreas Saurwein23-Jan-03 5:04
Andreas Saurwein23-Jan-03 5:04 
GeneralRe: WHQL: ChkINF fails with unknown error Pin
peterchen23-Jan-03 5:20
peterchen23-Jan-03 5:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.