|
-
Dec 5th, 2008, 05:38 PM
#1
Thread Starter
PowerPoster
Showing scrolling bars in UC
now i'm trying build a 2D Level Editor ActiveX control.
my 1st problem is for put the scroll bars in UC.
heres the code:
Code:
If vNewValue = ScrlBars Then Exit Property
'for showing the scroll bars, the UC is resized
If vNewValue = None Then
ScrollingHorizontal.Visible = False
ScrollingVertical.Visible = False
'put the scroll bars outside of UC
UserControl.Width = UserControl.Width - ScrollingHorizontal.Height
UserControl.Height = UserControl.Height - ScrollingVertical.Width
ScrollingHorizontal.Top = UserControl.Height + 100
ScrollingVertical.Left = UserControl.Width + 100
ElseIf vNewValue = Horizontal Then
ScrollingHorizontal.Visible = True
ScrollingVertical.Visible = False
'put the horizontal scroll bar in right position
'and the other outside of it
UserControl.Width = UserControl.Width + ScrollingHorizontal.Height
UserControl.Height = UserControl.Height - ScrollingVertical.Width
ScrollingHorizontal.Top = (UserControl.Height - ScrollingHorizontal.Width) * Screen.TwipsPerPixelY
ScrollingVertical.Left = UserControl.Width + 100
ElseIf vNewValue = Vertical Then
ScrollingHorizontal.Visible = False
ScrollingVertical.Visible = True
'put the vertical scroll bar in right position
'and the other outside of it
UserControl.Width = UserControl.Width - ScrollingHorizontal.Height
UserControl.Height = UserControl.Height + ScrollingVertical.Width
ScrollingHorizontal.Top = UserControl.Height + 100
ScrollingVertical.Left = (UserControl.Width - ScrollingHorizontal.Height) * Screen.TwipsPerPixelX
ElseIf vNewValue = Both Then
If ScrlBars = Both Then Exit Property
ScrollingHorizontal.Visible = True
ScrollingVertical.Visible = True
'put both scroll bars in right position
UserControl.Width = UserControl.Width + ScrollingHorizontal.Height
UserControl.Height = UserControl.Height + ScrollingVertical.Width
ScrollingHorizontal.Top = (UserControl.Height - ScrollingHorizontal.Width) * Screen.TwipsPerPixelY
ScrollingVertical.Left = (UserControl.Width - ScrollingHorizontal.Height) * Screen.TwipsPerPixelX
End If
ScrlBars = vNewValue
the scrolling bars aren't in right position, can anyone tell me what isn't right?
thanks
-
Dec 6th, 2008, 05:28 AM
#2
Thread Starter
PowerPoster
Re: Showing scrolling bars in UC
i change somethings in code:
Code:
If vNewValue = None Then
ScrollingHorizontal.Visible = False
ScrollingVertical.Visible = False
ElseIf vNewValue = Horizontal Then
ScrollingHorizontal.Visible = True
ScrollingVertical.Visible = False
ElseIf vNewValue = Vertical Then
ScrollingHorizontal.Visible = False
ScrollingVertical.Visible = True
ElseIf vNewValue = Both Then
ScrollingHorizontal.Visible = True
ScrollingVertical.Visible = True
End If
and
Code:
Private Sub UserControl_Resize()
ScrollingHorizontal.Top = UserControl.Height - ScrollingHorizontal.Height
ScrollingHorizontal.Width = UserControl.Width - 240
ScrollingVertical.Left = UserControl.Width - ScrollingVertical.Width
ScrollingVertical.Height = UserControl.Height - 240
End Sub
my proble here is the UserControl Resize event. what isn't right in code for change the scrollbars position?
thanks
-
Dec 6th, 2008, 05:50 AM
#3
Thread Starter
PowerPoster
Re: Showing scrolling bars in UC
i resolve my problem:
Code:
ScrollingHorizontal.Top = UserControl.Height / Screen.TwipsPerPixelY - ScrollingHorizontal.Height
ScrollingHorizontal.Width = UserControl.Width / Screen.TwipsPerPixelX - 16
ScrollingVertical.Left = UserControl.Width / Screen.TwipsPerPixelX - ScrollingHorizontal.Height
ScrollingVertical.Height = UserControl.Height / Screen.TwipsPerPixelY - 16
now i have 2 questions:
-why i must multply or divide by Screen.TwipsPerPixelY or Screen.TwipsPerPixelx?
-when i know that i need use them?
thanks
-
Dec 7th, 2008, 06:58 AM
#4
Thread Starter
PowerPoster
Re: Showing scrolling bars in UC
how can i calculate the scrollbars max property value?
i just can't do these:
VerticalScrollBar.Max = PictureBox.Heigth
HorizontalScrollBar.Max = PictureBox.Width
because the max values depends, too, the UC size.
can anyone explain to me something?
thanks
-
Dec 7th, 2008, 11:54 AM
#5
Thread Starter
PowerPoster
Re: Showing scrolling bars in UC
ok. i resolve the problem.
Code:
Private Sub ScrollingValues()
ScrollingVertical.Max = picView.Height - UserControl.ScaleHeight
If ScrlBars = Vertical Or ScrlBars = both Then ScrollingVertical.Max = ScrollingVertical.Max + 17
ScrollingHorizontal.Max = picView.Width - UserControl.ScaleWidth
If ScrlBars = Horizontal Or ScrlBars = both Then ScrollingHorizontal.Max = ScrollingHorizontal.Max + 17
If picView.ScaleHeight <= UserControl.ScaleHeight Then ScrollingVertical.Max = 0
If picView.ScaleWidth <= UserControl.ScaleWidth Then ScrollingHorizontal.Max = 0
End Sub
and works fine.
thanks
-
Dec 7th, 2008, 03:39 PM
#6
Thread Starter
PowerPoster
Re: Showing scrolling bars in UC
how can i see the controls name in these UC?
i try these:
UserControl.ContainedControls.Item(1).Name
but i recive an error:
"invalid property array".
thanks
-
Dec 7th, 2008, 06:55 PM
#7
Thread Starter
PowerPoster
Last edited by joaquim; Dec 8th, 2008 at 12:12 PM.
-
Dec 8th, 2008, 05:30 PM
#8
Thread Starter
PowerPoster
Re: Showing scrolling bars in UC
ok... problem 100% resolved.
the value variable was changed for HorizontalValue. i create these variable in declation section and when i change the horizontalscrollbar max property i give these variable 0 value.
and i change morethings in code(if anyone want to know these code setp by step, just tell me):
Code:
Private Sub ScrollingHorizontal_Change()
Dim i As Long
For i = 0 To UserControl.Controls.Count - 1
If UserControl.Controls(i).Name = "Timer1" Or UserControl.Controls(i).Name = "Picture1" Or UserControl.Controls(i).Name = "ScrollingHorizontal" Or UserControl.Controls(i).Name = "ScrollingVertical" Then
Else
If HorizontalValue > ScrollingHorizontal.value Then
UserControl.Controls(i).Left = UserControl.Controls(i).Left + (Abs(ScrollingHorizontal.value - HorizontalValue))
ElseIf HorizontalValue < ScrollingHorizontal.value Then
UserControl.Controls(i).Left = UserControl.Controls(i).Left - (Abs(ScrollingHorizontal.value - HorizontalValue))
End If
End If
Next i
HorizontalValue = ScrollingHorizontal.value
End Sub
thanks
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
|