Click here to Skip to main content
Click here to Skip to main content
Go to top

Nice Movie Cast (Text Scroller)

, 22 Mar 2008
Rate this:
Please Sign up or sign in to vote.
Scrolling text with music (just like those in movies' ends!!)
Sample Image - Movie_Cast.jpg

Introduction

I've always admired the way movies end, especially when they put a good music that could make up for the stupid movie and lets me forget the bitterness of thinking about the time I wasted watching this movie!!

Well, hopefully I'm making a good movie cast now, but hey, I ain't making up nothing!!

Explanation

Three main events were declared on the form level for this cast:

  • Load: To load the music and start off the scrolling process
  • MouseEnter: To pause the scrolling
  • MouseLeave: To resume scrolling

For the two mouse events, I've attached two timers to be triggered.

Oh, just two ordinary timers to scroll/pause the cast text.

  • tmrScroller would control the text movement and determine it has reached an end and if so, it's dead!! That is using the kill_Scroller method.
  • tmrPause to show the blinking pause sign at the bottom.

Notice that real pausing was already carried out in the MouseEnter event that in turn launched the tmrPause.

Well, I think that's it for the explanation. Let's go and take a peek at the code.

The Code

//By Muammar Yacoob
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using tonysound;
//Thanks to Tony for making the sound implementation easier
namespace Movie_Cast
{
    public partial class Cast : Form
    {
        public Cast()
        {
            InitializeComponent();
        }

        private void Cast_Load(object sender, EventArgs e)
        {
            //scrolling timer is started
            tmrScroller.Start();
            //sound is played on form loading
            Sound.Play("0X07.wav", PlaySoundFlags.SND_ASYNC);
        }

        private void tmrScroller_Tick(object sender, EventArgs e)
        {
            if (txtCast.Location.Y > (txtCast.Height * -1))
            //textbox's bottom "txtCast" is still in the window
                txtCast.Location = new Point(txtCast.Location.X, 
                   txtCast.Location.Y - 1);
                   // move txtCast up 1 pixel
            else
                kill_Scroller(); //ok, txtCast is out now!
        }

        private void kill_Scroller()
        {
            tmrScroller.Stop();
            label1.Visible = true;
            lnk_website.Visible = true;
            panel2.BringToFront();
            //to cover the lower stuff:)
        }

        private void Cast_FormClosed(object sender, 
                                     FormClosedEventArgs e)
        {
            Sound.Play(@"C:\WINDOWS\Media\start.wav", 
                 PlaySoundFlags.SND_ASYNC);
                 //to stop the sound
        }

        private void lnk_website_LinkClicked(object sender, 
                     LinkLabelLinkClickedEventArgs e)
        {
            this.Close();
            System.Diagnostics.Process.Start("http://" + 
               "www.uncdf.org/english/countries/yemen/index.php");
        }

        private void Cast_MouseEnter(object sender, 
                     EventArgs e) //enter pause mode
        {
            tmrScroller.Stop();
            tmrPause.Start();
            lbl_Pause.Visible = false;
        }

        private void Cast_MouseLeave(object sender, 
                     EventArgs e) //back to scroll mode
        {
            tmrScroller.Start();
            tmrPause.Stop();
            lbl_Paused.Visible = false;
            panel3.Visible = false;
            panel4.Visible = false;
            lbl_Pause.Visible = true;
        }

        private void tmrPause_Tick(object sender, EventArgs e)
        {
            if (lbl_Paused.Visible == false)
            {
                lbl_Paused.Visible = true;
                panel3.Visible = true;
                panel4.Visible = true;
            }
            else
            {
                lbl_Paused.Visible = false;
                panel3.Visible = false;
                panel4.Visible = false;
            }
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Muammar©
Retired QSoft
Yemen Yemen
Biography?! I'm not dead yet!
www.QSoftOnline.com

Comments and Discussions

 
Generalit's cool PinmemberClaud.Xing26-Aug-07 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 23 Mar 2008
Article Copyright 2006 by Muammar©
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid