Thread: How to make 2 threads that both will update one window?

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    12

    How to make 2 threads that both will update one window?

    I am making a program that creates a very large picture on the screen. The picture scrolls all by itself like a movie.

    The problem is that the code that generates this is in a loop in OnDraw, and as long as it's in it, I can't do anything else, like push a button on the screen, or click on a menu option.

    So I have to split the program into to threads. One thread will handle getting the picture onto the screen, and the other will handle the rest of the interface.

    I was thinking of taking the picture processing into the secondary thread, but that's when I get into trouble.

    I have made several threaded programs before, but no programs where the secondary thread need access to windows functions like BitBlt(....), SetPixel(....) and creating a bitmap memory. These are the functions that make the pixture apear on the screen.

    Does anybody have any idea of how I can attack this problem?

    Kristian

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Your are on the right track!

    Here are some resources for you to read. If you are having a specific problem, post it and the associated source.

    gg

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> how I can attack this problem?

    I have to concur with Codeplug, you haven't really given us a problem to solve.

    There is nothing espeacially magic about multithreading basic GDI stuff. You must be careful if you have more than one thread writing to the same part of the same DC, but that is true of any resource in a multithreaded program. You say you've done some threading, so you must be familiar with this.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. How to change window style at runtime?
    By Mr. Bitmap in forum Windows Programming
    Replies: 5
    Last Post: 06-09-2002, 04:49 PM
  5. how to make 2 text window
    By bluexrogue in forum C Programming
    Replies: 2
    Last Post: 09-15-2001, 08:51 PM