RE: Syncronising Lists
- Posted by pg_russell at lineone.net Apr 23, 2002
- 380 views
Hi, Oops! Included a fix for when the user drags the mouse in a list window (and tidied up a bit). Phil Russell include Win32Lib.ew without warning integer oldwndproc, void -- Window Test global constant Test = create( Window, "List Sync", 0, Default, Default, 333, 230, 0 ) global constant List1 = create( List, "List1", Test, 8, 12, 92, 172, 0 ) global constant List2 = create( List, "List2", Test, 116, 12, 92, 172,0 ) global constant List3 = create( List, "List3", Test, 222, 12, 92, 172, 0 ) for n = 1 to 10 do addItem(List1, "item " & sprint(n) & " list1") addItem(List2, "item " & sprint(n) & " list2") addItem(List3, "item " & sprint(n) & " list3") end for function Test_WndProc( atom hWnd, atom iMsg, atom wParam, atom lParam ) integer pos, ret -- allow list box to process the message ret = w32Func( xCallWindowProc, { oldwndproc, hWnd, iMsg, wParam, lParam } ) -- intercept clicks and keypresses in the list boxes if iMsg = WM_LBUTTONDOWN or iMsg = WM_KEYDOWN or iMsg = WM_LBUTTONUP -- user drags the mouse in the list box or (iMsg = WM_MOUSEMOVE and and_bits(wParam, MK_LBUTTON)) then -- get the resulting list box selection pos = w32Func( xSendMessage, {hWnd, LB_GETCURSEL, 0, 0 } ) -- if valid then update the other list boxes if pos >= 0 then if hWnd != getHandle(List1) then setIndex(List1, pos+1) end if if hWnd != getHandle(List2) then setIndex(List2, pos+1) end if if hWnd != getHandle(List3) then setIndex(List3, pos+1) end if end if end if -- return value from default list box procedure return ret end function -- Subclass the list boxes oldwndproc = w32Func( xSetWindowLong, { getHandle(List1), GWL_WndProc, call_back(routine_id("Test_WndProc")) } ) void = w32Func( xSetWindowLong, { getHandle(List2), GWL_WndProc, call_back(routine_id("Test_WndProc")) } ) void = w32Func( xSetWindowLong, { getHandle(List3), GWL_WndProc, call_back(routine_id("Test_WndProc")) } ) setIndex(List1, 1) setIndex(List2, 1) setIndex(List3, 1) -- Display window WinMain( Test, Normal )