Question

picture

Asked by: sml41

I am displaying pictures using load Picture in an array at ruin time, ie. to create multple picture boxes each displaying a diff bitmap. I have done that but i need two things 1. to display these picture boxes picture1(i) inside another picture box picture2 which has a vertical scroll bar to view all the pic1 boxes in it as thunp nails so how can i do that also I want the array to be initiated by the number of bitmaps available in folder1.

I haop I explained my self!!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
1999-09-21 at 12:24:19ID10209095
Tags

how

,

picture

,

scroll

Topic

Visual Basic Programming

Participating Experts
3
Points
70
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Merge Picture
    I have 3 picturebox ... I want merge 2 picture in on... I want put picture1 first after picture2 in picture3, how can I do that easly? and how can I write text in picture?
  2. Comparing Pictures
    Hello there! Say I have two picture boxes, Picture1 and Picture2 and I want to compare the content of them. Is there a way for me to find out if the content is equal in the two picture boxes? Martin
  3. Combining 2 Picture Objects
    Is there a way to combine 2 picture objects and then print it? Say, but this is just an oversimplication: Picture3=Picture1 + Picture2 Picture1 and Picture2 are actually Form1 and Form2 captured using the popular method on the link below, to be printed in a single sheet of...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: anthonycPosted on 1999-09-21 at 12:44:47ID: 2064001

you can get the count of bitmaps, in a very boring way like this

function GetBMPCount(szFolder as string) as long
  dim lCt as long
  dim szFile as string

  szfile = dir(szfolder & "\*.bmp")
  do until len(szfile) = 0
     lct = lct + 1
     szfile = dir()
  loop
  GetBMPCount = lct
end function

To do the first part, put the control array element you are using to build the other items inside picture2.  Write code to position those pictureboxes in a nice formation.  (make them all the same size).  Put a horizontal and/or a vertical bar in the picture2.  Set the Min = 0 and set the max = # of rows (or columns) * Width (or height).  Set the largechange of the scroll bar = to the width (or height) of the scroll bar.  In the scrollbars change event, reposition the controls.

 

by: sml41Posted on 1999-09-22 at 03:21:12ID: 2065608

hello anthonyc,

I have done what you advised but I am stuck on<Set the largechange of the scroll bar = to the width (or height) of the scroll bar.  In the scrollbars change event, reposition the controls>.

say i have 20 bitmaps, i made the controll array to display them in picture2, but i can not scroll thime up/down with the Vscrool1. because i have not done that before i am confused how to tackle it. If yo give me example code for the last part that will help.

many thanks

 

by: anthonycPosted on 1999-09-22 at 04:59:40ID: 2065799

ok:

do this:
private const mc_nPicsPerRow as integer = 4 'set to what you want

vScroll1.Min = 0
vScroll1.Max = picture2.height

private sub vScroll1_Change()
  dim pic as picturebox

  for each pic in picture1
     pic.Top = ((pic.index \ mc_nPicsPerRow) * pic.height) - vScroll1.Value
  next pic
end sub

 

by: moterkPosted on 1999-09-22 at 10:56:03ID: 2066936

If you have 20 pictures that is 21 pictureboxes on one form
That consumes a lot of memory and slows down you app.  Try two pictureboxs picture1 and picture2  Set the following:

picture1.visible=false
picture2.AutoRedraw=True

load your pictures one by one into picture1 and use its paintpicture method to paint them into the appropriate positions on picture2

PaintPicture will allow you to take any region of picture1 and paint it to any region of picture2 and you can even resize the region as it is painted.  Thus no matter if you have one picture or a thousand pictures you only use 2 pictureboxs.  This is much faster and consumes much less memory.  When the scroolbar is used picture2 can be cleared and then repainted with the appropriate pictures.

To save the need to access the disk everytime the scroll bar is used add a third picturebox picture3.  Paint all the thumbnails into picture3 instead of picture2. And then paint the appropriate regions of picture3.image to picture2.  Make sure picture3.AutoRedraw=true and picture3.visible=false.

 

by: sml41Posted on 1999-09-26 at 07:58:33ID: 2075898

