View Full Version : mouse wheel
nasersolona 10-08-2008, 11:10 AM Hello Guys!
Anyone knows how to Whell two dotnet listviews at once????
I want to wheel one list and automatically the other one.
i have this:
on myListview MouseWheel events do
(
--I dont know how to pass the events to the other listview
)
thanks.
|
|
nasersolona
10-09-2008, 07:07 PM
anyone knows???
ypuech
10-09-2008, 07:56 PM
Eduardo,
I think the best solution for UI interaction would be to change the SelectedIndices or SelectedItems value. This way the ScrollBar will be updated automatically.
ZeBoxx2
10-10-2008, 02:56 AM
if you don't want to check the selection, and presuming both listviews are of the same size (scrolling in tandem makes me think they are), then you might be able to get the current scroll amount for one listview, then apply the same scroll amount to the other.
ypuech
10-10-2008, 07:16 AM
if you don't want to check the selection, and presuming both listviews are of the same size (scrolling in tandem makes me think they are), then you might be able to get the current scroll amount for one listview, then apply the same scroll amount to the other.
I thought about that also but it seems you can only do that with a ScrollBar control. There's no way to get ListView ScrollBar or Scroll value.
nasersolona
10-10-2008, 08:50 AM
thanks ypuech, but i don't know how to control the scrolling of a listview for an ScrollBar control, what are the methods to use? I can't find any reference
thanks again
ypuech
10-10-2008, 11:06 AM
As I said in my previous post, there's no way to get ListView ScrollBar or Scroll value.
But why do you want to scroll two ListViews at the same time ?
nasersolona
10-10-2008, 11:26 AM
well, i'm creating a tool to connect automatically facial animation shapes and morpher channels. Then, in the second listview i want to show the morpher channels and in the first listview i want to show the matching shape. So if I scroll one of the listviews i need to scroll the other one.
I have two listviews because the tool specifications say that each listview is located in a different rollout. the rollouts move at once and one is just on the left from the other.
any idea of what can i do??
thanks
ypuech
10-10-2008, 11:39 AM
In fact, I've never seen a control updating its Scroll value without mouse Wheel event in it.
But you can update a ListView when in the other, a ListView item is selected. This way, the UI will be easier to understand by the user.
nasersolona
10-10-2008, 11:55 AM
i've implemented that functionality yet. but thanks anyway. sorry for wasting your time with things that are not possible to do. jeje.
Thanks again.
Kameleon
10-10-2008, 12:02 PM
I've found a way but I dont think it's the best way yet, but it does the job. From what I've read to control the scrollbars in the listview we need to dive into the windows API and so on... Anyway, here's an example, using EnsureVisible.
(
local hForm = dotNetObject "MaxCustomControls.MaxForm"
hForm.Size = dotNetObject "System.Drawing.Size" 640 480
hForm.FormBorderStyle = (dotnetclass "System.Windows.Forms.FormBorderStyle").FixedToolWindow
hForm.Text = ""
hForm.ShowInTaskbar = False
local txtbox = dotNetObject "System.Windows.Forms.TextBox"
txtbox.location=dotNetObject "System.Drawing.Point" 10 10
local txtbox2 = dotNetObject "System.Windows.Forms.TextBox"
txtbox2.location=dotNetObject "System.Drawing.Point" 10 40
local cmbbox = dotNetObject "System.Windows.Forms.ComboBox"
cmbbox.location=dotNetObject "System.Drawing.Point" 10 80
local lstview1 = dotNetObject "System.Windows.Forms.ListView"
lstview1.location=dotNetObject "System.Drawing.Point" 200 10
lstview1.name="lstview1"
local lstview2 = dotNetObject "System.Windows.Forms.ListView"
lstview2.location=dotNetObject "System.Drawing.Point" 400 10
lstview2.name="lstview2"
local dnKeys=dotnetclass "System.Windows.Forms.Keys"
hform.controls.add(txtbox)
hform.controls.add(txtbox2)
hform.controls.add(cmbbox)
hform.controls.add(lstview1)
hform.controls.add(lstview2)
seed(timestamp())
for i=1 to 20 do
(
lstview1.items.add ((random 1 256) as string)
lstview2.items.add ((random 1 256) as string)
)
local theKey=false
fn txtbox_KeyDown sender eb =
(
if (eb.Keycode==dnKeys.Tab) OR (eb.Keycode==dnKeys.Return) then theKey=eb.KeyCode else theKey=false
)
fn txtbox_KeyPress sender eb =
(
if theKey!=false then
(
case theKey of
(
(dnKeys.Tab): hform.selectnextcontrol hform.ActiveControl true true false false
(dnKeys.Return): print "Return"
)
)
)
local lstindex=0
fn lstview1_MouseWheel sender eb =
(
eb.handled=true
if eb.delta<0 then
(
if lstindex+1<sender.items.count then
(
lstindex+=1
lstview1.ensurevisible lstindex
lstview2.ensurevisible lstindex
)
)
else
(
if lstindex-1>0 then
(
lstindex-=1
lstview1.ensurevisible lstindex
lstview2.ensurevisible lstindex
)
)
)
dotnet.addEventHandler txtbox "KeyDown" txtbox_KeyDown
dotnet.addEventHandler txtbox "KeyPress" txtbox_KeyPress
dotnet.addEventHandler txtbox2 "KeyDown" txtbox_KeyDown
dotnet.addEventHandler txtbox2 "KeyPress" txtbox_KeyPress
dotnet.addEventHandler lstview1 "MouseWheel" lstview1_MouseWheel
hForm.ShowModeless()
)
PS- Sorry it has some other code I've used for the TAB handling in another example :P
nasersolona
10-10-2008, 01:05 PM
thanks, thanks anf thanks again Kameleon, it's just what i needed. I`ll implement the solution inmediately. how did you find the solution?
thanks again
Kameleon
10-10-2008, 01:09 PM
I did a search on google and saw that function, then I went to msdn to investigate it further, I'm glad it helps. Cheers :)
Kameleon
10-10-2008, 07:25 PM
Hi there, I wasnt quite satisfied, so I did a new class that helps handling the scroll by mousewheel, it works so much better! I've added it to custom control class project, so you just have to include it as an assembly, here's the example :
(
dotnet.loadAssembly @"KClasses.dll" --Dont forget to put the correct path here
local hForm = dotNetObject "MaxCustomControls.MaxForm"
hForm.Size = dotNetObject "System.Drawing.Size" 290 290
hForm.FormBorderStyle = (dotnetclass "System.Windows.Forms.FormBorderStyle").FixedToolWindow
hForm.Text = ""
hForm.ShowInTaskbar = False
local lstview1 = dotNetObject "System.Windows.Forms.ListView"
lstview1.backcolor=(dotnetclass "System.Drawing.Color").DarkCyan
lstview1.location=dotNetObject "System.Drawing.Point" 10 10
lstview1.name="lstview1"
local lstview2 = dotNetObject "System.Windows.Forms.ListView"
lstview2.location=dotNetObject "System.Drawing.Point" 150 10
lstview2.name="lstview2"
local lstview3 = dotNetObject "System.Windows.Forms.ListView"
lstview3.location=dotNetObject "System.Drawing.Point" 10 150
lstview3.name="lstview3"
local lstview4 = dotNetObject "System.Windows.Forms.ListView"
lstview4.location=dotNetObject "System.Drawing.Point" 150 150
lstview4.name="lstview4"
local vScroll=dotnetobject "KClasses.dnVScroll"
hform.controls.add(lstview1)
hform.controls.add(lstview2)
hform.controls.add(lstview3)
hform.controls.add(lstview4)
seed(timestamp())
for i=1 to 20 do
(
lstview1.items.add ((random 1 256) as string)
lstview2.items.add ((random 1 256) as string)
lstview3.items.add ((random 1 256) as string)
lstview4.items.add ((random 1 256) as string)
)
fn lstview1_MouseWheel sender eb =
(
eb.handled=true
vScroll.SetVScroll sender.handle eb
vScroll.SetVScroll lstview2.handle eb
vScroll.SetVScroll lstview3.handle eb
vScroll.SetVScroll lstview4.handle eb
)
dotnet.addEventHandler lstview1 "MouseWheel" lstview1_MouseWheel
hForm.ShowModeless()
)
And here's the Dll as an attachment... Cya!
CGTalk Moderation
10-10-2008, 07:25 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.