![]() |
How to use ActiveX in VC (Visual C++) | |
|
Let UltimaSerial unleash the power of your Windaq Starter kit!
Lessons on how to use UltimaSerial
|
The following is a step-by-step lesson on how to use ActiveX in Visual C++ (VC++) In this lession, we will use Ultimaserial ActiveX to develop a data acquisition application with DATAQ's Starter kit. Specification of the sample program: a) Acquire voltage signal between -10 to 10V via
Channel 1 of DI-194 at a rate of 240
Samples/second Here, we will create a Windows dialog-based Visual C++ program to acquire data from the DI-194 via COM 1. The program will start to acquire data as soon as the it is started, you can push the Cancel button to exit the program. Before we start, please download and install UltimaSerial then run Microsoft Visual C++. 1) Start Visual C++, and follow File->New 2) In the dialogue box New, choose Projects Tab 3) Select MFC AppWizard (exe), Fill in the name "Ultima" in project name and hit OK 4) Select Dialogue-based for "What type of application would you like to create?", then hit Finish. 5) Hit OK to create the project files. 6) If you see a dialoge box template labled as Ultima on your screen, you can proceed to Step 11) 7) From Workspace pane, select Resource 8) Click on the + sign in front of Ultima resources and you should see the folder labled as Dialog 9) Click on the + sign in front of the folder Dialog, and you should see IDD_ULTIMA_DIALOG. 10) Double-click on IDD_ULTIMA_DIALOG and you will see the dialoge box template labled as Ultima on your screen 11) Move the cursor to the dialog box template Ultima, and click the right button on your mouse, and follow Insert ActiveX Control ... 12) In several seconds, you will see a dialog box labeled as Insert ActiveX Control 13) Double click on DQChart Control in the list (If you don't see this control in the list, you need to install UltimaSerial.) 14) Repeat 11-13) to insert UltimaSerial Control 15) Remove the OK button and the "TODO Place dialog controls here" text from the dialog box. Also, resize/re-arrange the objects on the dialog box if you like 16) Follow View->ClassWizard ... to bring up the MFC ClassWizard 17) From the Member Variables tab of the MFC ClassWizard, Double-click on IDC_DQCHARTCTRL1, and the Wizard will ask if it is OK to generate a C++ wrapper class for it 18) Select OK to create the wrapper class for DQ Chart Control. When the Add Member Variable dialog box comes up, set the member variable name to m_dqchart 19) Repeat 16-18) to add a member variable m_ultima for IDC_ULTIMASERIALCTRL1 20) Hit OK to exit MFC ClassWizard 21) On the dialog box template Ultima, right-click on UltimaSerial control and follow Events... 22) You will see a dialog box labled as New Windows Message and Event Handlers for CUltimaDlg. 23) Double-click on NewData under New Windows messages/events list, then hit OK to use the default name 24) Hit OK to exit the dialog box New Windows Message and Event Handlers for class CUltimaDlg 25) From the Workspace pane, follow FileView tab, and open UltimaDlg.cpp 26) Add the follow codes to BOOL CUltimaDlg::OnInitDialog(), right after the comment // TODO: Add extra initialization here (If you decide to type in the codes, you will notice the properties and methods will be displayed in a drop-down menu once you typed in m_ultima.)
27) Add the follow codes OnNewDataUltimaserialctrl1(short Count)
Last update: 10/05/07 Copyright: 2000-2005 www.UltimaSerial.com
|
|