moterk, Hi.. can u give a samll example code, i was confused to follow this. but i agree when i display 150 picture i have to wait 2 minutes to display them..

 

by: sml41Posted on 1999-10-02 at 09:18:44ID: 2093533

thanks

 

by: moterkPosted on 1999-10-04 at 07:45:54ID: 2096894

The following form definition contains contains all you need to pull off a thumbnail viewer.  A folder path is sent to it via the command line then it creates a collection of all BMP, JPG, and GIF files'filenames.  Then from that collection, it loads each picture into picture1, paints a thumbnail of it to picture3, and stores that thumbnail into another collection.  Then the thumbnail collection paints thumbnails 25 at a time to picture2.  You flip through pages
of thumbnails in picture2 using the scroll bar.  You may not notice much if any improvement in loading time.  That is not where the time savings is.  But when you switch pages you do not have to show, hide, and/or move 25 picture boxes.  Which takes quite a bit of time.  This just paints thumbnails from the collection.  Page transitions seem
instantanious.  Since you are using 3 pictureboxes and two collections no matter how many pictures you have, you are saving a lot or memory resources. I can load 8 pages (200 thumbnails) in about 1 minute on my machine.  This is a little different then what I discribed earlier but it uses the same ideas.


VERSION 5.00
Begin VB.Form Form1
   BorderStyle     =   1  'Fixed Single
   Caption         =   "ThumbNail Viewer"
   ClientHeight    =   3465
   ClientLeft      =   1050
   ClientTop       =   1470
   ClientWidth     =   9315
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3465
   ScaleWidth      =   9315
   Begin VB.PictureBox Picture3
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   990
      Left            =   2475
      ScaleHeight     =   990
      ScaleWidth      =   1035
      TabIndex        =   3
      Top             =   1005
      Width           =   1035
   End
   Begin VB.VScrollBar VScroll1
      Height          =   3375
      Left            =   9030
      Max             =   1
      Min             =   1
      TabIndex        =   2
      Top             =   45
      Value           =   1
      Width           =   270
   End
   Begin VB.PictureBox Picture1
      AutoSize        =   -1  'True
      Height          =   1320
      Left            =   585
      ScaleHeight     =   1260
      ScaleWidth      =   1245
      TabIndex        =   0
      Top             =   645
      Visible         =   0   'False
      Width           =   1305
   End
   Begin VB.PictureBox Picture2
      AutoRedraw      =   -1  'True
      Height          =   3375
      Left            =   30
      ScaleHeight     =   3315
      ScaleWidth      =   8940
      TabIndex        =   1
      Top             =   30
      Width           =   9000
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private PictureFiles As Collection
Private PictureThumbs As Collection
Private OneThumb As StdPicture
Private CurPicture As String
Const PicsPerRow = 5  'Fit 25 thumbnails in picture2 at a time
Const PicsPerCol = 5

Sub LoadThumbNails(tnPath As String)
    Dim ftype As VbFileAttribute
   
    MaxHeight = Picture2.Height / PicsPerCol
    MaxWidth = Picture2.Width / PicsPerRow
   
    Set PictureFiles = New Collection
   
    ftype = vbArchive + vbHidden + vbNormal + vbReadOnly
    PicFile$ = Dir(tnPath & "*.bmp", ftype)
    Do Until PicFile$ = ""
        PictureFiles.Add tnPath & PicFile$
        PicFile$ = Dir
    Loop
    PicFile$ = Dir(tnPath & "*.gif", ftype)
    Do Until PicFile$ = ""
        PictureFiles.Add tnPath & PicFile$
        PicFile$ = Dir
    Loop
    PicFile$ = Dir(tnPath & "*.jpg", ftype)
    Do Until PicFile$ = ""
        PictureFiles.Add tnPath & PicFile$
        PicFile$ = Dir
    Loop
   
    Set PictureThumbs = New Collection
   
    PicsPerPage = PicsPerRow * PicsPerCol
    TotalPages% = Int(PictureFiles.Count / PicsPerPage)
    If (PictureFiles.Count Mod PicsPerPage) > 0 Then TotalPages% = TotalPages% + 1
    VScroll1.Max = TotalPages%
    If TotalPages% = 1 Then VScroll1.Enabled = False
    For i% = 1 To PictureFiles.Count
        Picture1.Picture = LoadPicture(PictureFiles.Item(i%)) 'Picture1.AutoSize=True
        SourceWidth = Picture1.Width
        SourceHeight = Picture1.Height
        wratio = MaxWidth / SourceWidth
        hratio = MaxHeight / SourceHeight
        tempratio = wratio: If hratio < tempratio Then tempratio = hratio
        DestWidth = SourceWidth * tempratio
        DestHeight = SourceHeight * tempratio
        Picture3.Width = DestWidth
        Picture3.Height = DestHeight
        SourceX = 0
        SorceY = 0
        DestX = 0
        DestY = 0
        Picture3.PaintPicture Picture1.Picture, DestX, DestY, DestWidth, DestHeight, SourceX, SourceY, SourceWidth, SourceHeight, vbSrcCopy
        Set OneThumb = Picture3.Image
        PictureThumbs.Add OneThumb
        Set OneThumb = Nothing
        Picture3.Cls
    Next i%
    Picture3.Visible = False
