Hello i'm using a neverending loop to read informations from the COM but the problem is that the reading process blocks my aplication. Not to listen to the COM all the time is not an option. What should I do to use the aplication in this time?
AfxBeginThread(MyThread,this);// Your call to start the thread.<br />
UINT MyThread(LPVOID lp)<br />
CCOMPROG* obj = (CCOMPROG*)lp; //To access the ReadCOM function, or you can pass any function, with using the void pointer.<br />
obj->ReadCOM(); <br />
Thanks a lot I folowed your code but ended up with the folowing error message : error C4716: 'CMina_sView::MyThread' : must return a value; i tryed to insert a return 0 or return TRUE but that wasn't much of a help as I got the same result: program blocked. so??!?
I'm afraid someone will have to get killed. ) Let me tell you how i modified your code:
1) I use an OnListenComm() function that is as the name tells us: a function auto-defined by VC++ that handles the code when you click on listencom button.
AfxBeginThread(MyThread,this);// Where should i put this???????
UINT CMina_sView::MyThread(LPVOID lp)
CMina_sView* obj = (CMina_sView*)lp; //To access the ReadCOM function, or you can pass any function, with using the void pointer.
It depends on when you want to start the thread. For example, you have CButton , If you wanna start listening to COM on the click of it, put the AfxBeginThread inside the OnClick Event of the CButton. You can do that anywhere.
You can also poll the COM port; this isn't necessarily the nicest design, but it may work. See the function SetCommTimeouts to set read timeouts. In fact, you may want to do this in either case; your thread can block reading the port and wake up every 1s to check if it is time to quit the application.
Save yourself a bunch of hassle and do a bit of reading about thread safety issues now before you do a bunch of work.
Try searching CodeProject for "video capture" or "webcams" - look for a sample application which captures frames of video to memory.
If you set the webcam / capture routine to capture 8-bit Black & White (monochrome), these captured images are really just 2D arrays of intensity (for 8-bit monochrome, each pixel is an intensity value in the range 0 to 255.)
If you capture in colour, you will have to convert the colour information of each pixel to an equivalent intensity value. I'd guess there are libraries to do that sort of thing.
Find a suitable project to start with, try playing around, then ask specific, detailed questions about any problems you encounter.
I have created a property sheet wizard using the below procedures:
Projects >> Add to Project >> Components & Controls
Select the Directory Visual C++ Components
Select the Property Sheet Component
Click the Insert Button.
Problem is that wizard is displaying a "help" button which i want to make invisible.Can anyone kindly tell me how to make the help button invisible.
Last Visit: 31-Dec-99 18:00 Last Update: 1-Aug-21 14:03