Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Alternatives to scroll control

Hello,

 

Currently I am using a graph control(ni waveformgraph) in a vb app (vs2010) . Scrolling, which works well by my point of view, is deemed too complicated by the client. They want (of course) something "different". The native way to scroll the graph is to hold down the CTRL key and "grab" the wavefrom and move it.

 

Is there a way to implement say horizontal scrolling by pressing a button for left and a buttonn for right scrolling? A button press would scrool it one tic(basic X axis resolution). I have thought about using sendkeys but I thoght I should aks if someone might already have a solution.

 

Thanks,

bartj

 

 

 

0 Kudos
Message 1 of 6
(4,942 Views)

I haven't seen an implementation like this before. Have you tried using send keys like you mentioned?

0 Kudos
Message 2 of 6
(4,915 Views)

All,

 

I was able to make this work in the following manner:

 

Public Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32)

    Const VK_LEFT = &H25
    Const VK_UP = &H26
    Const VK_RIGHT = &H27
    Const VK_DOWN = &H28
    Const VK_CONTROL = &H11
    Public Const KEYEVENTF_KEYUP = &H2

 

 Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click

        ' test to scroll the graph without the mouse or multi keys...

        ' must set the focu to the graph
        WaveformGraph1.Focus()

        keybd_event(VK_CONTROL, 0, 0, 0) ' press ctrl
        keybd_event(VK_LEFT, 0, 0, 0) ' press left arrow
        keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0) ' releaseleft arrow
        keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0) ' release ctrl
       

    End Sub

 

 

 

0 Kudos
Message 3 of 6
(4,913 Views)

Hello,

I would say that your approach is unnecessary complicated. You should obtain your X/Y axis from your graph property, and simply change it's range.

So if you like to scroll your graph on Yaxis by let's say 1 unit down you should do this (sorry for C#):

void button_Click(...)
{
	var currentRange = yourGraphName.YAxes[indexOfAxe].Range;
	yourGraphName.YAxes[indexOfAxe].Range = new Range(currentRange.Minimum - 1, currentRange.Maximum - 1);
}

 I wrote this code from top of my head and without trying it, because I don't have access to computer with MS installed at this moment, so there might be some errors. However this code has much better approach to your problem in my opinion.

Best regards,

Filip S.

0 Kudos
Message 4 of 6
(4,909 Views)

Filip,

 

Your solution works great! I just needed to change the axis from y to x for my needs. Great simple solution.

Thanks!

bartj

0 Kudos
Message 5 of 6
(4,897 Views)

I'm happy to hear that. You are welcome.

Filip S.

0 Kudos
Message 6 of 6
(4,888 Views)