Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Display arraylist in picturebox...

Posted on 2006-04-30
3
Medium Priority
?
694 Views
Last Modified: 2008-01-09
I'll try to explain this as best I can, so here it goes.

I have a scanned image that is normally transferred(displayed) in a new PicForm.  I would like for this scanned image to be displayed in a new PictureBox instead.  Anyhelp would be appreciated.  Here is the code:  This isn't all of the code that scans the image, etc because it would be way too much to paste in here.

Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
            Dim cmd As TwainCommand = tw.PassMessage(m)
            If (cmd = TwainCommand.Not) Then
                Return False
            End If

            Select Case cmd
                Case TwainCommand.CloseRequest
                    EndingScan()
                    tw.CloseSrc()
                Case TwainCommand.CloseOk
                    EndingScan()
                    tw.CloseSrc()
                Case TwainCommand.DeviceEvent
                Case TwainCommand.TransferReady
                    Dim pics As ArrayList = tw.TransferPictures()
                    EndingScan()
                    tw.CloseSrc()
                    picnumber += 1
                    Dim i As Integer
                    For i = 0 To pics.Count - 1 Step 1
                        Dim img As IntPtr = CType(pics(i), IntPtr)
                        Dim newpic As PicForm = New PicForm(img)
                        newpic.MdiParent = Me
                        Dim picnum As Integer = i + 1
                        newpic.Text = "ScanPass" + picnumber.ToString() + "_Pic" + picnum.ToString()
                        newpic.Show()
                    Next
            End Select

            Return True
        End Function
0
Comment
Question by:vilusion
  • 2
3 Comments
 

Author Comment

by:vilusion
ID: 16574144
Does anyone have any suggestions?
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 16574903
How are you going to arrange these new PictureBoxes?

The basic idea...

                    Dim pb As PictureBox
                    Dim i As Integer
                    For i = 0 To pics.Count - 1 Step 1
                        Dim img As IntPtr = CType(pics(i), IntPtr)
                        pb = New PictureBox
                        pb.Image = something...not sure how you are doing this...
                        pb.Size = New Size(50, 100)
                        pb.Location = New Point(i * 50, 25)
                        Me.Controls.Add(pb) ' or Panel1.Controls.Add(pb)
                    Next
0
 

Author Comment

by:vilusion
ID: 16578922
Here is the Class function that I have to better help.  I guess the idea I'm trying to solve here is instead of opening the image in a new PicForm, it creates a PictureBox (200px width by 300px height) on my form(frmMain) for each scanned image.  If you need anymore code, just let me know.

Public Function TransferPictures() As ArrayList
            Dim pics As ArrayList = New ArrayList
            If Equals(srcds.Id, IntPtr.Zero) Then
                Return pics
            End If

            Dim rc As TwRC
            Dim hbitmap As IntPtr
            Dim pxfr As TwPendingXfers = New TwPendingXfers()

            Do
                pxfr.Count = 0
                hbitmap = IntPtr.Zero

                Dim iinf As TwImageInfo = New TwImageInfo()
                rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf)
                If (rc <> TwRC.Success) Then
                    CloseSrc()
                    Return pics
                End If

                rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, hbitmap)
                If (rc <> TwRC.XferDone) Then
                    CloseSrc()
                    Return pics
                End If

                rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr)
                If (rc <> TwRC.Success) Then
                    CloseSrc()
                    Return pics
                End If

                pics.Add(hbitmap)
            Loop While (pxfr.Count <> 0)

            rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pxfr)
            Return pics
        End Function
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Screencast - Getting to Know the Pipeline
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

581 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