Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Remote Control PCs

, 20 Sep 2013
Two projects that work together to remote control PCs across a LAN.
// Remote Desktop System - remote controlling of multiple PC's
// Copyright (C) 2000-2009 GravyLabs LLC

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include "stdafx.h"
#include "RDV.h"
#include "RDVDoc.h"
#include "RDVView.h"
#include "NewConnectionDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CRDVDoc

IMPLEMENT_DYNCREATE(CRDVDoc, CDocument)

BEGIN_MESSAGE_MAP(CRDVDoc, CDocument)
END_MESSAGE_MAP()


// CRDVDoc construction/destruction

CRDVDoc::CRDVDoc()
{
}

CRDVDoc::~CRDVDoc()
{
}

// Return the view
CRDVView * CRDVDoc::GetView()
{
	CRDVView * pView = NULL;
	POSITION Pos = GetFirstViewPosition();
	if (Pos)
		pView = (CRDVView *)GetNextView(Pos);
	return pView;
}

BOOL CRDVDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// Display the connection dialog
	CNewConnectionDlg NewConnection;
	if (NewConnection.DoModal() != IDOK)
		return FALSE;

	// Set the connection specifics for a successful connection
	m_csIp = NewConnection.m_csIp;
	m_csPort = NewConnection.m_csPort;
	m_csPassword = NewConnection.m_csPassword;

	// Connect to the server
	GetView()->ConnectServer();

	return TRUE;
}

void CRDVDoc::OnCloseDocument()
{
	// Close all active connections
	CRDVView * pView = GetView();
	if (pView)
		pView->DisconnectServer();

	// Close the document
	CDocument::OnCloseDocument();
}

// CRDVDoc serialization

void CRDVDoc::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		// Save the connection information
		ar << m_csIp;
		ar << m_csPort;
		ar << m_csPassword;
	}
	else
	{
		// Load the connection information
		ar >> m_csIp;
		ar >> m_csPort;
		ar >> m_csPassword;

		// Connect to the server
		GetView()->ConnectServer();
	}
}

// CRDVDoc diagnostics

#ifdef _DEBUG
void CRDVDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CRDVDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

// CRDVDoc commands

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Andy Bantly
Founder
United States United States
Working as a software developer since 1989. Started out with Basic, FORTRAN and JCL, moved into Visual Basic 1.0, C, then C++, and now I work mainly in C++ using MFC, Win32, and ATL/COM. I use Microsoft Products only because that is what gives me gainful employment. Through work, I have a lot of experience with HTML, JavaScript, XSL transformations, the XMLHTTP object, PHP 4.x, and simple COM object integrations.
 
I've worked for the University of Oklahoma in the school of meteorology (Go SOONERS!), consulting, and now as a Senior Software Engineer. These things keep my lights on and electricity going. My dream job is to own a bowling alley and rub elbows with pro-bowlers! I'm also an avid pedicab driver and have my own cab. I like the hustle of picking up people in downtown and biking them to their destination.
Follow on   Google+   LinkedIn

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 20 Sep 2013
Article Copyright 2000 by Andy Bantly
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid