1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
{*****************************************************************************}
{ }
{ Tnt Delphi Unicode Controls }
{ http://www.tntware.com/delphicontrols/unicode/ }
{ Version: 2.2.1 }
{ }
{ Copyright (c) 2002-2005, Troy Wolbrink (troy.wolbrink@tntware.com) }
{ }
{*****************************************************************************}
unit TntClipBrd;
{$INCLUDE TntCompilers.inc}
interface
uses
Classes, Windows, Clipbrd;
type
{TNT-WARN TClipboard}
TTntClipboard = class(TClipboard{TNT-ALLOW TClipboard})
private
function GetAsWideText: WideString;
procedure SetAsWideText(const Value: WideString);
public
property AsWideText: WideString read GetAsWideText write SetAsWideText;
property AsText: WideString read GetAsWideText write SetAsWideText;
end;
{TNT-WARN Clipboard}
function TntClipboard: TTntClipboard;
implementation
{ TTntClipboard }
function TTntClipboard.GetAsWideText: WideString;
var
Data: THandle;
begin
Open;
Data := GetClipboardData(CF_UNICODETEXT);
try
if Data <> 0 then
Result := PWideChar(GlobalLock(Data))
else
Result := '';
finally
if Data <> 0 then GlobalUnlock(Data);
Close;
end;
if (Data = 0) or (Result = '') then
Result := inherited AsText
end;
procedure TTntClipboard.SetAsWideText(const Value: WideString);
begin
Open;
try
inherited AsText := Value; {Ensures ANSI compatiblity across platforms.}
SetBuffer(CF_UNICODETEXT, PWideChar(Value)^, (Length(Value) + 1) * SizeOf(WideChar));
finally
Close;
end;
end;
//------------------------------------------
var
GTntClipboard: TTntClipboard;
function TntClipboard: TTntClipboard;
begin
if GTntClipboard = nil then
GTntClipboard := TTntClipboard.Create;
Result := GTntClipboard;
end;
initialization
finalization
GTntClipboard.Free;
end.
|