source: cprs/branches/tmg-cprs/TntWare/Delphi Unicode Controls/Source/TntClipBrd.pas@ 1522

Last change on this file since 1522 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

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