Ovlßdßnφ posuvnφk∙ MDI formulß°e pomocφ klßves

Postup:
Zalo₧te nov² projekt. Standardn∞ se vytvo°φ Form1. Nastavte mu vlastnost MDIChild na True a na udßlost Form_KeyDown zapiÜte:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

   processKey KeyCode

End Sub

Nynφ do projektu p°idejte modul. Do deklaraΦnφ Φßsti modulu zapiÜte:

Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _
ByVal wCmd As Long) As Long

Public Const SB_BOTTOM = 7
Public Const SB_LEFT = 6
Public Const SB_LINEDOWN = 1
Public Const SB_LINELEFT = 0
Public Const SB_LINERIGHT = 1
Public Const SB_LINEUP = 0
Public Const SB_PAGEDOWN = 3
Public Const SB_PAGELEFT = 2
Public Const SB_PAGERIGHT = 3
Public Const SB_PAGEUP = 2
Public Const SB_RIGHT = 7
Public Const SB_THUMBPOSITION = 4
Public Const SB_THUMBTRACK = 5
Public Const SB_TOP = 6
Public Const SB_ENDSCROLL = 8

Public Const WM_HSCROLL = &H114
Public Const WM_VSCROLL = &H115

Public Const GW_CHILD = 5


Public Sub processKey(KeyCode As Integer)

   Dim mdiclientwin As Long

   Select Case KeyCode
      Case vbKeyDown
         mdiclientwin = GetWindow(MDIForm1.hwnd, GW_CHILD)
         SendMessage mdiclientwin, WM_VSCROLL, SB_LINEDOWN, ByVal 0&

      Case vbKeyUp
         mdiclientwin = GetWindow(MDIForm1.hwnd, GW_CHILD)
         SendMessage mdiclientwin, WM_VSCROLL, SB_LINEUP, ByVal 0&

      Case vbKeyPageUp
         mdiclientwin = GetWindow(MDIForm1.hwnd, GW_CHILD)
         SendMessage mdiclientwin, WM_VSCROLL, SB_PAGEUP, ByVal 0&

      Case vbKeyPageDown
         mdiclientwin = GetWindow(MDIForm1.hwnd, GW_CHILD)
         SendMessage mdiclientwin, WM_VSCROLL, SB_PAGEDOWN, ByVal 0&

      Case vbKeyRight
         mdiclientwin = GetWindow(MDIForm1.hwnd, GW_CHILD)
         SendMessage mdiclientwin, WM_HSCROLL, SB_LINERIGHT, ByVal 0&

      Case vbKeyLeft
         mdiclientwin = GetWindow(MDIForm1.hwnd, GW_CHILD)
         SendMessage mdiclientwin, WM_HSCROLL, SB_LINELEFT, ByVal 0&

   End Select

End Sub

Dßle do projektu p°idejte MDI formulß° a nastavte jej jako startovacφ objekt projektu. Do formulß°e p°idejte menu s jednou volbou a na udßlost Click tΘto polo₧ky zapiÜte:

Form1.Show

Spus¥te projekt a p°esu≥te Form1 tak, aby se vytvo°ili posuvnφky na MDI formulß°i. Nynφ vyzkouÜejte kurzorovΘ Üipky.

Zp∞t

Autor: The Bozena