End Sub
Sub PaintPage(pnum As Integer)
    Picture2.Cls
    PicsPerPage% = PicsPerCol * PicsPerRow
    MaxWidth = Picture2.Width / PicsPerRow
    MaxHeight = Picture2.Height / PicsPerCol
    StartPic% = ((pnum - 1) * PicsPerPage%) + 1
    EndPic% = StartPic% + PicsPerPage% - 1
    If StartPic% > PictureThumbs.Count Then Exit Sub 'Page requested does not exist
    If EndPic% > PictureThumbs.Count Then EndPic% = PictureThumbs.Count 'Last Page
    For i% = StartPic% To EndPic%
        ThumbNum% = i% - StartPic%
        PicRow% = Int(ThumbNum% / PicsPerRow)
        PicCol% = ThumbNum% - (PicRow% * PicsPerRow)
        Set OneThumb = PictureThumbs.Item(i%)
        SourceWidth = Picture2.ScaleX(OneThumb.Width)
        SourceHeight = Picture2.ScaleY(OneThumb.Height)
        DestWidth = SourceWidth
        DestHeight = SourceHeight
        SourceX = 0
        SorceY = 0
        DestX = (PicCol% * MaxWidth) + ((MaxWidth - SourceWidth) / 2)
        DestY = (PicRow% * MaxHeight) + ((MaxHeight - SourceHeight) / 2)
        Picture2.PaintPicture OneThumb, DestX, DestY, DestWidth, DestHeight, SourceX, SourceY, SourceWidth, SourceHeight, vbSrcCopy
        Set OneThumb = Nothing
    Next i%
End Sub


Private Sub Form_Load()
    xpath$ = Command$
    If Right(xpath$, 1) <> "\" Then xpath$ = xpath$ + "\"
    LoadThumbNails xpath$
    PaintPage 1
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set PictureFiles = Nothing
    Set PictureThumbs = Nothing
    Set OneThumb = Nothing
End Sub


Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If CurPicture = "" Then Exit Sub
    'Clicked on Thumbnail for image with filename CurPicture so open in image processor
    ShellLine$ = "C:\WINDOWS\KODAKIMG.EXE " + CurPicture
    xx = Shell(ShellLine$, vbNormalFocus)
End Sub

Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    SpanX% = Int(X * PicsPerRow / Picture2.Width)
    SpanY% = Int(Y * PicsPerCol / Picture2.Height)
    ThumbNum% = (SpanY% * PicsPerRow) + SpanX%
    PictureNum% = ThumbNum% + (((VScroll1.Value - 1) * PicsPerRow * PicsPerCol) + 1)
    If PictureFiles.Count >= PictureNum% Then
        CurPicture = PictureFiles.Item(PictureNum%)
        Picture2.ToolTipText = CurPicture
    Else
        CurPicture = ""
        Picture2.ToolTipText = ""
    End If
End Sub


Private Sub VScroll1_Change()
    PaintPage VScroll1.Value
End Sub


 

by: MoondancerPosted on 2002-03-14 at 05:57:28ID: 6864457

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...