There are many examples here how to enable drag and drop between Gadgets and how to acept Dropping Files from Outside using DragAcceptFiles_(hwnd,1) ...
In these examples I could see how to highlight a Treegadgetitem (using easyvent) during a dragover operation.
But I haven´t seen a example how to highlight a treegadgetitem if the Dragoperation starts from outside, and I could not figure out how to do this.
For example: If you drag a file from another Application over the Explorer, the folders and drives are highlighted.
Any Tips?
Highlight GadgetItem while dragover from another App
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
I have thrown something together now but be warned! Although this seems to work at the moment it's by far not what you call a final solution!
You should be aware of the fact that item highlighting is done with the default color used for items in window controls that don't have the focus. Perfectly normal behaviour if you consider the outside click. I you want a more crisp highlight color and a focus rectangle you can easily roll your own if want.
Code: Select all
Declare ThreadProc(lParam.l)
#WIN_Main = 0
#LST_Itemdata = 0
OpenWindow(0,0,0,400,300,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(#WIN_Main))
ListIconGadget(#LST_Itemdata,0,0,0,0,"Name",350,#PB_ListIcon_AlwaysShowSelection)
For i=1 To 30 : AddGadgetItem(#LST_Itemdata,-1,"Untitled ListView Item #" + Str(i)) : Next
CreateThread(@ThreadProc(),0)
; -------------------------------------------------------------------------------------
; MAIN LOOP
; -------------------------------------------------------------------------------------
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_SizeWindow
ResizeGadget(0,5,5,WindowWidth(0)-10,WindowHeight(0)-10)
EndIf
Until EventID = 16
; -------------------------------------------------------------------------------------
; FUNCTIONS
; -------------------------------------------------------------------------------------
Procedure ThreadProc(lParam.l)
Repeat
Delay(10) : GetCursorPos_(cpt.POINT)
Hotspot = SendMessage_(WindowID(#WIN_Main),#WM_NCHITTEST,0,cpt\x | cpt\y << 16)
If GetAsyncKeyState_(#VK_LBUTTON) And Hotspot = #HTCLIENT
ScreenToClient_(GadgetID(#LST_Itemdata),cpt)
irc.RECT : irc\left = #LVIR_LABEL
SendMessage_(GadgetID(#LST_Itemdata),#LVM_GETITEMRECT,0,irc)
ItemHeight = irc\bottom - irc\top
If cpt\x >= irc\left And cpt\x < (GadgetWidth(#LST_Itemdata) - 30)
Index = (cpt\y - irc\top) / ItemHeight
SetGadgetState(#LST_Itemdata,Index)
EndIf
EndIf
ForEver
EndProcedureWindows 10 Pro, 64-Bit / Whose Hoff is it anyway?
