目前我采用在窗体内加个和窗体大小一样的图片框,所有的控件在图片框内放置,在电脑显示分辨率:1280*1024下编辑好窗体。然后在电脑显示分辨率:1024*768下进行程序调试,结果是看不到最下面的和最左边的控件,而后采用加上hscroll和vscrol1的方式,控制代码如下:
Private Sub VS1_Scroll()
 HS1.Top = Screen.Height '''+ VS1.Value  ''HS1.Height +
 HS1.Max = Screen.Height
    F3Pic2.Top = 0 - VS1.Value
End Sub
Private Sub VS1_Change()
    F3Pic2.Top = 0 - VS1.Value
End SubPrivate Sub HS1_Change()
 '''+ HS1.Value ''VS1.Width +
  VS1.Max = Screen.Width
    F3Pic2.Left = 0 - HS1.Value
End SubPrivate Sub HS1_Scroll()
VS1.Left = Screen.Width
    F3Pic2.Left = 0 - HS1.Value
End SubPrivate Sub ShowHV()        '检测是否显示滚动条的过程.
    
出现的问题是:垂直滚动条在窗体启动时能显示,并能拖动,水平的滚动条不能显示,在垂直滚动条拖动到能看到水平滚动条后也能拖动,但是他们不能始终分别在屏幕的最下方和最右边!请高手指点,我想用滚动条控制其像网页那样上下、左右拖动。

