1. Bug in 'hitTestLV'

Found a bug in hitTestLV when compiled, but it works ok when interpreted. Instead of returning a sequence when clicking a list view item, it is returning a zero.

Was checking for RightDown in mouse event and using hitTestLV to find which row in list view was clicked. After finding bug, I changed it to RightUP, and then used getLVSelected to find which row was clicked. New way works fine, but there might be a case in the future where hitTestLV would be better.

I also have a question about hitTestLV. The manual says it will return an {item, subitem} sequence, what does subitem represent?. The item part is the row number of the list view, but subitem is always 1.

-- Bug in 'hitTestLV' See details in procedure 'ListView_One_Mouse' 
 
-- OS: Windows Vista Home Premium: Service Pack 2 
-- euphoria v4.0.3 
-- Win32lib v0.70.20 
-- gcc v4.6.1 
-- Compile command line: euc -gcc -lflags "-mwindows c:\euphoria\bin\eu.a -mu3" -lib C:\euphoria\bin\eu.a hitTestLV_Test.exw 
 
include Win32lib.ew 
 
constant Main_Window = create(Window, "Bug Test: hitTestLV", 0, 200, 200, 500, 300, 0) 
 
constant ListView_One = create(ListView, "Column 1", Main_Window, 8, 8, 200, 100, w32or_all({LVS_REPORT, LVS_SHOWSELALWAYS})) 
	addLVItem(ListView_One, 0, "Item 1") 
 
procedure ListView_One_Mouse(integer self, integer event, sequence params) 
	-- The Bug only surfaces with the compiled exe, interpreted exw runs fine. 
	-- When 'Item 1' is clicked 'hitTestLV' will return '0', it should return '{1,1}'. 
	-- This causes a row selection error if Index is declared as an object, 
	-- and a crash if Index is declared as a 'sequence', 
	-- due to a type mismatch assigning '0' to Index 
	-- If clicking on empty space in 'ListView_One', 'hitTestLV' will return an empty sequence '{}', as expected. 
	-- The exw will return '{1,1}' when clicking 'Item 1', as expected	 
	sequence Index 
	if params[1] = LeftUp then 
		Index = hitTestLV(ListView_One) 
		pretty_print(1, Index, {}) 
	end if 
end procedure 
setHandler(ListView_One, w32HMouse, routine_id("ListView_One_Mouse")) 
 
WinMain(Main_Window, Normal) 
new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu