We have ready-made examples also hope can be sent, thank you
CodePudding user response:
Scroll Bar control plan: create a scrollable graphics viewportBesides the PictureBox control, also can use horizontal and vertical scroll bars to create a scrollable graphics viewport application, when contains graphics than the control range, a single PictureBox control cannot achieve scrolling ─ because PictureBox control cannot be added automatically scroll bar,
App using two picture boxes, called the first father of smooth PictureBox control, call the second child PictureBox controls, it contains the picture box, the father the son in the picture box contains graphic images, available scroll bar controls in the parent picture box moving picture box,
Add a scroll bar control in the design of figure 7.25
As shown in figure 7.28, first create a new project, and then draw two picture box on the form, a vertical scroll bar and a horizontal scroll bar,
Here, in the form of Form_Load event set scale model, in the father picture box to adjust the size of a picture box son, horizontal, vertical scroll bar to locate and adjust their size, and then load the bitmap graphics, add the following code to the form of the Form_Load event process:
Private Sub Form_Load ()
'set the ScaleMode to pixels,
Form1. The ScaleMode=vbPixels
Picture1. The ScaleMode=vbPixels
'the Autosize is set to True to make the boundary of the Picture2
'extension to the actual bitmap size,
Picture2. AutoSize=True
'every picture box BorderStyle property is set to None,
Picture1. BorderStyle=0
Picture2. BorderStyle=0
'to load the bitmap,
Picture2. Picture=_
LoadPicture (" c: \ Windows \ Winlogo BMP ")
'initialize the position of the two picture box,
Picture1. Move 0, 0, ScaleWidth - VScroll1. Width, _
ScaleHeight - HScroll1. Height
Picture2. Move 0, 0
'the horizontal scroll bar positioning,
HScroll1. Top=Picture1. Height
HScroll1. Left=0
HScroll1. Width=Picture1. Width
'the vertical scroll bar positioning,
VScroll1. Top=0
VScroll1. Left=Picture1. Width
VScroll1. Height=Picture1. Height
'set the Max attribute of the scroll bar,
HScroll1. Max=Picture2. Width - Picture1. Width
VScroll1. Max=Picture2. Height - Picture1. Height
'to determine whether a child picture box will be full of the screen,
'if so, you do not need to use the scroll bar,
VScroll1. Visible=(Picture1. Height & lt; _
Picture2. Height)
HScroll1. Visible=(Picture1. Width & lt; _
Picture2. Width)
End Sub
Change event to the horizontal and vertical scroll bar in the parent picture box, upper middle, left and right picture box, please add the following code to the two scroll bar control Change event:
Private Sub HScroll1_Change ()
Picture2. Left=- HScroll1. Value
End Sub
Private Sub VScroll1_Change ()
Picture2. Top=- VScroll1. Value
End Sub
The Left and Top properties of child picture box separately set to the horizontal and vertical scroll bar numerical negative, in this way, when on, down, Left, right scroll, graphics can be correctly mobile,
Runtime, display graphics as shown in figure 7.26,
Figure 7.26 runtime rolling bitmap
Run time adjust the window size
In the example above, form the initial size of the limit size of the visual graphic, at runtime when the user adjust the window size, in order to adjust the size of the graphics viewport application, can add the following code to the form of Form_Resize event process:
Private Sub Form_Resize ()
'adjust the window size, change the Picture1
The size of ',
Picture1. Height=Form1. Height
Picture1. Width=Form1. Width
'the re-initialization of images and the scroll bar
'location,
Picture1. Move 0, 0, ScaleWidth - VScroll1. Width, _
ScaleHeight - HScroll1. Height
Picture2. Move 0, 0
HScroll1. Top=Picture1. Height
HScroll1. Left=0
HScroll1. Width=Picture1. Width
VScroll1. Top=0
VScroll1. Left=Picture1. Width
VScroll1. Height=Picture1. Height
HScroll1. Max=Picture2. Width - Picture1. Width
VScroll1. Max=Picture2. Height - Picture1. Width
'check whether need to scroll bar,
VScroll1. Visible=(Picture1. Height & lt; _
Picture2. Height)
HScroll1. Visible=(Picture1. Width & lt; _
Picture2. Width)
End Sub
CodePudding user response:
One kind is rolling, such as interface display at most 20 data, rolling around, always changing data, but has been take 20,CodePudding user response:
Baidu once every, use it to achieve better!CodePudding user response:
Scrollbar + mschart, after rolling the corresponding historical data to be loaded from the database, the surface is whole figure has all of the data, actually it is not necessary, where the scroll bar to scroll to load a piece of data that is ok,CodePudding user response:
Many words don't have to keep all data, as long as the display area to display the data retentionCodePudding user response:
Option Explicit
Const DataDisplayCount=100 'see how much you want to display a data
Dim data As New Collection
Private Sub Form_Load ()
Dim As Integer I
'data initialization
For I=1 To DataDisplayCount
Data. The Add 0
Next
'open the timer analog data input
Timer1. Interval=100
Timer1. Enabled=True
End Sub
Private Sub Timer1_Timer ()
'the analog data acquisition to processing
Dim As Integer I
Dim X As Long, Y As Long
LastY Dim lastX As Long, As Long
Data. The Add Rnd 'simulated random access to a number, here have a 0 ~ 1, used to tender data points Y coordinates of the percentage of the picture height
Data. Remove 1 'to display more than the number of data delete
'ready to redraw the coordinates of the starting point, the origin in the lower left corner of Picture, abscissa for time, data, display DataDisplayCount ordinate Y coordinate data for the first point, the Y coordinate algorithm to define, I this how simple how to
LastX=0
LastY=Picture1. ScaleHeight - Picture1. ScaleHeight * data (1)
Picture1. Cls' drawing region to empty
For I=2 To the data. The Count
X=X + Picture1. ScaleWidth/(DataDisplayCount - 1)
Y=Picture1. ScaleHeight - Picture1. ScaleHeight * data (I)
Picture1. Line (lastY, lastX) - (X, Y)
LastX=X
LastY=Y
Next
End Sub
Simple custom painting a, give you a sample: a form, throw a picturebox (initialized to flat longer) a timer, and then paste the code above a try
CodePudding user response: