// test3.cpp : main project file.

#include "Form1.h"
#include <stdio.h>
#include <tchar.h>
#include <string.h>

using namespace test3;



[STAThreadAttribute]

	void SrvrSession_OnLogin(int Result)
	{
		printf("\tOnLogin()\n");
//		return S_OK;
	}

		void SrvrSession_OnConnectionLost()
	{
		printf("\tOnLogin()\n");
//		return S_OK;
	}

void Form1::button1_Click(System::Object^  sender, System::EventArgs^  e) {
		SrvrSession = gcnew SrvrSessionClass();
		SrvrSession->OnLogin += gcnew _ISrvrSessionEvents_OnLoginEventHandler(SrvrSession_OnLogin);
		SrvrSession->OnConnectionLost += gcnew _ISrvrSessionEvents_OnConnectionLostEventHandler(SrvrSession_OnConnectionLost);
		SrvrSession->HostAddr = "10.200.200.201";
		SrvrSession->HostPort = 2900;
		SrvrSession->Name = "dim";
		SrvrSession->Password = "123";
		SrvrSession->Journal = "clients";
		SrvrSession->Connect();

}

void Form1::button2_Click(System::Object^  sender, System::EventArgs^  e){
		SrvrSession->Disconnect();
}



int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}





/*
// windowsforms.cpp : main project file.
//#include "stdafx.h"
#include "Form1.h"
#include <stdio.h>
#include <tchar.h>
#include <string.h>

//#import "progid:NiApi.SrvrSession" no_namespace


using namespace windowsforms;
using namespace NiApiLib;

	void SrvrSession_OnLogin(int Result)
	{
		printf("\tOnLogin()\n");
//		return S_OK;
	}


void Form1::btnConnect_Click(System::Object^  sender, System::EventArgs^  e) {
	NiApiLib::SrvrSession^ SrvrSession;
	SrvrSession = gcnew NiApiLib::SrvrSessionClass();

	SrvrSession->OnLogin += gcnew _ISrvrSessionEvents_OnLoginEventHandler(SrvrSession_OnLogin);
	SrvrSession->HostAddr = "10.200.200.201";
	SrvrSession->HostPort = 2900;
	SrvrSession->Name = "dim";
	SrvrSession->Password = "123";
	SrvrSession->Journal = "clients";
	SrvrSession->Connect();
}


[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}
*/