From 187ba5cd250f2561e0156520332f4614bfba1219 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 29 Oct 2010 11:49:24 +0200 Subject: GDI: Implemented StringToHandle in TfpgGDIDrag class This is needed so we can store a string in a global buffer for DND. This will also reduce code duplication a bit, by simply allowing us to call this function. --- src/corelib/gdi/fpg_gdi.pas | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/corelib/gdi') diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas index 980339b4..18b04da0 100644 --- a/src/corelib/gdi/fpg_gdi.pas +++ b/src/corelib/gdi/fpg_gdi.pas @@ -265,7 +265,10 @@ type end; + { Used mainly for sending drags - being the source of the drag } TfpgGDIDrag = class(TfpgDragBase) + private + function StringToHandle(const AString: TfpgString): HGLOBAL; protected FSource: TfpgGDIWindow; function GetSource: TfpgGDIWindow; virtual; @@ -2747,6 +2750,22 @@ end; { TfpgGDIDrag } +function TfpgGDIDrag.StringToHandle(const AString: TfpgString): HGLOBAL; +var + dest: HGLOBAL; + l: integer; + p: PChar; +begin + p := PChar(AString); + l := Length(AString)+1; + { allocate and lock a global memory buffer. Make it fixed + data so we don't have to use GlobalLock } + dest := GlobalAlloc(GMEM_FIXED, l); + { Copy the string into the buffer } + Move(p^, PChar(dest)^, l); + Result := dest; +end; + function TfpgGDIDrag.GetSource: TfpgGDIWindow; begin Result := FSource; -- cgit v1.2.3-70-g09d2