![]() | |
| |||||||
| Home | Register | Blogs | FAQ | Members List | Calendar | Downloads | Arcade | Mark Forums Read |
| Languages, Compilers and Interpreters C,C++,C#,.NET,Java,PHP,Perl,SQL and more |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Студент | 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. thx
__________________ Сколько времени и сил должен потратить мужчина, Чтобы воспользоваться минутной слабостью женщины |
| | |
| | #2 |
| Administrator Join Date: Sep 2001 Location: South Korea, Gumi
Posts: 7,164
Blog Entries: 15 Rep Power: 10 Reputation:
298 | 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. |
| | |