Click to open or copy the VCTERM project files.
The VCTERM sample is a simple terminal emulation program illustrating the use of the Mscomm32.ocx ActiveX Control. It illustrates how to use the Communications control with a serial port. The Communications control allows you to open a serial port, change its settings, send and receive data through the port, and monitor and set many of the different data lines. This particular sample is a direct spin-off of the VBTERM sample application that ships with Visual Basic, and mirrors its functionality closely.
This sample does not use the document/view architecture of the Microsoft Foundation Classes. The initial application was generated with the AppWizard as an MFC SDI-type application, but the document and view classes were then removed because they are not needed.
The Mscomm32.ocx ActiveX Control is created dynamically at runtime as a data member of the CMainFrame class. The creation code is located in the CMainFrame::OnCreate function.
An edit control is parented off of the CMainFrame window and is the interface for displaying the text that is sent and received via the Mscomm32.ocx control. The edit control is resized by overriding CMainFrame::RecalcLayout.
This sample also illustrates how to create a modeless status dialog capable of canceling an operation. The CCancelDlg class is a modeless dialog class, and simply signals the CMainFrame to stop transmitting data. The interesting code is in the CMainFrame::OnFileTransmit function. Note the calls to the DoEvents function, which processes all pending messages in the applications message queue.
You will need to have either a modem attached to your computer's serial port, or have two computers connected via a null-modem cable. Some of the modem commands that are hard-coded into this sample might not work with some modems. There are notes in the source code to point out where modem commands might need to be modified to work with a particular modem. Please consult the documentation included with your modem to determine the appropriate command strings to send to your modem.
After you have connected a null-modem cable to your computers, simply build and run the sample. Select the desired port settings (settings should be identical across both machines) and open the port. At this point, text typed into the edit window of the VCTERM application should appear in the Edit window of the VCTERM application running on the other machine.
Note This sample does not support the downloading of files. It also does not support the transmitting of binary files. VCTERM supports transmitting ASCII text only.