Skip to content

Commit

Permalink
Remove Clipbrd unit dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Jan 26, 2014
1 parent 7693a0e commit b10b62d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
51 changes: 47 additions & 4 deletions EnvMan.dpr
Expand Up @@ -11,7 +11,7 @@ library EnvMan;
}

uses
Windows, Types, {$IFDEF UNICODE}PluginW{$ELSE}Plugin{$ENDIF}, PluginEx, Clipbrd;
Windows, Types, {$IFDEF UNICODE}PluginW{$ELSE}Plugin{$ENDIF}, PluginEx;

// ****************************************************************************

Expand Down Expand Up @@ -166,6 +166,49 @@ end;

// ****************************************************************************

function GetClipboardText: String;
var
Data: HGLOBAL;
begin
if not OpenClipboard(0) then
Exit;
try
Data := GetClipboardData(CF_TEXT);
if Data = 0 then
Exit;
Result := PChar(GlobalLock(Data));
GlobalUnlock(Data);
finally
CloseClipboard;
end;
end;

procedure SetClipboard(Format: Cardinal; const Buffer; Size: Cardinal);
var
Data: HGLOBAL;
DataPtr: Pointer;
begin
if not OpenClipboard(0) then
Exit;
try
Data := GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, Size);
DataPtr := GlobalLock(Data);
Move(Buffer, DataPtr^, Size);
EmptyClipboard;
SetClipboardData(Format, Data);
GlobalUnlock(Data);
finally
CloseClipboard;
end;
end;

procedure SetClipboardText(const Value: String);
begin
SetClipboard(CF_TEXT, PChar(Value)^, Length(Value) + 1);
end;

// ****************************************************************************

type
TEntry = record
Name: FarString;
Expand Down Expand Up @@ -838,17 +881,17 @@ begin
12: // VK_SHIFTDEL
if Current >= 0 then
begin
Clipboard.AsText := EntryToText(Entries[Current]);
SetClipboardText(EntryToText(Entries[Current]));
DeleteEntry(Current);
end;
13: // VK_CTRLINS
if Current >= 0 then
Clipboard.AsText := EntryToText(Entries[Current]);
SetClipboardText(EntryToText(Entries[Current]));
14: // VK_SHIFTINS
begin
if Current < 0 then
Current := 0;
InsertEntry(Current, TextToEntry(Clipboard.AsText));
InsertEntry(Current, TextToEntry(GetClipboardText));
end;
15: // VK_F2
begin
Expand Down
3 changes: 1 addition & 2 deletions build-config-sample.bat
Expand Up @@ -7,8 +7,7 @@ set PC32_DEFINE=-D
set PC32_SEARCH=-U
set PC32_OUTDIR=-E

set LAZARUS=C:\Soft\lazarus
set PC64=ppcrossx64 -Sd -Fu%LAZARUS%\lcl\units\x86_64-win64 -Fu%LAZARUS%\lcl -Fu%LAZARUS%\components\lazutils -Fi%LAZARUS%\lcl\include
set PC64=ppcrossx64 -Sd
set PC64_DEFINE=-d
set PC64_SEARCH=-Fu
set PC64_OUTDIR=-FE

0 comments on commit b10b62d

Please sign in to comment.