Cyrus Wolf

I have created a VB app, and the last piece is the "About Box" info, i have seen other apps that when the about button is clicked, their is a semi transparent layer that appears on top of the main app window, and the credits scroll from bottom to top, then if you left click the mouse the "layer" will go away leaving the main, app, i cant recreate this and in need of help, as I am a novice in VB, I have searched and searched and cant find a suitable solution



Re: Visual Basic Language Semi-transparent autoscrolling "Credits screen" help

Chris128

Im not sure about the scrolling credits but the transparency and mouse click to close is simple. Create a new form or aboutbox and once you have designed it how you want, select the form and in the properties window on the bottom right (if your using VS2005) find a property called Opacity and set this to 50%. (or however transparent you want it)

As for closing when you click, double click on your form to bring up the code editor and create a new sub using the following code:

Code Snippet

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick

Me.Close()

End Sub

Obviously if your form isnt called Form1 then you will need to edit this to replace the Form1_MouseClick with yourformname_MouseClick

Hope that helps.

Im sure someone else will let you know how to do the scrolling thing Smile






Re: Visual Basic Language Semi-transparent autoscrolling "Credits screen" help

SJWhiteley

Create a form that is borderless. Set the opacity to something appropriate. Of course, anything placed on the form will have the same transparency. Do you want the text to be opaque or transparent also The former would be very, very hard (there may be a 'trick'...), the later is straight forward. To actually scroll text, you'd do something like:

Code Snippet

Public Class Form1

Private WithEvents Scroller As System.Windows.Forms.Timer

Private TextLocationY As Integer

Private Credits() As String

Private FontHeight As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.DoubleBuffered = True

Me.BackColor = Color.White

Me.Opacity = 0.8

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None

Scroller = New System.Windows.Forms.Timer

Scroller.Interval = 100

Scroller.Enabled = True

TextLocationY = Me.ClientSize.Height

FontHeight = MyBase.Font.Height

'

' Create some credits

ReDim Credits(0 To 10)

For i As Integer = 0 To Credits.Length - 1

Credits(i) = "Credit Line " & i.ToString

Next

End Sub

Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick

Me.Close()

End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim loc As Integer = TextLocationY

For i As Integer = 0 To Credits.Length - 1

Dim sz As SizeF = e.Graphics.MeasureString(Credits(i), MyBase.Font, Me.ClientSize.Width)

Dim x As Single = (Me.ClientSize.Width - sz.Width) / 2

e.Graphics.DrawString(Credits(i), MyBase.Font, Brushes.Black, x, loc)

loc += FontHeight * 2

Next

' Reset the p[osition if necessary

If loc < 0 Then TextLocationY = Me.ClientSize.Height

End Sub

Private Sub Scroller_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Scroller.Tick

TextLocationY -= 2

Me.Invalidate()

End Sub

End Class

(The above was just knocked out - you'll probably have to modify it to suit, and doublecheck for errors).