Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters
Register

Reply
 
LinkBack Thread Tools
Old 30.01.2002, 00:35   #1
Студент
 
Join Date: 01 2002
Location: Yerevan, Armenia
Age: 37
Posts: 282
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Red face 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.

thx
__________________
Сколько времени и сил должен потратить мужчина,
Чтобы воспользоваться минутной слабостью женщины
Reply With Quote
Old 30.01.2002, 02:44   #2
Moderator
 
acid's Avatar
 
Join Date: 09 2001
Location: South Korea, Gumi
Posts: 7,699
Downloads: 102
Uploads: 34
Blog Entries: 16
Reputation: 561 | 6
Post

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.
Reply With Quote
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 10:49.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.