解决方案 »

  1.   

    HS1.Top = Screen.Height '''+ VS1.Value  ''HS1.Height +
    大哥,这是什么呀!!
    hs1.top=0
      

  2.   

    窗体中放置一个水平滚动条HScroll1(需要确定它的高度)和一个垂直滚动条VScroll1(需要确定它的宽度),它们的放置位置任意。
    窗体中再放置一个图片控件Picture1,你程序中用到的其他控件放置在这个Picture1中。
    其他的,下面的代码会在运行后帮你搞定的。Option Explicit'Powered By JadeluoPrivate Sub Form_Resize()
        VScroll1.Top = 0
        VScroll1.Left = Me.ScaleWidth - VScroll1.Width
        VScroll1.Height = Me.ScaleHeight - HScroll1.Height
        VScroll1.Max = Picture1.Height - Me.ScaleHeight
        VScroll1.Visible = VScroll1.Max > VScroll1.Min
        
        HScroll1.Left = 0
        HScroll1.Top = Me.ScaleHeight - HScroll1.Height
        HScroll1.Width = Me.ScaleWidth - VScroll1.Width
        HScroll1.Max = Picture1.Width - Me.ScaleWidth
        HScroll1.Visible = HScroll1.Max > HScroll1.Min
        
        Picture1.Left = HScroll1.Value
        Picture1.Top = -VScroll1.Value
    End SubPrivate Sub HScroll1_Change()
        Picture1.Left = -HScroll1.Value
    End SubPrivate Sub HScroll1_Scroll()
        HScroll1_Change
    End SubPrivate Sub VScroll1_Change()
        Picture1.Top = -VScroll1.Value
    End SubPrivate Sub VScroll1_Scroll()
        VScroll1_Change
    End Sub
      

  3.   

    你需要用两个图片框,将包含有控件的图片框放到另一个图片框中,滚动条放在两个图片框的外面(即直接放窗体上)。修改滚动条事件及“Form_Resize”事件以动态改变图片框的大小以及滚动条的值。在滚动条事件中,让内部的图片框在外侧的图片框中进行移动。
    不要将滚动条放在图片框中,IE中是view视图不是图片框,它们的实现效果是不同的,只用一个图片框实现出来的外观很不好看。
      

  4.   

    Private Sub Form_Resize()
    Dim w, h
    Me.WindowState = 2
    VS1.Move Me.ScaleWidth - VS1.Width, 0, VS1.Width, Me.ScaleHeight - HS1.Height
    HS1.Move 0, Me.ScaleHeight - HS1.Height, Me.ScaleWidth - VS1.Width, HS1.Height
    Picture2.Move 0, 0, Me.ScaleWidth - VS1.Width, Me.ScaleHeight - HS1.Height
    Picture1.Move 0, 0, 1268, 1024
    Text2.Move Picture1.ScaleWidth - Text2.Width, Picture1.ScaleHeight - Text2.Height
    HS1.Max = Picture1.Width + VS1.Width - Me.ScaleWidth: VS1.Max = Picture1.Height + HS1.Height - Me.ScaleHeight
    End SubPrivate Sub HS1_Change()
        Picture1.Left = -HS1.Value
    End SubPrivate Sub HS1_GotFocus()
        Text1.SetFocus
    End SubPrivate Sub HS1_Scroll()
        Picture1.Left = -HS1.Value
    End SubPrivate Sub VS1_Change()
        Picture1.Top = -VS1.Value
    End SubPrivate Sub VS1_GotFocus()
        Text1.SetFocus
    End SubPrivate Sub VS1_Scroll()
        Picture1.Top = -VS1.Value
    End Sub
    最大化窗体,两个图片框,将包含有控件的图片框放到另一个图片框中,滚动条放在窗体上,测试
      

  5.   

    此问题如果很好的解决,另外会再发200分给真正解决问题的高人,决不食言!!!继续期待解决办法ING
      

  6.   

    jadeluo(秀峰) 的方法不就是挺好的吗?
    VERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   5910
       ClientLeft      =   60
       ClientTop       =   450
       ClientWidth     =   8490
       LinkTopic       =   "Form1"
       ScaleHeight     =   5910
       ScaleWidth      =   8490
       StartUpPosition =   3  '窗口缺省
       Begin VB.PictureBox Picture2 
          BorderStyle     =   0  'None
          Height          =   495
          Left            =   9240
          ScaleHeight     =   495
          ScaleWidth      =   375
          TabIndex        =   7
          Top             =   6960
          Width           =   375
       End
       Begin VB.VScrollBar VScroll1 
          Height          =   5055
          Left            =   8400
          TabIndex        =   1
          TabStop         =   0   'False
          Top             =   360
          Width           =   375
       End
       Begin VB.HScrollBar HScroll1 
          Height          =   375
          Left            =   120
          TabIndex        =   0
          TabStop         =   0   'False
          Top             =   6600
          Width           =   7695
       End
       Begin VB.PictureBox Picture1 
          BorderStyle     =   0  'None
          Height          =   6975
          Left            =   0
          ScaleHeight     =   6975
          ScaleWidth      =   9015
          TabIndex        =   2
          Top             =   0
          Width           =   9015
          Begin VB.ListBox List2 
             Height          =   1140
             Left            =   5400
             TabIndex        =   6
             Top             =   1920
             Width           =   2415
          End
          Begin VB.ListBox List1 
             Height          =   960
             Left            =   240
             TabIndex        =   5
             Top             =   5280
             Width           =   2175
          End
          Begin VB.CommandButton Command2 
             Caption         =   "Command2"
             Height          =   1095
             Left            =   6840
             TabIndex        =   4
             Top             =   5880
             Width           =   2175
          End
          Begin VB.CommandButton Command1 
             Caption         =   "Command1"
             Height          =   1215
             Left            =   840
             TabIndex        =   3
             Top             =   1440
             Width           =   2655
          End
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Const SMALLX = 100
    Const SMALLY = 100
    Private Sub Form_Resize()
        If Me.WindowState = vbMinimized Then
            Exit Sub
        End If
        VScroll1.Top = 0
        VScroll1.Left = Me.ScaleWidth - VScroll1.Width
        VScroll1.Height = Me.ScaleHeight - HScroll1.Height
        VScroll1.Max = (Picture1.Height - Me.ScaleHeight + HScroll1.Height) / SMALLY
        VScroll1.Visible = VScroll1.Max > VScroll1.Min
        
        HScroll1.Left = 0
        HScroll1.Top = Me.ScaleHeight - HScroll1.Height
        HScroll1.Width = Me.ScaleWidth - VScroll1.Width
        HScroll1.Max = (Picture1.Width - Me.ScaleWidth + VScroll1.Width) / SMALLX
        HScroll1.Visible = HScroll1.Max > HScroll1.Min
        
        Picture1.Left = HScroll1.Value
        Picture1.Top = -VScroll1.Value
        Picture2.Move Me.ScaleWidth - VScroll1.Width, Me.ScaleHeight - HScroll1.Height, VScroll1.Width, HScroll1.Height
    End SubPrivate Sub HScroll1_Change()
        Picture1.Left = -HScroll1.Value * SMALLX
    End SubPrivate Sub HScroll1_Scroll()
        HScroll1_Change
    End SubPrivate Sub VScroll1_Change()
        Picture1.Top = -VScroll1.Value * SMALLY
    End SubPrivate Sub VScroll1_Scroll()
        VScroll1_Change
    End Sub
      

  7.   

    Private Sub Form_Resize()
    Dim w, h
    Me.WindowState = 2
    VS1.Move Me.ScaleWidth - VS1.Width, 0, VS1.Width, Me.ScaleHeight - HS1.Height
    HS1.Move 0, Me.ScaleHeight - HS1.Height, Me.ScaleWidth - VS1.Width, HS1.Height
    Picture2.Move 0, 0, Me.ScaleWidth - VS1.Width, Me.ScaleHeight - HS1.Height
    Picture1.Move 0, 0, 1268, 1024
    Text2.Move Picture1.ScaleWidth - Text2.Width, Picture1.ScaleHeight - Text2.Height
    HS1.Max = Picture1.Width + VS1.Width - Me.ScaleWidth: VS1.Max = Picture1.Height + HS1.Height - Me.ScaleHeight
    End SubPrivate Sub HS1_Change()
        Picture1.Left = -HS1.Value
    End SubPrivate Sub HS1_GotFocus()
        Text1.SetFocus
    End SubPrivate Sub HS1_Scroll()
        Picture1.Left = -HS1.Value
    End SubPrivate Sub VS1_Change()
        Picture1.Top = -VS1.Value
    End SubPrivate Sub VS1_GotFocus()
        Text1.SetFocus
    End SubPrivate Sub VS1_Scroll()
        Picture1.Top = -VS1.Value
    End Sub
    这个就能达到要求!
      

  8.   

    一个图片框就够了,所谓滚动其实是改变图片框的Top和Left属性。
      

  9.   

    加两个picturebox,picturebox1,picturebox2
      两个scroll
    将所有的控件扔到picturebox1里,再把picturebox1扔到picture2里
    这样 你只需当做两个控件来看待就可以,代码应该很容易写
      

  10.   

    偶也遇到过这问题,后来引用了下面的代码问题就解决了,现在还一直在用,你可试试:
    先在窗体上拖一个双屏幕长的frame1框(你的所有内容都可以在这上面拖出),高18000;宽15085;(窗体的属性Scalemode取1-Twip)
    然后拖水平与垂直的两个滚动条;
    Vscrloo1(竖滚动条)属性:LargeChange=20000,Max=11055
    HScroll1(横)属性:LargeChange=8000;Max=1000;Top=18000;Width=14040
    上面是偶的选用参数,你可自选;
    建立一个模块:下面代码放进去
    Option Explicit
    Public Type POINTL
        x As Long
        y As Long
    End Type
    Declare Function CallWindowProc _
        Lib "user32" Alias "CallWindowProcA" _
            (ByVal lpPrevWndFunc As Long, _
            ByVal hwnd As Long, _
            ByVal Msg As Long, _
            ByVal wParam As Long, _
            ByVal lParam As Long) As Long
    Declare Function SetWindowLong _
        Lib "user32" Alias "SetWindowLongA" _
            (ByVal hwnd As Long, _
            ByVal nIndex As Long, _
            ByVal dwNewLong As Long) As Long
    Declare Function SystemParametersInfo _
        Lib "user32" Alias "SystemParametersInfoA" _
            (ByVal uAction As Long, _
            ByVal uParam As Long, _
            lpvParam As Any, _
            ByVal fuWinIni As Long) As Long
    Declare Function ScreenToClient Lib "user32" _
    (ByVal hwnd As Long, xyPoint As POINTL) As Long
    Public Const GWL_WNDPROC = -4
    Public Const SPI_GETWHEELSCROLLLINES = 104
    Public Const WM_MOUSEWHEEL = &H20A
    Public WHEEL_SCROLL_LINES As Long
    Global lpPrevWndProc As Long
    Public Sub Hook(ByVal hwnd As Long)
        lpPrevWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)
        Call SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, WHEEL_SCROLL_LINES, 0)
        If WHEEL_SCROLL_LINES > Form1.VScroll1.Max Then
            WHEEL_SCROLL_LINES = Form1.VScroll1.Max
        End If
    End Sub
    Public Sub UnHook(ByVal hwnd As Long)
        Dim lngReturnValue As Long
        lngReturnValue = SetWindowLong(hwnd, GWL_WNDPROC, lpPrevWndProc)
    End Sub
    Function WindowProc(ByVal hw As Long, _
            ByVal uMsg As Long, _
            ByVal wParam As Long, _
            ByVal lParam As Long) As Long
        Dim pt As POINTL
        Select Case uMsg
            Case WM_MOUSEWHEEL
                If wParam = -7864320 Then
                    If Form1.VScroll1.Value <= Form1.VScroll1.Max - 300 Then '4个300值可调鼠标滚轮移动屏幕的速度,可取100-500
                        Form1.VScroll1.Value = Form1.VScroll1.Value + 300
                    Else
                        Form1.VScroll1.Value = Form1.VScroll1.Max
                    End If
                ElseIf wParam = 7864320 Then
                    If Form1.VScroll1.Value >= 300 Then
                        Form1.VScroll1.Value = Form1.VScroll1.Value - 300
                    Else
                        Form1.VScroll1.Value = 0
                    End If
                End If
            Case Else
                WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
        End Select
    End FunctionPublic Function HIWORD(LongIn As Long) As Integer
      HIWORD = (LongIn And &HFFFF0000) \ &H10000
    End Function
    Public Function LOWORD(LongIn As Long) As Integer
          LOWORD = LongIn And &HFFFF&
    End Function下面代码放在窗体中:
    Private Sub Form_Load()
        Hook Me.hwnd
    End Sub
    Private Sub Form_Resize()
        If Frame1.Height > Me.Height Then
            VScroll1.Visible = True
        Else
            VScroll1.Visible = False
        End If
        If Frame1.Width > Me.Width Then
            HScroll1.Visible = True
        Else
            HScroll1.Visible = False
        End If
        HScroll1.Left = 0
        HScroll1.Top = Me.ScaleHeight - HScroll1.Height
        VScroll1.Left = Me.ScaleWidth - VScroll1.Width
        VScroll1.Top = 0
        HScroll1.Width = Me.ScaleWidth
        VScroll1.Height = Me.ScaleHeight
        If VScroll1.Visible = True Then
            If HScroll1.Visible = True Then
               HScroll1.Width = Abs(Me.ScaleWidth - VScroll1.Width)
               VScroll1.Height = Abs(Me.ScaleHeight - HScroll1.Height)
            End If
        End If
        HScroll1.Max = (Frame1.Width - Me.Width) + 3 * VScroll1.Width
        VScroll1.Max = (Frame1.Height - Me.Height) + 3 * HScroll1.Height
         HScroll1.ZOrder
         VScroll1.ZOrder
        End Sub
    Private Sub Form_Unload(Cancel As Integer)
        UnHook Me.hwnd
    End Sub
    Private Sub HScroll1_Change()
        Frame1.Left = -HScroll1.Value
    End Sub
    Private Sub VScroll1_Change()
        Frame1.Top = -VScroll1.Value
    End Sub
    Private Sub VScroll1_GotFocus() '此段可防止滚动条闪烁,借用一个按钮控件
        Command1.SetFocus
    End Sub
      

  11.   

    JRS123(北京奥运世界关注) ( ) 信誉:100    Blog 
    你的代码中在我拖动后,滚动条不能随时始终显示在低端或者右边,也跟着跑到屏幕的中央
      

  12.   

    搞定,滚动条放在窗体上,不放在Frame1内就可以,可以优化代码了,谢谢大家的帮助!