Using the Main ActiveX Control in VC++ .NET

  1. Open .NET and create a new Visual C++ MFC Application that is Dialog Based and uses MFC in a shared DLL. Take the defaults for everything else. Name the project “Tutor

  2. Once the main dialog appears, right click the dialog and select “Insert ActiveX control…” From the list of ActiveX Controls select “LEAD Main Control” and click okay.

  3. Right click the control on the dialog and select “Add Variable…” Name the variable “m_Lead1” and click okay.

  4. Open the header file “stdafx.h” and at the end of the file add the following line of code:

#import "LTOCXU.ocx" no_namespace, named_guids, exclude("ReadyStateConstants")

  1. Open the *.h file TutorDlg.h. Add the public variable: _DLeadPtr m_pLead1;

  2. Open the *.cpp file TutorDlg.cpp. In OnInitDialog add the code:

m_pLead1 = m_Lead1.GetControlUnknown();

m_pLead1->Load(“D:\\Test\\Test.jpg”, 0, 0, 1);

  1. Compile and run your code. You should see an image when the dialog appears.

  2. In this code you will use the m_pLead1 variable when calling any property or method. Follow the same procedure to add other controls to the form.