Microsoft KB Archive/190179

= How To Change ProgressBar Orientation at Run-Time =

Article ID: 190179

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q190179



SUMMARY
When changing the Orientation property of a ProgressBar, the bar changes position on the form. If this Orientation is changed at run-time, it could overlap other controls or be displayed off the visible portion of the form. This article describes how to change the Orientation and keep the control in the same position.



Step-by-Step Example
 Start a new Visual Basic project. Form1 is created by default. Select Components from the Project menu. Check "Microsoft Windows Common Controls 6.0" and click OK. Add a Progress Bar, ProgessBar1, to Form1. Add a CommandButton, Command1, to Form1.  Add the following code to Form1's code window: Private Sub Command1_Click Dim iWidth As Integer Dim iHeight As Integer Dim iLeft As Integer Dim iTop As Integer

' Store the current position iWidth = ProgressBar1.Width iHeight = ProgressBar1.Height iLeft = ProgressBar1.Left iTop = ProgressBar1.Top

' This only works with Smooth Scrolling ProgressBar1.Scrolling = ccScrollingSmooth

' Change the Orientation to the opposite If ProgressBar1.Orientation = ccOrientationVertical Then ProgressBar1.Orientation = ccOrientationHorizontal Else ProgressBar1.Orientation = ccOrientationVertical End If

' Reset the new position with the old position ProgressBar1.Width = iWidth ProgressBar1.Height = iHeight ProgressBar1.Left = iLeft ProgressBar1.Top = iTop

DoEvents Form1.Refresh ProgressBar1.Value = 0 ProgressBar1.Max = 1000 For i = 1 To 1000 ProgressBar1.Value = i        Next i      End Sub

 Run the Project and click Command1 multiple times to see vertical and horizontal scrolling.</ol>

Additional query words: kbControl kbVBp kbdsd kbDSupport kbVBp600

Keywords: kbhowto KB190179

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.