Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
First project
Message
Information générale
Forum:
Visual C++
Catégorie:
ActiveX
Titre:
Divers
Thread ID:
00023507
Message ID:
00024609
Vues:
40
>>>>>OK, so here I go, first project, an ocx. Specialized dial-up serial communications. I've got the *Circle* tutorial and high hopes :) Any words of wisdom before I start ??
>>>>>
>>>>>TIA
>>>>Have you built a class to wrap the COMM APIs?
>>>
>>>No ! Thanks for the warning. I have not gotten that far yet. Still trying to understand the basics of the *Circle* tutorial.
>>
>>Currently I am working on a communication project and in the process of building a class for Win32APSs. You can can't build a good COMM OCX without first building and tesing it in MFC. This is complicated topics and Involves multi-thread programming. The ideal is to create a worker thread to monitoring the the port while you can do other things in main thread.
>
>This is all very new to me, so I hope you don't mind some questions.
>Do you then use a synchronization class ? Should you transmit and receive in the worker thread, or separate them ?
>
>I have a dial-up type need. Once connected, I follow a 10 step protocol to communicate with a device. This would be very easy in VFP, as a class, using a MSComm.ocx. Because I want to be able to use the same object in VB, I were going to write this as an ocx, to aviod maintaining VFP and VB versions. Also, the C++ learning is a good. :)
>
>Joe recomended several books in an earlier thread, that I have ordered, and have not arrived. Do you have a fovorite, that deals specifically with multi-thread in C++ ?
>
>I am not on any deadline, just learning, for the experience.
>
>Thanks,


Yes, I do use a synchronization class CEvent. this is necessary in this application. Right now the class only handle monitoring, receice in a worker thread. I will improve the class so that it can handle write also. I think the wrting would probably be handled in the same thread because the class is intended as a resuable object- MFC extension class. I learn a lot though this project. The point is to try use the latest C++ feature. It might qicker to write COMM app use C style API, but you may end up spending a lot more time to improve and expend you apps. A COMM sample that comes with C++ is a C style app. You may find how hard to reuse the code except copying . If we had a well-designed a class, what we need to in order to use the comm function probably is to change some data member or drive a new class from it.

The book that may help you regarding thread is Jeff Prosise's Programming Window'95 with MFC from Microsoft Press. It contain a chapter devoted to multi-thread. The contents is enough to apply to COMM app include monitoring, read and write.

Right now you use MSCOMM OCX control how you handle the situation when your program can get through the connection?. If it is a single threaded, your whoel program has to wai untile it can get through. With multi-threaded, you can do other thing such as switch to another menu or so. A sample that come with C++ is very helpful to understand Multi-threaded programming with MFC, --MFC advanced sample--MTRECALC ALC, although it is not comm-oriented.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform