AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Drag & Drop im Edit erkennen und farbig markieren
Thema durchsuchen
Ansicht
Themen-Optionen

Drag & Drop im Edit erkennen und farbig markieren

Ein Thema von Helmi · begonnen am 30. Sep 2011 · letzter Beitrag vom 7. Dez 2011
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von Helmi
Helmi

Registriert seit: 29. Dez 2003
Ort: Erding, Republik Bayern
3.312 Beiträge
 
Delphi XE2 Professional
 
#1

Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 18:03
Hallo,

ich verwende diesen Code um Dateinamen via Drag & Drop aus dem Explorer in ein Edit zu bekommen.

Nun würd ich gerne, wenn die Maus über dem Edit ist, dass Drag & Drop erlaubt, dieses Edit farbig markieren.

Nur wie kann ich feststellen ob Drag & Drop im Edit aktiv ist und nur in diesem Falle es farbig markieren?
(Die Markierung sollte natürlich wieder zurück gesetzt werden, wenn das Dragen zu ende ist)

Ich hab schon: OnStartDrag, OnEndDrag, OnDragDrop, OnDragOver ausprobiert - aber kein Ereignis wird ausgelöst
mfg
Helmi

>> Theorie ist Wissen, dass nicht funktioniert - Praxis ist, wenn alles funktioniert und keiner weiss warum! <<
  Mit Zitat antworten Zitat
Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.337 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 18:18
Du könntest evtl. in MouseEnter und MouseExit auf DragControl prüfen...
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat
Benutzerbild von Helmi
Helmi

Registriert seit: 29. Dez 2003
Ort: Erding, Republik Bayern
3.312 Beiträge
 
Delphi XE2 Professional
 
#3

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 19:18
Du könntest evtl. in MouseEnter und MouseExit auf DragControl prüfen...
Hättest du vielleicht ein Beispiel dafür?
mfg
Helmi

>> Theorie ist Wissen, dass nicht funktioniert - Praxis ist, wenn alles funktioniert und keiner weiss warum! <<
  Mit Zitat antworten Zitat
Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.337 Beiträge
 
Delphi 11 Alexandria
 
#4

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 19:45
Nein sorry.
Habe es gerade mal probiert, das funktioniert so leider doch nicht
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat
Benutzerbild von Helmi
Helmi

Registriert seit: 29. Dez 2003
Ort: Erding, Republik Bayern
3.312 Beiträge
 
Delphi XE2 Professional
 
#5

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 21:37
Ich hab schon überlegt den Cursor im OnMouseMove abzufragen, aber leider funktioniert das auch nicht.
Der Screen.Cursor scheint nicht verändert zu werden, wenn Explorer-Drag & Drop aktiv ist

Habs so probiert:
Delphi-Quellcode:
procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  If Screen.Cursor <> crDefault then
    Edit1.Color := clRed
  else
    Edit1.Color := clBlue;
end;
mfg
Helmi

>> Theorie ist Wissen, dass nicht funktioniert - Praxis ist, wenn alles funktioniert und keiner weiss warum! <<
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.199 Beiträge
 
Delphi 12 Athens
 
#6

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 23:05
Du könntest im OnEnter mit GetAsyncKeyState prüfen, ob die linke Maustaste gedrückt ist
und wenn gleichzeitig gewisse Datenformate im Zwischenspeicher sind, dann könntest du zu relativ großer Wahrscheinlichkeit davon ausgehn, daß es sich um Drag&Drop handelt.

Was genau sich im Zwischenspeicher befindet, müßtest'e aber nochmal nachsehn.
Ich glaub das waren zwei verschiedene Dinge, welche sich dabei immer darin befinden.


Kann aber sein, daß du kein OnEnter/OnMouseMove bekommst, da der sich Eingabefokus, wärend des Clicks+Drags, noch beim Explorer befindet.
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu (30. Sep 2011 um 23:09 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.337 Beiträge
 
Delphi 11 Alexandria
 
#7

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 23:28
Kann aber sein, daß du kein OnEnter/OnMouseMove bekommst, da der sich Eingabefokus, wärend des Clicks+Drags, noch beim Explorer befindet.
So sah es bei meinem kurzen Test aus. Man müsste wohl nachschauen, wo und wie der Cursor genau geändert wird.
Ich denke mal, das wird vom Aufwand unverhältnismäßig sein....
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.199 Beiträge
 
Delphi 12 Athens
 
#8

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 30. Sep 2011, 23:45
Zitat von http://www.codeguru.com/cpp/cpp/cpp_mfc/dragdrop/article.php/c4059:
The drag-and-drop can be obtained in two ways; the first is OLE and the second is using the MFC. MFC supports the functionality of drag-and-drop without using OLE.
Dann bleibt dir wohl nur noch der andere Weg. (mit etwas Glück gibt es dort ein passendes Ereignis)


API / MFC : in der WinAPI und im MFC würde dann wohl DragAcceptFiles, WM_DROPFILES und Co. verwendet

OLE / MFC OLE : k.A. ... das müßtest du erstmal irgendwie rausbekommen

[add]
ShlObj.IDropTargetHelper ?
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu ( 1. Okt 2011 um 08:42 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Helmi
Helmi

Registriert seit: 29. Dez 2003
Ort: Erding, Republik Bayern
3.312 Beiträge
 
Delphi XE2 Professional
 
#9

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 6. Dez 2011, 20:19
[add]
ShlObj.IDropTargetHelper ?
Jetzt seh ich erst dass da noch was hinzugefügt wurde...

ShlObj kennt leider IDropTargetHelper nicht
mfg
Helmi

>> Theorie ist Wissen, dass nicht funktioniert - Praxis ist, wenn alles funktioniert und keiner weiss warum! <<
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.199 Beiträge
 
Delphi 12 Athens
 
#10

AW: Drag & Drop im Edit erkennen und farbig markieren

  Alt 6. Dez 2011, 21:20
Dieses Interface gibt es seit Windows 2000,
und Delphi 7 stammt aus dem Jahre 2002.

Embarcadero ... ähhhhhh Borland, waren beim Importieren der WinAPI noch nie die Schnellsten.


http://msdn.microsoft.com/en-us/libr.../bb762034.aspx
usw.

Eventuell ist in den JEDI-WinAPI-Headern, bzw in der JCL noch mehr/besseres Zeugs enthalten,
wenn nicht gar ein ganzes Drag&Drop-Komponentendinges.

Delphi-Quellcode:
///////////////////////////////////////////////////////
//
// Drag and Drop helper
//
// Purpose: To expose the Shell drag images
//
// This interface is implemented in the shell by CLSID_DragDropHelper.
//
// To use:
// If you are the source of a drag (i.e. in response to LV_DRAGBEGIN or
// equivelent begin drag message) call
// IDragSourceHelper::InitializeFromWindow
// (<hwnd of window supporting DI_GETDRAGIMAGE>,
// <pointer to POINT indicating offset to the mouse from
// the upper left corner of the image>,
// <pointer to data object>)
//
// NOTE: The Data object must support IDataObject::SetData with multiple
// data types and GetData must implement data type cloning
// (Including HGLOBAL), not just aliasing.
//
// If you wish to have an image while over your application add the
// IDragImages::Dr* calls to your IDropTarget implementation. For Example:
//
// STDMETHODIMP CUserDropTarget::DragEnter(IDataObject* pDataObject,
// DWORD grfKeyState,
// POINTL pt, DWORD* pdwEffect)
// {
// // Process your DragEnter
// // Call IDragImages::DragEnter last.
// _pDropTargetHelper->DragEnter(_hwndDragOver, pDataObject,
// (POINT*)&pt, *pdwEffect);
// return hres;
// }
//
//
// If you wish to be able to source a drag image from a custom control,
// implement a handler for the RegisterWindowMessage(DI_GETDRAGIMAGE).
// The LPARAM is a pointer to an SHDRAGIMAGE structure.
//
// sizeDragImage - Calculate the length and width required to render
// the images.
// ptOffset - Calculate the offset from the upper left corner to
// the mouse cursor within the image
// hbmpDragImage - CreateBitmap( sizeDragImage.cx, sizeDragImage.cy,
// GetDeviceCaps(hdcScreen, PLANES),
// GetDeviceCaps(hdcScreen, BITSPIXEL),
// NULL);
//
// Drag Images will only be displayed on Windows NT 5.0 or later.
//
//
// Note about IDropTargetHelper::Show - This method is provided for
// showing/hiding the Drag image in low color depth video modes. When
// painting to a window that is currently being dragged over (i.e. For
// indicating a selection) you need to hide the drag image by calling this
// method passing FALSE. After the window is done painting, Show the image
// again by passing TRUE.

const
  SID_IDropTargetHelper = '{4657278B-411B-11D2-839A-00C04FD918D0}';
  SID_IDragSourceHelper = '{DE5BF786-477A-11D2-839D-00C04FD918D0}';
  SID_IDragSourceHelper2 = '{83E07D0D-0C5F-4163-BF1A-60B274051E40}';

  // This is sent to a window to get the rendered images to a bitmap
  // Call RegisterWindowMessage to get the ID
  DI_GETDRAGIMAGE = 'ShellGetDragImage';

  DSH_ALLOWDROPDESCRIPTIONTEXT = $1;

type
  LPSHDRAGIMAGE = ^SHDRAGIMAGE;
  SHDRAGIMAGE = record
      sizeDragImage: SIZE; // OUT - The length and Width of the
                                      // rendered image
      ptOffset: TPoint; // OUT - The Offset from the mouse cursor to
                                      // the upper left corner of the image
      hbmpDragImage: HBITMAP; // OUT - The Bitmap containing the rendered
                                      // drag images
      crColorKey: COLORREF; // OUT - The COLORREF that has been blitted
                                      // to the background of the images
  end;
  TShDragImage = SHDRAGIMAGE;
  PShDragImage = ^TShDragImage;

  IDropTargetHelper = interface(IUnknown)
    [SID_IDropTargetHelper]
    function DragEnter(hwndTarget: HWND; const pDataObject: IDataObject;
                       var ppt: TPoint; dwEffect: DWORD): HRESULT; stdcall;
    function DragLeave: HResult; stdcall;
    function DragOver(var ppt: TPoint; dwEffect: DWORD): HRESULT; stdcall;
    function Drop(const pDataObject: IDataObject; var ppt: TPoint;
                  dwEffect: DWORD): HRESULT; stdcall;
    function Show(fShow: BOOL): HRESULT; stdcall;
  end;

  IDragSourceHelper = interface(IUnknown)
    [SID_IDragSourceHelper]
    function InitializeFromBitmap(pshdi: LPSHDRAGIMAGE;
      const pDataObject: IDataObject): HRESULT; stdcall;
    function InitializeFromWindow(hwnd: HWND; var ppt: TPoint;
      const pDataObject: IDataObject): HRESULT; stdcall;
  end;

  IDragSourceHelper2 = interface(IDragSourceHelper)
    [SID_IDragSourceHelper2]
    function SetFlags(dwFlags: DWORD): HRESULT; stdcall;
  end;
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:48 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz