![]() |
Drag & Drop im Edit erkennen und farbig markieren
Hallo,
ich verwende diesen ![]() 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 |
AW: Drag & Drop im Edit erkennen und farbig markieren
Du könntest evtl. in MouseEnter und MouseExit auf DragControl prüfen...
|
AW: Drag & Drop im Edit erkennen und farbig markieren
Zitat:
|
AW: Drag & Drop im Edit erkennen und farbig markieren
Nein sorry.
Habe es gerade mal probiert, das funktioniert so leider doch nicht :-( |
AW: Drag & Drop im Edit erkennen und farbig markieren
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; |
AW: Drag & Drop im Edit erkennen und farbig markieren
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. |
AW: Drag & Drop im Edit erkennen und farbig markieren
Zitat:
Ich denke mal, das wird vom Aufwand unverhältnismäßig sein.... |
AW: Drag & Drop im Edit erkennen und farbig markieren
Zitat:
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 ? |
AW: Drag & Drop im Edit erkennen und farbig markieren
Zitat:
ShlObj kennt leider IDropTargetHelper nicht |
AW: Drag & Drop im Edit erkennen und farbig markieren
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. :stupid: ![]() 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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:50 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz