I am a beginner at MFC and I am going to make a simple game with some card images.
When I click a button, the cards have to appear in the window with an apposite animation.
I had made animation in a function to the following:
But while the animation is playing, I can't do anything neither click button nor chat. So I have a decision to make an animation thread. However the Device Context (dc) is the biggest problem because the main thread and animation thread will control one dc together.
What can I do for solving this problem? Help me. Thank you.
Or you could make it so the function doesn't hang but instead use a timer to see how long has actually passed and if the desired amount of time has passed then do what ever.
I am sorry about the late reply.
You are right. I want to make a multithreading program.
So I am going to process window messages and bitmap animations at one time side by side.
// thread example
#include <iostream> // std::cout
#include <thread> // std::thread
void foo()
{
// do stuff...
}
void bar(int x)
{
// do stuff...
}
int main()
{
std::thread first (foo); // spawn new thread that calls foo()
std::thread second (bar,0); // spawn new thread that calls bar(0)
std::cout << "main, foo and bar now execute concurrently...\n";
// synchronize threads:
first.join(); // pauses until first finishes
second.join(); // pauses until second finishes
std::cout << "foo and bar completed.\n";
return 0;
}
main, foo and bar now execute concurrently...
foo and bar completed.