How do I know when a file is being dragged into my main window? lazarus / 32-Linux ---------------------------------------------------------------------- lugdanum · 2020-06-03 21:36 Bonjour Comment savoir quand un fichier est en train d'être glissé dans ma fenêtre principale ? J'aimerais pouvoir changer l'image de fond (par exemple) de ma fênetre lorsqu'un utilisateur passe dessus avec un fichier en mode glisser/déposer. En gros comment savoir que la personne est en train de glisser un fichier sur ma fenêtre et donc agir avant le déposer ? Merci beaucoup d'avance. - - - - - -  Hello How do I know when a file is being dragged into my main window? I would like to be able to change the background image (for example) of my window when a user passes over it with a file in drag and drop mode. Basically how to know that the person is dragging a file on my window and therefore act before depositing it? Thank you very much in advance. ---------------------------------------------------------------------- RAW · 2020-06-03 22:14 Maybe like this ...  AllowDropFiles:= True; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.FormDropFiles(Sender:TObject;Const FileNames:Array Of String);Var i:Integer; strExt:String;Begin  // check file suffix  For i:= Low(FileNames) To High(FileNames)  Do   Begin    strExt:= LowerCase(ExtractFileExt(FileNames[i]));    If ((strExt = '.txt') Or (strExt = '.log') Or (strExt = '.ini'))    Then Color:= clBlue;   End;End; ---------------------------------------------------------------------- lugdanum · 2020-06-04 09:11 Hello Thank you very much, but in fact I did not explain myself well. I would like to get the same thing as on this example: https://i0.wp.com/css-tricks.com/wp-content/uploads/2015/11/drag-drop- upload-1.gif?ssl=1 ie detect when the user arrives with a file in drag and drop on my window to change the background image for example, act before he drops the file. thank you so much ----------------------------- Bonjour Merci beaucoup, mais en fait je me suis mal expliqué. J'aimerais obtenir la même chose que sur cet exemple : https://i0.wp.com/css-tricks.com/wp-content/uploads/2015/11/drag-drop- upload-1.gif?ssl=1 c'est à dire détecter quand l'utilisateur arrive avec un fichier en drag and drop sur ma fenêtre pour changer l'image de fond par exemple, agir avant qu'il dépose/lâche le fichier. Merci beaucoup ---------------------------------------------------------------------- RAW · 2020-06-04 15:04 Yes, I overlooked two things: "LINUX" and "act before depositing it" ...  I guess you need to take a look at the LINUX-Api for that ... On Windows it's always the same thing: If you need something special then the OS-Api is your best friend... A solution might be: 1. Set AllowDropFiles:= True (FORM, WND) 2. React on the changed cursor icon (LMessages: CM_CURSORCHANGED) Maybe that's a starting point ... ---------------------------------------------------------------------- 440bx · 2020-06-04 16:44 Quote from: lugdanum on June 04, 2020, 11:11:37 amie detect when the user arrives with a file in drag and drop on my window to change the background image for example, act before he drops the file. Just so you know, that page is _not_ detecting that a file is being dragged onto it.  It's just a .gif that continuously changes regardless of whether a file is being dragged onto it or not. Also, under Windows @RAW is correct.  Detecting the change in cursor icon is the first step to find out if something is being dragged onto the window.  In addition to that, it would be good to use GetCapture() to ensure the mouse is captured (drag & drop requires the mouse to be captured.) You can even find out which program/process the drag originated from by calling GetGUIThreadInfo. HTH. ---------------------------------------------------------------------- lugdanum · 2020-06-04 17:02 Hello Quote from: RAW on June 04, 2020, 05:04:49 pmA solution might be: 1. Set AllowDropFiles:= True (FORM, WND) 2. React on the changed cursor icon (LMessages: CM_CURSORCHANGED) -> Thank you for this start of the track, I hadn't thought of looking there. Merci pour ce début de piste je n'avais pas pensé à regarder par là. Quote from: 440bx on June 04, 2020, 06:44:32 pmJust so you know, that page is _not_ detecting that a file is being dragged onto it.  It's just a .gif that continuously changes regardless of whether a file is being dragged onto it or not. -> Lol seriously  ? it was just to show what i wanted to get, thanks i didn't know it was a gif Lol sérieux ? c'était juste pour montrer ce que je voulais obtenir, merci je ne savais pas que c'était un gif ;-) Quote from: 440bx on June 04, 2020, 06:44:32 pmAlso, under Windows @RAW is correct.  Detecting the change in cursor icon is the first step to find out if something is being dragged onto the window.  In addition to that, it would be good to use GetCapture() to ensure the mouse is captured (drag & drop requires the mouse to be captured.) You can even find out which program/process the drag originated from by calling GetGUIThreadInfo. -> In any case a big thank you too, I will see and look on this side, thank you! En tout cas un grand merci aussi, je vais voir et chercher de ce côté, merci !