Getting started using Visual C++

  1. In Visual Studio .NET, select [Create a new project].
  2. Select [Visual C++]-[CLR]-[CLR Empty Project (.NET Framework)].
  3. Select [Project]-[Add Reference].
  4. In the [Browse] tab, select the "RCAPINt2.dll" file under the "\API" directory.
    • .NET Framework : \Assembly\net462
    • .NET6 : \Assembly\net6.0-windows
  5. Select the menu-[Project]-[Add New Item]-[UI]-[Windows Form].
  6. Open the cpp file (ex: Form1.cpp) of the added form and add the following source code.
#include "Form1.h"  

 using namespace SampleProject; // Name of the created project
 void main() {
    Application  EnableVisualStyles();
    Application  SetCompatibleTextRenderingDefault(false);

    Form1 frm; // Name of added form
    Application Run(% frm); 
 }
  1. Select the menu-[Project]-[Project Properties].

  2. Select [Configuration Properties]-[Linker]-[System] on Property Pages and select “Windows (/SUBSYSTEM:WINDOWS)” on SubSystem.

  3. Select [Configuration Properties]-[Linker]-[Advanced] on Property Pages and enter the function name that is added in the step 6 in “Entry Point”. In here, “main” is entered.

  4. Click the [OK] button.

KEY POINTS


After configuring the setting, build the solution once and make sure that no error is occurred. Then, we recommend that you close the solution and reopen it.

  1. In the Form1 class, declare a Spel variable as shown below.
private:RCAPINet::Spel^ m_spel;  
  1. In the Form_Load event, add initialization code, as shown below.
private:System::Void Form1_Load(  
   System::Object^ sender, System::EventArgs^ e)  
{  
   m_spel = gcnew RCAPINet::Spel();  
   m_spel->Initialize();  
   m_spel->Project =  
      "c:\\EpsonRC80\\projects\\ API_Demos\\Demo1\\demo1.sprj";  
   m_spel->EventReceived += gcnew  
      RCAPINet::Spel::EventReceivedEventHandler(  
      this, &Form1::m_spel_EventReceived);  
}
  1. Add the event handler, as shown below.
private:System::Void m_spel_EventReceived(  
   System::Object^ sender, RCAPINet::SpelEventArgs^ e)  
{  
   MessageBox::Show(e->Message);  
}  

KEY POINTS


When your application exits, you need to delete each Spel class instance if it was allocated on the heap (using gcnew). This can be done in your main form's FormClosed event. If the Spel class instances are not deleted, then the application will not shutdown properly.

delete m_spel;