|
-
May 16th, 2000, 05:22 AM
#1
Thread Starter
Lively Member
I wanna create a long form about 2 pages, but I need a horiz. scrollbar. It seems that forms (other than MDI) don't
use scroll bars. Anyone know why?
Thanx
-
May 16th, 2000, 05:24 AM
#2
Fanatic Member
I ran into this problem before. The trick is to expand the textbox or any control to the desire length. Then instead of moving the form, you move the textbox making it look like it scrolls. Drop the horizontal and vertical scroll bars and just make it move.
Chemically Formulated As:
Dr. Nitro
-
May 16th, 2000, 05:27 AM
#3
Fanatic Member
Although not the best way to solve this issue but an affective one would be to place your scroll bar on the form and reposition the controls on the form using it. I used this option once when I needed something quick.
-
May 16th, 2000, 06:11 AM
#4
If you do not want to make your own, I believe you can download OCX controls to do it.
-
May 16th, 2000, 06:29 AM
#5
Instead of moving the individual controls with the Scroll bar(s), place all the controls in a Picturebox container and scroll that instead, here's a skeleton example, just add it to a Form with a Picturebox and Horizontal and Vertical Scrollbar set the picturebox to the Size of your Virtual Form, then just place your controls within the Picturebox.
The scroll bars will appear automatically like they do on the MDI form depending on the Size of the Form.
Code:
Private Sub Form_Load()
Picture1.BorderStyle = vbBSNone
End Sub
Private Sub Form_Resize()
On Error Resume Next
VScroll1.Visible = Picture1.Height > ScaleHeight
HScroll1.Visible = Picture1.Width > ScaleWidth
VScroll1.Visible = Picture1.Height > ScaleHeight - IIf(HScroll1.Visible, HScroll1.Height, 0)
HScroll1.Visible = Picture1.Width > ScaleWidth - IIf(VScroll1.Visible, VScroll1.Width, 0)
VScroll1.Move ScaleWidth - VScroll1.Width, 0, VScroll1.Width, ScaleHeight - IIf(Picture1.Width > ScaleWidth, HScroll1.Height, 0)
HScroll1.Move 0, ScaleHeight - HScroll1.Height, ScaleWidth - IIf(Picture1.Height > ScaleHeight, VScroll1.Width, 0)
If VScroll1.Visible Then
VScroll1.Max = Picture1.Height - ScaleHeight + IIf(HScroll1.Visible, HScroll1.Height, 0)
Else
VScroll1 = 0
End If
If HScroll1.Visible Then
HScroll1.Max = Picture1.Width - ScaleWidth + IIf(VScroll1.Visible, VScroll1.Width, 0)
Else
HScroll1 = 0
End If
HScroll1_Change
End Sub
Private Sub HScroll1_Change()
Picture1.Move -HScroll1, -VScroll1
End Sub
Private Sub HScroll1_Scroll()
HScroll1_Change
End Sub
Private Sub VScroll1_Change()
Picture1.Move -HScroll1, -VScroll1
End Sub
Private Sub VScroll1_Scroll()
VScroll1_Change
End Sub
-
May 16th, 2000, 06:32 AM
#6
use the picture box control, and the scroll bars....
or if you want a more customized look, use 3 command buttons, 2 timers, and a picturebox....
use two of the command buttons as the buttons you push to scroll, and use the third as the little bar that moves.
use a shape control, or possibly another picture box as the container for the thing that moves...
use the button mousedown and mouseup to turn the timer on/off
this works pretty well......
Code:
Private Sub cmdDown_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
TimerDown.Enabled = True
End If
End Sub
Private Sub cmdDown_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
TimerDown.Enabled = False
End If
End Sub
Private Sub cmdUp_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
TimerUp.Enabled = True
End If
End Sub
Private Sub cmdUp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
TimerUp.Enabled = False
End If
End Sub
Private Sub Form_Load()
TimerUp.Enabled = False
TimerDown.Enabled = False
TimerUp.Interval = 1
TimerDown.Interval = 1
Picture2.ScaleHeight = Form1.ScaleHeight
End Sub
Private Sub TimerDown_Timer()
Picture1.Top = Picture1.Top - 50
cmdBar.Top = cmdBar.Top + 50
End Sub
Private Sub TimerUp_Timer()
Picture1.Top = Picture1.Top + 50
cmdBar.Top = cmdBar.Top - 50
End Sub
picture1 is the container for the stuff you want to be scrolled....
picture2 is the container for cmdbar... which is the little gray looking thin(the thing thatmoves up and down when you scrool up/down)
you may need to add some code to stop the process at the bottom and top...
you also may need to play around with the size of the pictureboxes and stuff...
I am working on some better code right now... but if you need it right away... heres the code....
-
May 16th, 2000, 06:42 AM
#7
megatron:
I dont like using OCX's, I know this isnt my thread, but I hate using them, its a real pain in the ass to have the installation program register them, half the time it doesnt work right(the installation program)
and with your code, if there is an error, come here, and you will get help, if there is an error with the OCX, you have to remove the OCX, and erase all the code you wrote for it. etc...
I like to write code better... even if its not my own...
-
May 16th, 2000, 06:42 AM
#8
Thread Starter
Lively Member
Thanx Nitro
but textbox disappears off the bottom of the screen
Private Sub Command1_Click()
For i = 6600 To 12000 Step 500
Me.Height = i + 2400
Text1.Top = i
MsgBox "yo"
Next
End Sub
Private Sub Form_Load()
Me.Height = 9000
Text1.top = 6600
End Sub
you guys are quick!
I've just noticed 3 more replies
reespec'!!
-
May 16th, 2000, 06:57 AM
#9
Thread Starter
Lively Member
Thanks for your help guys
The code from Aaron Young seems to work just fine.
-
May 16th, 2000, 11:19 AM
#10
Fanatic Member
I've ran into this a couple of times and have also noticed these api functions that sound like they should do the trick, anybody know how to use them?
Code:
Declare Function ScrollWindowEx Lib "user32" Alias "ScrollWindowEx" (ByVal hwnd As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate As Long, lprcUpdate As RECT, ByVal fuScroll As Long) As Long
Declare Function ScrollWindow Lib "user32" Alias "ScrollWindow" (ByVal hWnd As Long, ByVal XAmount As Long, ByVal YAmount As Long, lpRect As RECT, lpClipRect As RECT) As Long
Declare Function ScrollDC Lib "user32" Alias "ScrollDC" (ByVal hdc As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate As Long, lprcUpdate As RECT) As Long
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
May 16th, 2000, 08:43 PM
#11
Thread Starter
Lively Member
Specially for Aaron
Additional:-
Scrolling works fine, but I need an A4 printout
The form is about 11 or so inches in height, so I didn't
expect any problems, but the printform method just gives me
a screen dump, (about half a page).
Is there a solution?
Thanks again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|