Thread: Stop button doesnt stop a function (using PostMessage)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    416

    Stop button doesnt stop a function (using PostMessage)

    I'm trying to make a function that will scan through the files that are in a directory of the users choice to search for a certain file. However, the stop button I tried to make doesn't actually work. It's not even possible to do anything while it's searching, including closing the program. I'm using PostMessage() to go through the process one file at a time, hoping that after each file the user could have the option to stop it. Unlike having SendMessage where the user definitely cannot do anything until it's finished. Is there a different route to take so I can stop it in mid search?

    Here is what I think is causing the problem.

    Code:
            //update what the user sees
            SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Scanning..");
    
            //update percentage
            percent = 100*(sofar/total); //get the total percent
    
            itoa(percent,Percent,10);   //change the integer percent to string
    
            strcat(Percent,"%"); //add percent sign to percentage
    
            char OverAll[MAX_PATH] = "Progress: "; //reset the overall progress
    
            strcat(OverAll,Percent); //set overall percentage
    
            SendMessage(hStatus, SB_SETTEXT, 1, (LPARAM)OverAll); //display overall percentage
    
            PostMessage(Hwnd,WM_COMMAND,SCAN,0); //repeat the process
    EDIT: just tried using Sleep(500) and it still has the same problem. I clicked the stop button really fast hoping I'd catch it, but nothing. I also can't regain focus of the window.
    Last edited by scwizzo; 03-06-2008 at 11:15 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM