Go Back   Random Stuff Forums > Technical > Programming

Programming Discuss any type of programming here.

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 18-09-2007, 12:03 AM
World Domination's Avatar
(Offline)
Super Sexy Admin
 
Join Date: Jan 2007
Location: Illinois, USA
Posts: 7,384
World Domination is an unknown quantity at this point
Default [TUT - VB6] Adding a Splash Screen to your Project

This Tutorial will teach you how to add a splash screen to your project. I will explain two ways to do it, and easy way and a not as easy way. The easy way will have it so you have to click a button for the Main for to load and the not as easy way will have the Splash Screen Fade in and then out.

First open up Visual basic 6, and click Standard EXE.

EASY WAY:

Go to Project -> Add Form. Select Form.

Add a Command Button to the form, and in the Command1_Click() function add the following code:

Form2.Show
Unload Me

You need to make sure that the form with the Command button is the form that loads first.

NOT AS EASY WAY:

Go to Project -> Add form and select Splash Screen.

Double click on the frmSplash form to view the code. Delete all the code and put in the following:
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Function SetWindowTransparency(hwnd As Long, Value As Long)
      SetWindowLong hwnd, -20, GetWindowLong(hwnd, -20) Or &H80000
      SetLayeredWindowAttributes hwnd, 0, Value, &H2
End Function

Private Sub Wait(ByVal ms As Long)
    ms = timeGetTime() + ms
    Do: DoEvents: Loop While ms > timeGetTime()
End Sub

Private Sub Form_Load()
Dim i As Long
    SetWindowTransparency Me.hwnd, 0
    Me.Show
    DoEvents
    For i = 0 To 250 Step 10
        SetWindowTransparency Me.hwnd, i
        Wait 50
    Next i
    Wait 2000
    For i = 250 To 0 Step -10
        SetWindowTransparency Me.hwnd, i
        Wait 50
    Next i
  form1.show
    Unload Me
End Sub
Change the green to the name of the frame you want to load after the Splash Screen has loaded.

Most of you are probably confused by the code, but don't worry, all it basically is saying is Load frmSplash, by fading in, and then out, and then after it has faded out close frmSplash and then load the main frame.

Now you need to set the priorities of what form is going to load first, otherwise the frmSplash form will not load and you won't have a Splash Screen.
To do this go to Project -> Project1 Properties and under the General tab you will see a spot that says 'Start up Object' and a drop down menu below it. You need to choose frmSplash as the start up Object. Then hit OK.

Now test it. If it doesn't work go through and read the Tutorial again. If it still doesn't work post and I can help you.

Hopefully you all enjoyed this awesome tutorial by me. :P
__________________
RSForums.org - We Don't give a fuck.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

"It's not yelling, it's projecting; and by the way, my voice is soothing."
-Billy Mays


Last edited by World Domination; 18-09-2007 at 12:28 AM..
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 04:59 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright © 2006 - 2010, Rsforums.org