summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-29 12:00:50 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2010-10-29 12:00:50 +0200
commit420623b7b478d1bc653ef69ad6e22da344c3b478 (patch)
tree6ca6ce0da3e41da560f550a58e7c51186f0ac523 /src/corelib
parent3f1a38ece21e5e7da9508c57e5fe2b23bea11817 (diff)
downloadfpGUI-420623b7b478d1bc653ef69ad6e22da344c3b478.tar.xz
Added DND debugging entries and minor code formatting improvements.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/gdi/fpg_gdi.pas13
-rw-r--r--src/corelib/gdi/fpg_oledragdrop.pas49
2 files changed, 46 insertions, 16 deletions
diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas
index 15131adf..a6a94c4d 100644
--- a/src/corelib/gdi/fpg_gdi.pas
+++ b/src/corelib/gdi/fpg_gdi.pas
@@ -277,6 +277,7 @@ type
end;
+ { Used mainly for receiving drags - being the target of the drag }
TGDIDragManager = class(TInterfacedObject, IDropTarget)
private
FDropTarget: TfpgWindowBase; { actually a TfpgWidget }
@@ -823,7 +824,7 @@ begin
begin
{$IFDEF DEBUG}
if uMsg <> WM_MOUSEMOVE then
- SendDebug('fpGFX/GDI: Found a mouse button event');
+ writeln('fpGFX/GDI: Found a mouse button event');
{$ENDIF}
// msgp.mouse.x := smallint(lParam and $FFFF);
// msgp.mouse.y := smallint((lParam and $FFFF0000) shr 16);
@@ -1353,6 +1354,9 @@ procedure TfpgGDIWindow.HandleDNDLeave(Sender: TObject);
var
wg: TfpgWidget;
begin
+ {$IFDEF DND_DEBUG}
+ writeln('TfpgGDIWindow.HandleDNDLeave ');
+ {$ENDIF}
FUserMimeSelection := '';
wg := self as TfpgWidget;
if wg.AcceptDrops then { if we get here, this should always be true anyway }
@@ -1373,6 +1377,9 @@ var
EnumIntf: IEnumFORMATETC;
msgp: TfpgMessageParams;
begin
+ {$IFDEF DND_DEBUG}
+ writeln('TfpgGDIWindow.HandleDNDEnter ');
+ {$ENDIF}
wg := self as TfpgWidget;
if wg.AcceptDrops then
begin
@@ -1410,7 +1417,6 @@ begin
msgp.mouse.y := PT.y;
fpgPostMessage(nil, wg, FPGM_DROPENTER, msgp);
end;
-
end;
end;
@@ -1426,6 +1432,9 @@ begin
want that, for performance reasons. }
if FDropPos <> PT then
begin
+ {$IFDEF DND_DEBUG}
+ writeln('TfpgGDIWindow.HandleDNDPosition ');
+ {$ENDIF}
FDropPos.x := PT.x;
FDropPos.y := PT.y;
fillchar(msgp, sizeof(msgp), 0);
diff --git a/src/corelib/gdi/fpg_oledragdrop.pas b/src/corelib/gdi/fpg_oledragdrop.pas
index 316c9799..fa17ba67 100644
--- a/src/corelib/gdi/fpg_oledragdrop.pas
+++ b/src/corelib/gdi/fpg_oledragdrop.pas
@@ -362,8 +362,10 @@ var
begin
DataObject := TfpgOLEDataObject.Create;
+ { append filenames as one long string delimited by #0. ie: something like a PChar }
S := '';
- for I := 0 to FFileNames.Count - 1 do begin
+ for I := 0 to FFileNames.Count - 1 do
+ begin
SetLength(S, Length(S)+Length(FFileNames[I])+1);
Move(FFileNames[I][1], S[Length(S)-Length(FFileNames[I])], Length(FFileNames[I]));
S[Length(S)] := #0;
@@ -371,6 +373,7 @@ begin
SetLength(S, Length(S)+1);
S[Length(S)] := #0;
+ { description of data we are sending }
New(F);
F^.cfFormat := CF_HDROP;
F^.ptd := nil;
@@ -379,6 +382,7 @@ begin
F^.tymed := TYMED_HGLOBAL;
DataObject.FormatEtcList.Add(F);
+ { storage for data we are sending }
New(M);
M^.tymed := TYMED_HGLOBAL;
M^.hGlobal := Cardinal(GlobalAlloc(GMEM_FIXED, SizeOf(TDropFiles)+Length(S)));
@@ -389,9 +393,12 @@ begin
Move(S[1], PChar(M^.hGlobal+SizeOf(TDropFiles))^, Length(S));
DataObject.StgMediumList.Add(M);
- if (FAliasFileNames.Count > 0) and (FAliasFileNames.Count = FFileNames.Count) then begin
+ if (FAliasFileNames.Count > 0) and (FAliasFileNames.Count = FFileNames.Count) then
+ begin
+ { append filename aliases as one long string delimited by #0. ie: something like a PChar }
S := '';
- for I := 0 to FAliasFileNames.Count - 1 do begin
+ for I := 0 to FAliasFileNames.Count - 1 do
+ begin
SetLength(S, Length(S)+Length(FAliasFileNames[I])+1);
Move(FAliasFileNames[I][1], S[Length(S)-Length(FAliasFileNames[I])], Length(FAliasFileNames[I]));
S[Length(S)] := #0;
@@ -399,6 +406,7 @@ begin
SetLength(S, Length(S)+1);
S[Length(S)] := #0;
+ { description of data we are sending }
New(F);
F^.cfFormat := CF_FILENAMEMAP;
F^.ptd := nil;
@@ -407,6 +415,7 @@ begin
F^.tymed := TYMED_HGLOBAL;
DataObject.FormatEtcList.Add(F);
+ { storage for data we are sending }
New(M);
M^.tymed := TYMED_HGLOBAL;
M^.hGlobal := Cardinal(GlobalAlloc(GMEM_FIXED, Length(S)));
@@ -417,8 +426,11 @@ begin
DropSource := TfpgOLEDropSource.Create;
dwResult := ActiveX.DoDragDrop(DataObject as IDataObject, DropSource as IDropSource, DROPEFFECT_COPY, @dwEffect);
- if dwResult = DRAGDROP_S_DROP then begin
- if dwEffect = DROPEFFECT_COPY then begin
+ if dwResult = DRAGDROP_S_DROP then
+ begin
+ if dwEffect = DROPEFFECT_COPY then
+ begin
+ // nothing to do. If this whas xxx_MOVE, we would remove data from source
end;
end;
end;
@@ -450,8 +462,7 @@ begin
Result := DRAGDROP_S_USEDEFAULTCURSORS;
end;
-function TfpgOLEDropSource.QueryContinueDrag(fEscapePressed: BOOL;
- grfKeyState: Integer): HResult;
+function TfpgOLEDropSource.QueryContinueDrag(fEscapePressed: BOOL; grfKeyState: Integer): HResult;
begin
if FEscapePressed then
Result := DRAGDROP_S_CANCEL
@@ -459,6 +470,9 @@ begin
Result := DRAGDROP_S_DROP
else
Result := S_OK;
+ {$IFDEF DND_DEBUG}
+ writeln('TfpgOLEDropSource.QueryContinueDrag Result = ', Result);
+ {$ENDIF}
end;
{ TfpgOLEDataObject }
@@ -503,7 +517,8 @@ end;
function TfpgOLEDataObject.EnumFormatEtc(dwDirection: DWORD;
out enumFormatEtc: IEnumFormatEtc): HResult;
begin
- if dwDirection = DATADIR_GET then begin
+ if dwDirection = DATADIR_GET then
+ begin
enumFormatEtc := TfpgOLEEnumFormatEtc.Create(FFormatEtcList) as IEnumFormatEtc;
Result := S_OK;
end
@@ -528,10 +543,12 @@ begin
Idx := LookupFormatEtc(formatetcIn);
if Idx = -1 then
Result := DV_E_FORMATETC
- else begin
+ else
+ begin
medium.tymed := FFormatEtcList[Idx]^.tymed;
medium.PUnkForRelease := nil;
- if medium.tymed = TYMED_HGLOBAL then begin
+ if medium.tymed = TYMED_HGLOBAL then
+ begin
medium.hGlobal := DupGlobalMem(FStgMediumList[Idx]^.hGlobal);
Result := S_OK;
end
@@ -747,10 +764,14 @@ function TfpgOLEDropTarget.Drop(const dataObj: IDataObject;
var
Effect: TfpgOLEDragDropEffect;
begin
- if dwEffect and DROPEFFECT_COPY > 0 then Effect := deCopy
- else if dwEffect and DROPEFFECT_MOVE > 0 then Effect := deMove
- else if dwEffect and DROPEFFECT_LINK > 0 then Effect := deLink
- else Effect := deNone;
+ if dwEffect and DROPEFFECT_COPY > 0 then
+ Effect := deCopy
+ else if dwEffect and DROPEFFECT_MOVE > 0 then
+ Effect := deMove
+ else if dwEffect and DROPEFFECT_LINK > 0 then
+ Effect := deLink
+ else
+ Effect := deNone;
DoDragDrop(dataObj, grfKeyState, pt, Effect);
Result := S_OK;
end;