Setting focus on a window

This is a discussion on Setting focus on a window within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm having a problem with my program freezing up. In my program I call the URLDownloadToFile function to download ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    112

    Setting focus on a window

    Hi, I'm having a problem with my program freezing up. In my program I call the URLDownloadToFile function to download a file. The only problem is that the program locks up until the download is finished. The problem is that the function doesn't return until the download is done. Is there a command I can call inside the URLDownloadToFile function so that the program doesn't lock up. I've tried SetFocus but that doesn't seem to do anything.

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Im new to programming things over a network or internet but are you using sockets? If not id suggest you look into using winsock b/c it will help out with what u want. Seach this board for "winsock" or "sockets" and you will find what you want.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Create a seperate thread for the download and give the main user interface thread prority.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    I had exactly the same problem about a year ago, and i got around it with a seperate thread. A thread runs code seperatly away from your main program code. Heres a small example:

    Code:
    //Define your thread function and put all your code that you 
    //wanna run independantly from your program.
    
    DWORD ChildProcId;
    
    DWORD WINAPI ThreadP(HWND hWnd)
    {
    
    //Your code here.....
    
    ExitThread(TRUE);
    return 0;
    }
    
    
    CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadP, hWnd, 0, &ChildProcId);

    Hope that helps,
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    OK, thanks for the help. Ignore the post below I was way off but I figured it out by looking at msdn.
    Last edited by pinkcheese; 04-02-2002 at 11:26 PM.

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    Figured it out
    Last edited by pinkcheese; 04-02-2002 at 11:26 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21