Solved

Synchronizing txt box & picture box 4 slide show & speeding up changing from 1 pb 2 another

Posted on 2004-04-16
8
343 Views
Last Modified: 2010-04-24
I have an app that basically is a slide show, it works, however:

I have 2 form versions, one with group boxes & one with tabs

Because it takes time to load jpg to picture boxes I have 2 group boxes or 2 tab with picture boxes, whilst one is being viewed, the other is being loaded with 2nd picture, also the photo caption is either in a label or group box text.

when I set the slide show going, I get text appearing for the second picture before the last picture has been replaced by the 2nd picture.

What I want is a synchronised text with the picture & a snappy exchange from one picture box to the next.

ie: show picture & text together at the same time & switch from one group box or tab to another at the time the event is fired (sometimes it may be activated by a click event & it does not respond fast enough)


It worked fine in vb6 but trying numerous options in net, have eluded me so far.

Also after showing about 10 pictures, it just seems to get slower & slower.

Any help is much appreciated
0
Comment
Question by:bemson
  • 4
  • 2
  • 2
8 Comments
 
LVL 10

Expert Comment

by:gangwisch
ID: 10847889
the best way to pre-load these images is to use an imagelist

you should do this at runtime in form_load
dim x as new bitmap("c:\filepath")
imagelist1.images.add(x)
then when it becomes time to viewing the image you can do
picturebox1.picture=imagelist1.list(pictureindex) 'it may be .listimages

this will be good for your slideshow because you can just make a global variable with dim numpictures as integer
and then increment it when the user clicks for next picture make sure you set the index back to 0 when it equals numpictures-1
0
 

Author Comment

by:bemson
ID: 10847947
to GANGWISCH

Thanks for your suggestion, today is nearly over here, so will try tomorrow am and be back in about 17 hours
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 10849688
Here is I what use to display images.  The form displays an image in fullscreen mode and scales the image to fit the screen while preserving the images aspect ratio.

You could use two of these forms and then toggle between them from your slideshow code using the .Show() method.

Regards,

Idle_Mind

Public Class FullScreenImage
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'PictureBox1
        '
        Me.PictureBox1.Location = New System.Drawing.Point(192, 168)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(50, 50)
        Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
        Me.PictureBox1.TabIndex = 0
        Me.PictureBox1.TabStop = False
        '
        'Form3
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.Black
        Me.ClientSize = New System.Drawing.Size(440, 400)
        Me.Controls.Add(Me.PictureBox1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "Form3"
        Me.Text = "Form3"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sc As Rectangle = Screen.PrimaryScreen.Bounds()
        Me.Left = 0
        Me.Top = 0
        Me.Width = sc.Width
        Me.Height = sc.Height
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Cursor.Show()
        Me.Hide()
        ' or use
        'Me.Dispose(True)
    End Sub

    Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
        Cursor.Hide()
    End Sub

    Public Sub updateImage(ByVal fullPathFileName As String)
        Dim sc As Rectangle = Screen.PrimaryScreen.Bounds()
        Dim i As Image
        Dim ratio As Double
        Dim s As Size

        PictureBox1.Left = 0
        PictureBox1.Top = 0
        PictureBox1.Width = sc.Width
        PictureBox1.Height = sc.Height
        If Dir(fullPathFileName) <> "" Then
            i = Image.FromFile(fullPathFileName)
            ratio = i.Height / i.Width
            s.Width = PictureBox1.Width
            s.Height = s.Width * ratio
            If s.Height > PictureBox1.Height Then
                ratio = PictureBox1.Height / s.Height
                s.Width = s.Width * ratio
                s.Height = s.Height * ratio
            End If
            PictureBox1.Image = New Bitmap(i, s)
        Else
            MsgBox(fullPathFileName, MsgBoxStyle.Exclamation, "File Not Found")
        End If
    End Sub

End Class
0
 

Author Comment

by:bemson
ID: 10851411
For Gangwisch & idle_mind

I have spent last 2 hours trying to use imagelist, without much success, image size is the problem at the moment.

I have been trying to adapt the help example for imagelist class, but keep running into problems I don't understand.

This app which is more than just a slide show has taken me over 2 years on & off to develop, starting in vb6.

For Idle_mind
thanks for your suggestion, some of the features you are using are foreign to me but will have a go.

at present I have to go out for 4 hours, will try to set up your suggestion then, but I expect it will take me a while, so probably be back in 24hrs
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:bemson
ID: 10852201
After another 2 hours of searching help & trying to use your suggestions:

for gangwisch

I have exhausted my options with an imagelist for the following reasons
1. after loading 79 out of 160 pictures, I run out of memory
2. if I restrict it to say 10 then I have problems setting picturebox size from the image list
3. for whatever reason, when I do get an image in picturebox it is blurred ( and size is wrong)

for idle_mind

your suggestion is probably a solution to my problem, however your code example has routines that are foreign to me, so my programming expertise is way below yours.

I don't expect you to further elaborate to help me understand something I have not learn't yet.

However, perhaps you could explain how to modify the code using designer & not code editor, as I have looked everywhere for an option to modify using the designer.

As tomorrow is a work day & I am working on this project at home, I will endeavour to further explore your suggestion as time permits during the week at home.

Any progress & I will get back to you

Thanks to both for suggestions so far
Regards
Bob
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 10852320
All of the code between this line,

    #Region " Windows Form Designer generated code "

and this line,

    #End Region

is generated automatically by the IDE when you drag controls onto the form and change properties about them.  You should not change things in there manually.  By cutting and pasting all of the code above into a new form, over all existing code on the form, you will get the same layout and property settings as I have them.

For instance, if you and a new form to a project, it will have something like this in it:

-   Public Class Form3
        Inherits System.Windows.Forms.Form

+      Windows Form Designer generated code

    End Class

If you select all of that code and paste the code I gave over it, then you have the exact same layout as I did.  Once you have pasted the code, you can hit the "-" symbol next to #Region " Windows Form Designer generated code " line and not worry about that code section anymore as it will get changed by the IDE as you work with the form in the designer.

Here is a small example of how to use the form.  The main form has a Button and an OpenFileDialog control on it.  Obviously you wouldn't use a file dialog box in your app, it's just an easy way to get a valid image file name.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim result As DialogResult
        result = OpenFileDialog1.ShowDialog
        If result = DialogResult.OK Then
            Dim fs As New FullScreenImage
            fs.updateImage(OpenFileDialog1.FileName)
            fs.ShowDialog()
            fs.Dispose()
        End If

    End Sub

Let me know how I can be of further assistance.

Idle_Mind
0
 
LVL 10

Expert Comment

by:gangwisch
ID: 10853306
Here is my best advice:

You need to keep about 5 images in that imagelist at a time you can remove the last one by using the remove method(index) this will save on memory
0
 

Author Comment

by:bemson
ID: 11019362
Soory for delay in replying I have had a few medical issues to resolve

However;

for gangwisch, I have checked help for use of image list & it appears that it's intention is to tye it to say a tab on a tab control.

As I already have the images stored, it does not seem logical to store them again & retrive them from an image list rather than my array already built up

For idle-mind, I have found after much form adding & heaps of useless code, all I needed was the section for the update image. it works fine with only one picturebox on one form, I was trying to load image to a duumy picturebox, determine landscape or portrait, then adjusting pic box to suit, this is where time was lost in the display
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now