Results 1 to 2 of 2

Thread: Anything like a doevents function?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    I am trying to make a stopwatch program...but I keep freezing the program (at least it doesn't freeze C++ like VB froze itself)...

    This is the code that does the actual time management:
    PHP Code:
    Pause(50000);
                    
    int active 1;
                    
    int milli 0;
                    
    int secs 0;
                    
    int mins =0;

                    while(
    active==1)  {
                        
    milli++;
                        if(
    milli>=10) {
                            
    milli=0;
                            
    secs++;
                        }
                        if(
    secs>=60)  {
                            
    secs=0;
                            
    mins++;
                        }
                        
    char buf[40];
                        
    int m milli;
                        
    itoa(mbuf10); // 10 is the radix (number base)
                        
    SendMessage(ghWnd_milliWM_SETTEXT0, (LPARAM) (LPCTSTRitoa(mbuf10));
                        
    int s secs;
                        
    itoa(sbuf10); // 10 is the radix (number base)
                        
    SendMessage(ghWnd_secsWM_SETTEXT0, (LPARAM) (LPCTSTRitoa(sbuf10));
                        
    int mi mins;
                        
    itoa(mibuf10); // 10 is the radix (number base)
                        
    SendMessage(ghWnd_minsWM_SETTEXT0, (LPARAM) (LPCTSTRitoa(mibuf10));


    //=======NOW IS A PAUSE FUNCTION=========
    void Pause(unsigned long amount)
    {  
    //creates a delay with the duration of amount.
      
    unsigned long t GetTickCount();
      while((
    GetTickCount() - t) < amount);

    how do I stop it from freezing?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    For the equivalent of DoEvents, use Sleep(0).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width