[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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

Posted on 2004-04-16
Medium Priority
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
Question by:bemson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
LVL 10

Expert Comment

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")
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

Author Comment

ID: 10847947

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

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.



Public Class FullScreenImage
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()

        'This call is required by the Windows Form Designer.

        '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
            End If
        End If
    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.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
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.Black
        Me.ClientSize = New System.Drawing.Size(440, 400)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "Form3"
        Me.Text = "Form3"

    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
        ' or use
    End Sub

    Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
    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)
            MsgBox(fullPathFileName, MsgBoxStyle.Exclamation, "File Not Found")
        End If
    End Sub

End Class
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

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

Author Comment

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
LVL 86

Accepted Solution

Mike Tomlinson earned 1500 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
        End If

    End Sub

Let me know how I can be of further assistance.

LVL 10

Expert Comment

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

Author Comment

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


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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

649 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