Join Date: 01 2002
Location: Yerevan, Armenia
Uploads: 0Reputation: 0 | 0
2 Questins too.
1st one: who worked with double buffering and how achieve this simultaneous thing:<BR>reading data from file into the buffer, and at the same time playing data from another buffer. As i understand i've to use threads.<BR>Please tell me about double buffering, and how acheive it.
2nd one: i'm using MFC, then my dialog has to handle some king of messages which is not included in the ClassWizard's Message List.<BR>How i could handle them in MFC, like i'm doing in WinMain() of API Win32.
Сколько времени и сил должен потратить мужчина,
Чтобы воспользоваться минутной слабостью женщины
Join Date: 09 2001
Location: South Korea, Gumi
Blog Entries: 16
Uploads: 34Reputation: 561 | 6
1. Yes you've got to use threads. Either you can use CWinThread or just Win32 api. I'll explain very briefly the simple way to make what you want.
Make some "Events" using CreateEvent and set the state of this event to non-signaled.
Make two functions which will be the "working thread functions" and assign some buffering routines to that functions. Arrange some loop in those functions and put your "event signaled" state as break condition of that loop. You can use WaitForSingleObject.
Use _beginthread from you main place to create all the threads you need by putting those created function addresses as last parameter.
Now you must have all your threads working and doing their job.
Whenever you want to stop them change the state of your event to signaled and those functions will respond to it by closing up all the job.
Again, that was very briefly and I didn't went too much deep into details.
2. Well, it's up which kind of messages you desire to handle. First if you don't see your messages in class wizard, open your workspace, right click on the class name, you will see "Add windows message handler" and you will see other way to add message handlers. Don't forget to change filter in that dialog box to see more messages. Next way is adding them manually - you have to follow instruction for each message personally because there is no common way to do that. Search for keywords beginning with ON_..., put declaration in header file, put message name in BEGIN_MESSAGE_MAP(...) and finally put function body into code, all according to documentation for that message.
Hope it helps.