Hello,
I have this program and when i want to load pictures it crashes at the form.showdialog ()....???
Here it goes: -
Private Sub CmbPath_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmbPath.SelectedIndexChanged
-
-
-
Dim Table As DataTable
-
Dim i As Integer
-
Dim ThumbSize As Integer = 160
-
Dim ThumbNail As Image = Nothing
-
-
FlowLayoutPanel1.Controls.Clear()
-
-
Dim SQL As String = "SELECT fotonaam, fotomap, textveld FROM foto WHERE (fotomap = '" & Replace(CmbPath.Text, "'", "''") & "');"
-
-
Table = SelectQuery(SQL)
-
Dim ThumbPicturearr(Table.Rows.Count) As PictureBox
-
Dim TextField(Table.Rows.Count) As TextBox
-
Dim FlowPanel(Table.Rows.Count) As FlowLayoutPanel
-
-
While Table.Rows.Count <> i
-
-
Dim Photo As Image = Image.FromFile((Table.Rows(i).Item("fotomap") & "\" & Table.Rows(i).Item("fotonaam")))
-
Try
-
-
'Determine the scale of the imahe
-
Dim Scale As Single = CSng(IIf(Photo.Width > Photo.Height, ThumbSize / Photo.Width, ThumbSize / Photo.Height))
-
-
Dim Width As Integer = CInt(Photo.Width * Scale)
-
Dim Height As Integer = CInt(Photo.Height * Scale)
-
-
ThumbNail = Photo.GetThumbnailImage(Width, Height, Nothing, New IntPtr)
-
-
Catch ex As Exception
-
-
MsgBox("Error creating thumbnail:" & vbCr & ex.Message)
-
-
End Try
-
-
Try
-
ThumbPicturearr(i) = New PictureBox
-
ThumbPicturearr(i).Name = "Foto" & i
-
ThumbPicturearr(i).Height = 130
-
ThumbPicturearr(i).Width = 160
-
ThumbPicturearr(i).BackColor = Color.DarkGray
-
ThumbPicturearr(i).Image = ThumbNail
-
ThumbPicturearr(i).SizeMode = PictureBoxSizeMode.Zoom
-
ThumbPicturearr(i).BorderStyle = BorderStyle.Fixed3D
-
-
TextField(i) = New TextBox
-
TextField(i).BackColor = Color.DarkGray
-
TextField(i).ForeColor = Color.WhiteSmoke
-
TextField(i).Font = New Font("Ms sans serif", 12, FontStyle.Regular, GraphicsUnit.Pixel)
-
TextField(i).Size = New Size(160, 20)
-
TextField(i).TextAlign = HorizontalAlignment.Center
-
TextField(i).Text = Table.Rows(i).Item("textveld")
-
TextField(i).BorderStyle = BorderStyle.FixedSingle
-
TextField(i).Enabled = False
-
TextField(i).Location = New Point(ThumbPicturearr(i).Location.X - 10, ThumbPicturearr(i).Location.Y + 5)
-
-
FlowPanel(i) = New FlowLayoutPanel
-
FlowPanel(i).Size = New Size(170, 170)
-
FlowPanel(i).BackColor = Color.DarkGray
-
FlowPanel(i).FlowDirection = FlowDirection.TopDown
-
-
FlowPanel(i).Controls.Add(ThumbPicturearr(i))
-
FlowPanel(i).Controls.Add(TextField(i))
-
-
FlowLayoutPanel1.Controls.Add(FlowPanel(i))
-
-
ThumbNail.Dispose()
-
-
'Increase the counter
-
i = i + 1
-
-
Catch ThumbError As Exception
-
-
MsgBox("Error creating thumbnails for pictureboxes:" & vbCr & ThumbError.Message)
-
-
End Try
-
-
End While
-
-
Table.Dispose()
-
-
-
End Sub
-
-
' AND THEN HERE IT CRASHES AFTER I CALLED THE FORM YOU"LL SEE A PART OF IT UP HERE
-
-
Dim EditPhoto As New Bewerk
-
-
EditPhoto.ShowDialog()
-
-
At editPhoto.ShowD ialog() i get the error: Parameter is not valid.
Strange, because the form has already been loaded....
Anybody an idea?
ohyeah, when i replace "ThumbPicturear r(i).Image = ThumbNail" with "ThumbPicturear r(i).Image = Image.FromFile( "c:\" & Table.rows(i).I tem("fotonaam") " it's working but i don't want him to make al kind of little pictures but directly add the thumbs to the pictureboxes...
Thanks in advance!
Paul
2 1551 Plater 7,872
Recognized Expert Expert
Which line does the error actually say it is occuring on? It shouldn't be on the ShowDialog() call, unless that form was already loaded and visible maybe?
Also, when you call .Dispose() on the iamge, it disposes all references to it.
So you would need to change this:
ThumbPicturearr (i).Image = ThumbNail
to this:
ThumbPicturearr (i).Image = ThumbNail.Clone ()
If you want to call .Dispose() on the image.
Hmm, Why are some answers so simpel, as the question looks very difficult???
That worked perfect!
Just added .clone beheind there an that was it!
Thanks!
(p.s. i like this forum, it's great!)
Regards, Paul
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Neil Ginsberg |
last post by:
I have a strange situation with my Access 2000 database. I have code in the
database which has worked fine for years, and now all of a sudden doesn't
work fine on one or two of my client's machines. The code opens MS Word
through Automation and then opens a particular Word doc. It's still working
fine on most machines; but on one or two of them, the user is getting an
Automation Error. The code used is as follows:
Dim objWord As...
|
by: James Dean |
last post by:
In my program i create a 32ARGB bitmap. To actually create the bitmap
seems very slow. In fairness the file size is very big. I support
multiple bitmaps as well. I have to convert these bitmaps to thumbnails
also which again seems very slow. There is a memory bitmap but i can't
seem to find any good information about it. I want to be able to create
a 32bpp bitmap as fast as possible and also try to make a thumbnail as
fast as possible too....
|
by: James Dean |
last post by:
I have thought about creating a thumbnail from my full image but its too
slow. What is the best algorithm to use for creating a thumbnail
directly from data by yourself. What algorithm do microsoft use to
create the thumbnail image......
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
|
by: asad |
last post by:
Hello friends, how ru all, i have some problem about saving created
thumbnail, following is the code i use for creating thumbnail but thumbnail
was not saved it is on memory which method is used to store created thumbnail
in to hard disk
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"
%>
<%@ Import Namespace="System.Drawing.Imaging"%>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |