Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) MouseWheel? (VB.Net) (Read 6552 times)
Mark_Wills
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Mar 6th, 2006
MouseWheel? (VB.Net)
Sep 19th, 2006 at 9:43am
Print Post  
Has anyone found out how to scroll the flow chart client area using the mouse wheel?

I found an example in C# on this forum from January, but I don't understand it at all!

Anyone done it in VB?

kind regards

Mark Wills
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MouseWheel? (VB.Net)
Reply #1 - Sep 19th, 2006 at 10:22am
Print Post  
Hi,

Implement the MouseWheel event handler like this:

Code
Select All
Private Sub fc_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles fc.MouseWheel
  Dim fcSender As FlowChart = sender

  Dim newScrollY As Single = fcSender.ScrollY - e.Delta / 50

  If newScrollY > fcSender.DocExtents.Top Then _
    fcSender.ScrollY = newScrollY
End Sub

 



For some reason the MouseWheel event is not visible from the C# form editor, but VB.NET displays it fine in the form events combo box.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Mark_Wills
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Mar 6th, 2006
Re: MouseWheel? (VB.Net)
Reply #2 - Sep 19th, 2006 at 11:31am
Print Post  
Thanks Stoyan:

Dim fcSender As FlowChart = sender

That doesn't look right to me... Are you thinking of CType()?

The code doesn't build as written.

Or maybe you're thinking of Dim fcSender As NEW FlowChart = sender ????

Regards

Mark
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MouseWheel? (VB.Net)
Reply #3 - Sep 19th, 2006 at 11:41am
Print Post  
It works fine in my VS2003 test project. What error message did the compiler show? Do you use the "Option Strict" compiler directive?

Regards
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MouseWheel? (VB.Net)
Reply #4 - Sep 19th, 2006 at 11:47am
Print Post  
This should work fine with "Option Strict":

Code
Select All
Private Sub fc_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles fc.MouseWheel
  Dim fcSender As FlowChart = CType(sender, FlowChart)

  Dim newScrollY As Single = fcSender.ScrollY - e.Delta / 50.0F

  If newScrollY > fcSender.DocExtents.Top Then _
    fcSender.ScrollY = newScrollY
End Sub
 



Stoyan
  
Back to top
 
IP Logged
 
Mark_Wills
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Mar 6th, 2006
Re: MouseWheel? (VB.Net)
Reply #5 - Sep 19th, 2006 at 12:08pm
Print Post  
Thanks Stoyan,

Yes, I use option strict 'everything'  Smiley

Yes, I thought you wanted a CType in there somewhere!

Also, it didn't like 'FlowChart' but thats because I don't use the Imports directive - I prefer to use the fully qualified names - makes lines longer, but you know exactly whats going on!

I'll give this a try!

Mark.
  
Back to top
 
IP Logged
 
Mark_Wills
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Mar 6th, 2006
Re: MouseWheel? (VB.Net)
Reply #6 - Sep 19th, 2006 at 12:12pm
Print Post  
Perfect Stoyan,

You rock!

Here's the code I used in the end:

       Dim fcSender As MindFusion.FlowChartX.FlowChart = CType(sender, MindFusion.FlowChartX.FlowChart)

       Dim newScrollY As Single = fcSender.ScrollY - e.Delta / 20.0F

       If newScrollY > fcSender.DocExtents.Top Then _
         fcSender.ScrollY = newScrollY

Definatley more long winded, but as I said, still being on the .Net learning curve, I don't like to assume anything!

Regards

Mark
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MouseWheel? (VB.Net)
Reply #7 - Sep 19th, 2006 at 12:29pm
Print Post  
8)
  
Back to top
 
IP Logged
 
heinrich
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Oct 18th, 2006
Re: MouseWheel? (VB.Net)
Reply #8 - Feb 15th, 2007 at 10:32am
Print Post  
Have anyone done this with Delphi 2006 (WinForms not VCL)?

/Heinrich
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MouseWheel? (VB.Net)
Reply #9 - Feb 16th, 2007 at 5:57am
Print Post  
Should look like this in Delphi:

Code
Select All
procedure TWinForm1.FC_MouseWheel(sender: System.Object; e: MouseEventArgs);
var newScrollY : Single;
begin
	newScrollY := System.Single(fc.ScrollY - e.Delta / 20);
	if newScrollY > fc.DocExtents.Top then
     begin
	 fc.ScrollY := newScrollY;
     end;
end;
 



Stoyan
  
Back to top
 
IP Logged
 
heinrich
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Oct 18th, 2006
Re: MouseWheel? (VB.Net)
Reply #10 - Feb 16th, 2007 at 6:30am
Print Post  
Thank you, I will try this at once.
Smiley

/Heinrich
  
Back to top
 
IP Logged
 
heinrich
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Oct 18th, 2006
Re: MouseWheel? (VB.Net)
Reply #11 - Feb 16th, 2007 at 7:09am
Print Post  
Hi again

The code seems ok, but nothing happens.
It seems like no call from Delphi to this procedure is done. Do you know from where it should be called?

???
  
Back to top
 
IP Logged
 
Mark_Wills
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Mar 6th, 2006
Re: MouseWheel? (VB.Net)
Reply #12 - Feb 16th, 2007 at 7:15am
Print Post  
I know nothing about Delphi, but the code, as written seems to be a standard 'procedure', as opposed to an event.

Thus, I would summise that an event handler would have to be set up, such that when the mousewheel event fires, it called the procedure.

Regards

Mark
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MouseWheel? (VB.Net)
Reply #13 - Feb 16th, 2007 at 2:12pm
Print Post  
Hi,

You must attach the procedure to the event  -

Include(Self.fc.MouseWheel, Self.FC_MouseWheel);

Stoyan
  
Back to top
 
IP Logged
 
heinrich
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Oct 18th, 2006
Re: MouseWheel? (VB.Net)
Reply #14 - Feb 19th, 2007 at 5:50am
Print Post  
Thanks a lot. This made it work.

Smiley

/Heinrich
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint