RE: Syncronising Lists
- Posted by pg_russell at lineone.net Apr 22, 2002
- 366 views
Hi There, Here is my attempt at synchronising lists. This one involves subclassing the list windows so that mouse and keyboard events are processed early enough to avoid any time lag in updating the other lists. Regards, 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 -- intercept clicks and keypresses in the list boxes if iMsg = WM_LBUTTONDOWN or iMsg = WM_KEYDOWN then -- allow list box to process the message void = w32Func( xCallWindowProc, { oldwndproc, hWnd, iMsg, wParam, lParam } ) -- 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 -- we have processed this message so return false return 0 end if -- pass all other messages to the default list box procedure return w32Func( xCallWindowProc, { oldwndproc, hWnd, iMsg, wParam, lParam } ) 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")) } ) -- Display window WinMain( Test, Normal )