+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 19

Thread: VB 6.0: Tutorial, How to make a GIF in your application

  1. #1
    TcM
    TcM is offline
    Code Warrior TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM's Avatar
    Join Date
    Aug 2006
    Posts
    11,461
    Blog Entries
    6

    Exclamation VB 6.0: Tutorial, How to make a GIF in your application

    Introduction/Problem
    Well this is a common problem, VB does NOT support GIF's in the Applet, many of you ( I suppose ) make an array of pictureboxes and make still images loaded in them and then in a timer you make the still images to change and well its confusing even to say it, and much more confusing to make! it will take like 8 to 10 lines to just make an animation of 2 frames only! so imagine to make a long GIF! I found this 'secret' and all its going to take is 10 lines! and instead you can have a GIF with unlimited frames and make it with just 10 lines!!

    Solution

    Start a new Project and select "Standard EXE" as follows:-



    Save your project somewhere
    how?
    see below:-



    Add a Picturebox ( Picture1 ) and a web browser control.
    HOW?
    See this image below


    a dialog box will be displayed scroll down till you find "Microsoft Internet Controls" tick it and press OK here is an image to explain better:-


    and instead of WebBrowser1 rename it to Animation
    and make a GIF image in the same directory where you saved the project and rename it to image.gif

    Ok so now make the following code:-

    Code:
    Private Sub Form_Load()
    Dim loc As String
    Dim Source As String
    loc = App.Path & "\image.gif"
    Picture1.Visible = False
    Picture1.AutoSize = True
    Picture1.Picture = LoadPicture(loc)
    Animation.Width = Picture1.Width
    Animation.Height = Picture1.Height
    Source = "about:" & "<html>" & "<body leftMargin=0 topMargin=0 marginheight=0 marginwidth=0 scroll=no>" & "<img src=""" & loc & """></img></body></html>"
    Animation.Navigate Source
    End Sub
    Code Explanation

    Code:
    Dim loc As String
    Dim Source As String
    Here we are declaring 2 variables loc will be the location of the gif and Source will be some HTML code, dont worry if you dont know HTML! you dont need to because I did it for you

    Code:
    loc = App.Path & "\image.gif"
    Here we are asigning the varible loc to the image path, App.path is the location of the project/app and "\image.gif" is the name of the image

    Code:
    Picture1.Visible = False
    Picture1.AutoSize = True
    Picture1.Picture = LoadPicture(loc)
    Well here the code talks on its own
    Here we are hiding the picturebox and making it to AutoSize (will take the size of the picture you load (image.gif)) and in the last step we are loading the picture

    Code:
    Animation.Width = Picture1.Width
    Animation.Height = Picture1.Height
    Here we are making the Webbrowser to take the height and width of the picture1, therefore the size of the GIF!

    Code:
    Source = "about:" & "<html>" & "<body leftMargin=0 topMargin=0 marginheight=0 marginwidth=0 scroll=no>" & "<img src=""" & loc & """></img></body></html>"
    This is the HTML code that you will need to display the picture!

    Code:
    Animation.Navigate Source
    here we are telling the Webbrowser to execute the Source code!

    How does this work?
    Simple Just place the browser control where you want to make the picture to appear

    Complete Source Code:-
    Well I included the FULL source code its an attachment, its the complete project just compile and have fun

    IMPORTANT NOTE
    With this way if you are going to distribute your application you NEED to distribute the picture TOO!!

    Ending:-

    If you have any questions/problems/feedback pls post here and I will sureley Help you!
    So I'm waiting for your feedback
    Ow and if you want me to make you some tutorials request what you want and I will see what I can do! I will be happy making some tuts here!

    Tcm9669
    Attached Files
    Last edited by Jordan; 10-02-2006 at 12:44 PM. Reason: Picture Location Change

  2. #2
    Programming God AfTriX is on a distinguished road
    Join Date
    Jan 2007
    Location
    Chicago
    Posts
    586
    Nice work buddy

  3. #3
    TcM
    TcM is offline
    Code Warrior TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM's Avatar
    Join Date
    Aug 2006
    Posts
    11,461
    Blog Entries
    6
    Quote Originally Posted by AfTriX View Post
    Nice work buddy
    Thanks Just a trick of the trade!

  4. #4
    Programming God AfTriX is on a distinguished road
    Join Date
    Jan 2007
    Location
    Chicago
    Posts
    586
    You are welcome!

    Each thanks that is welcomed and recorded is a nest egg by the side of which more will be laid..... Juz

  5. #5
    Newbie oasisjoel is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    2

    HElp

    I used your... And theres a bug everytime you try to load the form with GIF multiple time's there some kind of ERROR

  6. #6
    Newbie oasisjoel is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    2
    BTW your program has a bug RUN-Time Error -1

  7. #7
    Newbie juriani_rahul is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    1
    awesum

  8. #8
    Newbie simon8088 is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    1
    great tutorial!

  9. #9
    Newbie MasterPerkins is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    1

    Re: VB 6.0: Tutorial, How to make a GIF in your application

    most def will try this out!

  10. #10
    Newbie witcherofhell is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    1

    Re: VB 6.0: Tutorial, How to make a GIF in your application

    great work man keep it up

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

     

Similar Threads

  1. VB 6.0: Tutorial, Making a Port Scanner
    By TcM in forum VB Tutorials
    Replies: 119
    Last Post: 08-24-2009, 03:59 PM
  2. VB 6.0: Tutorial, Using the MsgBox
    By TcM in forum VB Tutorials
    Replies: 11
    Last Post: 05-15-2009, 07:48 AM
  3. VB 6.0: Tutorial, How to Make Glass2K!!
    By TcM in forum VB Tutorials
    Replies: 17
    Last Post: 05-01-2009, 07:31 AM
  4. VB 6.0: Tutorial, Explaining the VB 6.0 GUI
    By TcM in forum VB Tutorials
    Replies: 1
    Last Post: 05-18-2007, 11:25 AM
  5. John's Java Tutorial Index
    By John in forum Java Tutorials
    Replies: 0
    Last Post: 01-11-2007, 04:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts