[Lazarus] [FPC] Install from sources

Mattias Gaertner nc-gaertnma at netcologne.de
Sun May 16 14:48:49 CEST 2010


Hi,

Can anyone confirm this?

On win9x I have a problem with ClipBoard.GetAsText.

Take a look at this example code:

  ClipText := ClipBoard.AsText;
  debugln;
  debugln('ClipText = "',ClipText,'"');
  debugln('Length = ',DbgS(Length(ClipText)));
  for i := 1 to length(ClipText) do DbgOut('#',DbgS(Ord(ClipText[i])));
  debugln;

Now when I copy (from Windows Notepad) 'ABC'  to the clipboard and run
the above code, the output is

ClipText = "ABC                            "
Length = 31
#65#66#67#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0

The first #0 after 'C' (#67) is consistent, the rest may be garbage.

I traced this down to (in /lcl/interfaces/win32/win32winapi.inc)

  function ReadClipboardToStream(DestStream: TStream): Boolean;
  begin
    Result := false;

    DataHandle := Windows.GetClipboardData(FormatID);
    if DataHandle<>HWND(0) then
    begin
      Size := Windows.GlobalSize(DataHandle);      // <<-------------------- **

    .....
  end;


**       Size will always be n times 32 (on win32)

In ClipBoard.GetAsText there is code to remove the last trailing #0
(if there is one), but as the example shows, this is not enough.
Moreover, the last char in the buffer might not even be a #0 and
nothing gets removed.

Can anyone confirm this?
Is it Windows (win32) only?

Bart




More information about the Lazarus mailing list