mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 12:59:37 +02:00
fixed copy / paste
git-svn-id: trunk@7756 -
This commit is contained in:
parent
9aedd8aeee
commit
3a66e78c03
@ -383,7 +383,7 @@ end;
|
||||
procedure TClipboard.SetTextBuf(Buffer: PChar);
|
||||
begin
|
||||
if Buffer=nil then Buffer:=#0;
|
||||
SetBuffer(PredefinedClipboardFormat(pcfText),Buffer^,StrLen(Buffer));
|
||||
SetBuffer(PredefinedClipboardFormat(pcfText),Buffer^,StrLen(Buffer)+1);
|
||||
end;
|
||||
|
||||
function TClipboard.GetTextBuf(Buffer: PChar; BufSize: Integer): Integer;
|
||||
|
@ -481,6 +481,36 @@ End;
|
||||
Function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
|
||||
OnRequestProc: TClipboardRequestEvent; FormatCount: Integer;
|
||||
Formats: PClipboardFormat): Boolean;
|
||||
|
||||
procedure PutOnClipBoard(FormatID: integer);
|
||||
var
|
||||
DataStream: TStream;
|
||||
DataHandle : Windows.HGLOBAL;
|
||||
DataPtr: pointer;
|
||||
begin
|
||||
if assigned(OnClipBoardRequest) then begin
|
||||
DataStream := TMemoryStream.Create;
|
||||
try
|
||||
OnClipBoardRequest(FormatID, DataStream);
|
||||
DataStream.Position:=0;
|
||||
DataHandle := Windows.GlobalAlloc(Windows.GMEM_MOVEABLE, DataStream.Size);
|
||||
if (DataHandle=HWND(0)) then begin
|
||||
debugln('TWin32WidgetSet.ClipboardGetOwnerShip DataHandle=',dbgs(DataHandle),' DataSize=',dbgs(DataStream.Size));
|
||||
Result := false;
|
||||
exit;
|
||||
end;
|
||||
DataPtr := GlobalLock(DataHandle);
|
||||
try
|
||||
DataStream.Read(DataPtr^, DataStream.Size);
|
||||
finally
|
||||
Windows.GlobalUnlock(DataHandle);
|
||||
end;
|
||||
Windows.SetClipboardData(FormatID, DataHandle);
|
||||
finally
|
||||
DataStream.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure PutTextOnClipBoard;
|
||||
var
|
||||
@ -567,12 +597,12 @@ Begin
|
||||
exit;
|
||||
end;
|
||||
Result := true;
|
||||
OnClipBoardRequest := OnRequestProc;
|
||||
for I := 0 To FormatCount-1 do begin
|
||||
{$IFDEF VerboseWin32Clipbrd}
|
||||
debugln('TWin32WidgetSet.ClipboardGetOwnerShip A Formats['+dbgs(i)+']=',dbgs(Formats[i]));
|
||||
{$ENDIF}
|
||||
if Formats[i]=Windows.CF_TEXT then
|
||||
PutTextOnClipBoard;
|
||||
PutOnClipBoard(Formats[i]);
|
||||
end;
|
||||
finally
|
||||
if not Windows.CloseClipboard then begin
|
||||
|
Loading…
Reference in New Issue
Block a user