1*c2c66affSColin Finck ///////////////////////////////////////////////////////////////////////////////
2*c2c66affSColin Finck //Telnet Win32 : an ANSI telnet client.
3*c2c66affSColin Finck //Copyright (C) 1998  Paul Brannan
4*c2c66affSColin Finck //Copyright (C) 1998  I.Ioannou
5*c2c66affSColin Finck //Copyright (C) 1997  Brad Johnson
6*c2c66affSColin Finck //
7*c2c66affSColin Finck //This program is free software; you can redistribute it and/or
8*c2c66affSColin Finck //modify it under the terms of the GNU General Public License
9*c2c66affSColin Finck //as published by the Free Software Foundation; either version 2
10*c2c66affSColin Finck //of the License, or (at your option) any later version.
11*c2c66affSColin Finck //
12*c2c66affSColin Finck //This program is distributed in the hope that it will be useful,
13*c2c66affSColin Finck //but WITHOUT ANY WARRANTY; without even the implied warranty of
14*c2c66affSColin Finck //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*c2c66affSColin Finck //GNU General Public License for more details.
16*c2c66affSColin Finck //
17*c2c66affSColin Finck //You should have received a copy of the GNU General Public License
18*c2c66affSColin Finck //along with this program; if not, write to the Free Software
19*c2c66affSColin Finck //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*c2c66affSColin Finck //
21*c2c66affSColin Finck //I.Ioannou
22*c2c66affSColin Finck //roryt@hol.gr
23*c2c66affSColin Finck //
24*c2c66affSColin Finck ///////////////////////////////////////////////////////////////////////////
25*c2c66affSColin Finck 
26*c2c66affSColin Finck // TnClip.cpp
27*c2c66affSColin Finck // A simple class for handling clipboard functions
28*c2c66affSColin Finck // Written by Paul Brannan <pbranna@clemson.edu>
29*c2c66affSColin Finck // Last modified 7/12/98
30*c2c66affSColin Finck 
31*c2c66affSColin Finck #include "precomp.h"
32*c2c66affSColin Finck 
Tnclip(HWND W,TNetwork & RefNetwork)33*c2c66affSColin Finck Tnclip::Tnclip(HWND W, TNetwork &RefNetwork): Network(RefNetwork) {
34*c2c66affSColin Finck 	Window = W;
35*c2c66affSColin Finck }
36*c2c66affSColin Finck 
~Tnclip()37*c2c66affSColin Finck Tnclip::~Tnclip() {
38*c2c66affSColin Finck }
39*c2c66affSColin Finck 
Copy(HGLOBAL clipboard_data)40*c2c66affSColin Finck void Tnclip::Copy(HGLOBAL clipboard_data) {
41*c2c66affSColin Finck 	if(!OpenClipboard(Window)) return;
42*c2c66affSColin Finck 	if(!EmptyClipboard()) return;
43*c2c66affSColin Finck 
44*c2c66affSColin Finck 	SetClipboardData(CF_TEXT, clipboard_data);
45*c2c66affSColin Finck 	CloseClipboard();
46*c2c66affSColin Finck }
47*c2c66affSColin Finck 
Paste()48*c2c66affSColin Finck void Tnclip::Paste() {
49*c2c66affSColin Finck 	if(!OpenClipboard(Window)) return;
50*c2c66affSColin Finck 
51*c2c66affSColin Finck 	HANDLE clipboard_data = GetClipboardData(CF_TEXT);
52*c2c66affSColin Finck 	LPVOID clipboard_ptr = GlobalLock(clipboard_data);
53*c2c66affSColin Finck 	DWORD size = strlen((const char *)clipboard_data);
54*c2c66affSColin Finck 	Network.WriteString((const char *)clipboard_ptr, size);
55*c2c66affSColin Finck 	GlobalUnlock(clipboard_data);
56*c2c66affSColin Finck 
57*c2c66affSColin Finck 	CloseClipboard();
58*c2c66affSColin Finck }
59*c2c66affSColin Finck 
60