Hello,
Is there any way to know if the mouse is hovering over a ListViewGadget (only hover without clicking or anything else) or should it be handled based on mouse coordinates?
Thank you for your help
Overview LitsViewGadget
Re: Overview LitsViewGadget
I would handle it through the regular events (#PB_EventType_MouseEnter/Move/Leave). Do you have special needs, like which cell is right now under the cursor?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Overview LitsViewGadget
What kind of hovering?
In the first example, a "WM_MOUSEMOVE" event occurs every time the mouse moves on the gadget.
In the second code, a "WM_MOUSEHOVER" event occurs when the mouse movement stops for a specified time on the gadget. In the example, a hover event occurs after 1000 milliseconds.
In the first example, a "WM_MOUSEMOVE" event occurs every time the mouse moves on the gadget.
In the second code, a "WM_MOUSEHOVER" event occurs when the mouse movement stops for a specified time on the gadget. In the example, a hover event occurs after 1000 milliseconds.
Code: Select all
#MyAPP_OldWindProc = "OldWndProc"
Procedure MyListViewGadgetCallback(hWnd, Msg, wParam, lParam)
Protected old = GetProp_(hWnd, #MyAPP_OldWindProc)
Select Msg
Case #WM_MOUSEMOVE
Debug "move"
Case #WM_NCDESTROY
RemoveProp_(hWnd, #MyAPP_OldWindProc)
EndSelect
ProcedureReturn CallWindowProc_(old, hWnd, Msg, wParam, lParam)
EndProcedure
If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0, 10, 10, 250, 120)
For a = 1 To 12
AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
Next
SetGadgetState(0, 9)
old = SetWindowLongPtr_(GadgetID(0), #GWLP_WNDPROC, @MyListViewGadgetCallback())
SetProp_(GadgetID(0), #MyAPP_OldWindProc, old)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Select all
#MyAPP_OldWindProc = "OldWndProc"
Procedure MyListViewGadgetCallback(hWnd, Msg, wParam, lParam)
Protected old = GetProp_(hWnd, #MyAPP_OldWindProc)
Protected tme.TRACKMOUSEEVENT
Select Msg
Case #WM_MOUSEMOVE
With tme
\cbSize = SizeOf(TRACKMOUSEEVENT)
\dwFlags = #TME_HOVER
\hwndTrack = hWnd
\dwHoverTime = 1000
EndWith
TrackMouseEvent_(tme)
Case #WM_MOUSEHOVER
Debug "hover"
Case #WM_NCDESTROY
RemoveProp_(hWnd, #MyAPP_OldWindProc)
EndSelect
ProcedureReturn CallWindowProc_(old, hWnd, Msg, wParam, lParam)
EndProcedure
If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0, 10, 10, 250, 120)
For a = 1 To 12
AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
Next
SetGadgetState(0, 9)
old = SetWindowLongPtr_(GadgetID(0), #GWLP_WNDPROC, @MyListViewGadgetCallback())
SetProp_(GadgetID(0), #MyAPP_OldWindProc, old)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Overview LitsViewGadget
Hot tracking ListViewGadget()
Code: Select all
#LB_ITEMFROMPOINT = $1A9
OpenWindow(0,200,200,200,200,"Test",#PB_Window_SystemMenu)
ListViewGadget(1,10,10,180,180)
AddGadgetItem(1,-1,"first item")
AddGadgetItem(1,-1,"second item")
AddGadgetItem(1,-1,"third item")
AddGadgetItem(1,-1,"fourth item")
AddGadgetItem(1,-1,"fifth item")
AddGadgetItem(1,-1,"first item")
AddGadgetItem(1,-1,"second item")
AddGadgetItem(1,-1,"third item")
AddGadgetItem(1,-1,"fourth item")
AddGadgetItem(1,-1,"fifth item")
AddGadgetItem(1,-1,"first item")
AddGadgetItem(1,-1,"second item")
AddGadgetItem(1,-1,"third item")
AddGadgetItem(1,-1,"fourth item")
AddGadgetItem(1,-1,"fifth item")
AddGadgetItem(1,-1,"first item")
AddGadgetItem(1,-1,"second item")
AddGadgetItem(1,-1,"third item")
AddGadgetItem(1,-1,"fourth item")
AddGadgetItem(1,-1,"fifth item")
itemh = SendMessage_(GadgetID(1), #LB_GETITEMHEIGHT, 0, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
Case #WM_MOUSEMOVE
GetCursorPos_(p.POINT)
ScreenToClient_ (GadgetID(1), @p)
item = SendMessage_(GadgetID(1),#LB_ITEMFROMPOINT,0,p\y<<16+p\x)
Debug item
SetGadgetState(1,item)
EndSelect
Until Quit = 1
End
Egypt my love
Re: Overview LitsViewGadget
Thank you RASHAD