Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / MFC

Remote Control PCs

Rate me:
Please Sign up or sign in to vote.
4.60/5 (150 votes)
20 Sep 2013GPL3 882.3K   63.9K   489  
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.

#pragma once

#include <afxwin.h>
#include <vector>

// Wrapper class for the Cursor
class CCursor
{
public:
	CCursor() : m_hCursor(NULL) {}
	~CCursor()
	{
		Destroy();
	}
	operator HCURSOR() {return m_hCursor;}
	void CreateCursor(DWORD dwXHotSpot,DWORD dwYHotSpot,int nWidth,int nHeight,WORD bmMaskPlanes,WORD bmMaskBitsPixel,WORD bmColorPlanes,WORD bmColorBitsPixel,BYTE * pMaskBits,BYTE * pColorBits)
	{
		// Clean up
		Destroy();

		// Create a mask bitmap
		HBITMAP hMask = NULL;
		CBitmap Mask;
		if (pMaskBits)
		{
			Mask.CreateBitmap(nWidth,nHeight,bmMaskPlanes,bmMaskBitsPixel,pMaskBits);
			hMask = (HBITMAP)Mask;
		}

		// Create a color bitmap
		HBITMAP hColor = NULL;
		CBitmap Color;
		if (pColorBits)
		{
			Color.CreateBitmap(nWidth,nHeight,bmColorPlanes,bmColorBitsPixel,pColorBits);
			hColor = (HBITMAP)Color;
		}

		// Create an Icon from the "color" and "mask" bitmaps
		ICONINFO IconInfo;
		IconInfo.fIcon = FALSE;
		IconInfo.xHotspot = dwXHotSpot;
		IconInfo.yHotspot = dwYHotSpot;
		IconInfo.hbmMask = hMask;
		IconInfo.hbmColor = hColor;

		// Create the cursor
		m_hCursor = CreateIconIndirect(&IconInfo);
	}

protected:
	void Destroy()
	{
		if (m_hCursor)
		{
			DestroyCursor(m_hCursor);
			m_hCursor = NULL;
		}
	}

private:
	HCURSOR m_hCursor;
};

class CDIBFrame
{
public:
	CDIBFrame();
	CDIBFrame(int x,int y,int nBitCount);
	CDIBFrame(BYTE * pBuffer,DWORD dwLen);
	CDIBFrame(const CDIBFrame & rhs);
	~CDIBFrame();

public:
	CDIBFrame & operator = (const CDIBFrame & rhs);
	operator HBITMAP () {return m_hBkgFrame;}
	operator HDC () {return (HDC)m_FrameDC;}
	operator CDC * () {return &m_FrameDC;}
	operator CDC & () {return m_FrameDC;}
	operator LPSTR () {return m_pBkgBits;}
	operator LPSTR * () {return &m_pBkgBits;}
	operator BITMAPINFO * () {return m_pBitmapInfo;}
	operator BITMAPINFOHEADER * () {return m_pBitmapInfoHdr;}

public:
	void Init(int x,int y,int nBitCount);
	void CreateFrame(const BYTE * pBuffer = NULL,DWORD dwLen = 0);
	void DeleteFrame();

public:
	int m_x,m_y,m_nBitCount;
	DWORD m_dwBkgImageBytes;

protected:
	CDC m_FrameDC;
	HBITMAP m_hBkgFrame;
	LPSTR m_pBkgBits;
	HBITMAP m_hLastBkgFrame;
	std::vector<BYTE> m_Buffer;
	BITMAPINFO * m_pBitmapInfo;
	BITMAPINFOHEADER * m_pBitmapInfoHdr;
};

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)


Written By
Founder
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions