i have a form and i need to use mouse scroll for moving my panel.
so i need to create event ( :) ok ok im not sure ) and No matter where the selected i need to use this event when i use mousescroll :) I hope i was explain.
is there any way to do it?


Thx to all Daniweb Family

Edited 5 Years Ago by Oneryavuz: n/a

Hi Oneryavuz

I think u r looking for intelli-zoom procedure as like AUTOCAD...
U have to keep the Mainpic(ie., ur panel) always focused using

Mainpic.Focus in key events..

'--Note: Mainpic is a panel
 Private Sub mainpic_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles mainpic.MouseWheel
        Dim xw, yw As Single
        xw = e.X / zm
        yw = e.Y / zm

        'If scrolll = True Then
        If e.Delta > 0 Then
            If zm < 20 Then
                zm = zm + 0.25
            End If
        Else
            If zm > 1 Then
                zm = zm - 0.25
            End If
        End If
        If e.X <> xw * zm Then
            mainpic.Width = 1600 * zm
            mainpic.Height = 1600 * zm
            HScrollBar1.Maximum = (1600 * zm) - coverpic.Width
            VScrollBar1.Maximum = (1600 * zm) - coverpic.Height

            xw = -(mainpic.Left - ((xw * zm) - e.X))
            yw = -(mainpic.Top - ((yw * zm) - e.Y))

            If xw <= HScrollBar1.Minimum Then
                mainpic.Left = -1
                HScrollBar1.Value = 0
            ElseIf xw >= HScrollBar1.Maximum Then
                mainpic.Left = -HScrollBar1.Maximum
                HScrollBar1.Value = HScrollBar1.Maximum
            Else
                mainpic.Left = -xw
                HScrollBar1.Value = xw
            End If

            If yw <= VScrollBar1.Minimum Then
                mainpic.Top = -1
                VScrollBar1.Value = 0
            ElseIf yw >= VScrollBar1.Maximum Then
                mainpic.Top = -VScrollBar1.Maximum
                VScrollBar1.Value = VScrollBar1.Maximum
            Else
                mainpic.Top = -yw
                VScrollBar1.Value = yw
            End If
            MDIMain.ToolStripzoom.Text = zm * 100
            mainpic.Refresh()
        End If
        'End If
    End Sub
'----ZM is the transformation value used for graphics.scaletransformation

Rgrds

Sam

umm first of all thx for this example :) but i have a program and my my form have 1024x768 pxl so when i instal this program on my notebook and my notebooks resolution is 1024x600 and i need to see between 600 - 768 pixels. then i create a scroll for this so this scroll automatically adjusts itself in accordance with a resolution of the form is loaded. and i need to control this scroll with my mousescroll . i know mousewhell event but i cant use this couse when i using textbox i cant control my scroll.

so i want to use my vbscroll everytime (when i scroll my whell i wanna use vbscroll)
sorry my english isnt enough :) i hope u understanded me

Hi Oneryavuz

I think the scroll created by you can be adjusted by changing the property of the following Vscroll.Maximum,Minimum,value while loading...

I presume ur window state while the application starts is Maximized....If u want to use a resizable form I recommend to use anchor on all sides, believe me nobody likes scroll bars nowadays ...

Also u cannot use mouse wheel since ur textbox has to be in focused state for the end user...Make the Autoscroll property for windows form to true and check..

I still have understanding problem..sorry


Rgrds

Sam

OMG i cant belive. its awsome and so easy :) Thx a lot. (autoscroll property ^^ )

Edited 5 Years Ago by Oneryavuz: n/a

This question has already been answered. Start a new discussion instead.