-
while images are loading, if we try to close application it is not working.
In my project by selecting path loading all png images to application, while loading images if i try to close application its not working, After loading completion it is closing.
please tell me what is the problem.
-
1. Why would you want to close the application while it is loading the images? 
2. It can't do two things at once. If you start the images loading, then you would need to build in a cancel feature so the loading would stop. Then you could close it.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
if the loading process is under ur code, just put a "DoEvents"
otherwise, u can use the windows threading API and put the code where it asks the application to load picture in a separate thread. don't forget to interrupt the thread when closing or -in VB- u'll get an expected error.
-
This isn't VB.NET 
Classic VB applications are single threaded.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
 Originally Posted by Hack
Classic VB applications are single threaded.
Yes! they are, but u can use windows API for multithreading it ... well actually built-in VB controls have some kind of multithreading ...
-
Let's see the code, shamsam1
-
The following is the code what I a using
Private Sub OpenFolder()
Dim a6() As String
ReDim a6(Text1.Text + 100000) As String
Dim t As Double
On Error GoTo 1:
Dim i As Long
If PathFileExists(txtPath) = 0 Then Err.Raise 76
For i = 0 To ThumbList.Count - 1
If ThumbList.ItemData(i) > 0 Then Call FreeImage_Unload(ThumbList.ItemData(i))
Next i
Call ThumbList.Clear
t = 0
For i = 0 To List2.ListCount - 1
a6(t) = List2.List(i)
t = t + 1
Next i
For i = 0 To t - 1
Call ThumbList.AddItem(a6(i))
ThumbList.ItemText(1, ThumbList.Count - 1) = Slsh(File.Path) & a6(i)
Next i
If dOnFlyThumbs = 1 Then Exit Sub
InProc = True
For i = ThumbList.Count - File.ListCount To ThumbList.Count - 1
If Not InProc Then Exit For
Call CreateThumbnail(i) This is the code for loading
Call DoEventz
Next i
lbl_inf = ""
InProc = False:
Exit Sub
1: MsgBox Err.Description, vbExclamation, "OpenFolder"
End Sub
In form unload event
Private Sub Form_Unload(Cancel As Integer)
Call SaveAllSettings
Dim i As Long
For i = 0 To ThumbList.Count - 1
If ThumbList.ItemData(i) > 0 Then _
Call FreeImage_Unload(ThumbList.ItemData(i))
Next i
For i = 0 To ThumbList1.Count - 1
If ThumbList1.ItemData(i) > 0 Then _
Call FreeImage_Unload(ThumbList1.ItemData(i))
Next i
Open App.Path & "\savelist.dll" For Output As #1:
Close #1
FreeLibrary hLib
If InProc Then End
End Sub
If click form close button while loading images the close button is not getting activated. I dont want to use any extra button for close.
-
Simple soloution:
Code:
Private Sub Form_Unload(Cancel As Integer)
If InProc Then 'Cancel unloading, and alert the user with a beep
Cancel = 1
Beep
Exit Sub
End If
Call SaveAllSettings
Dim i As Long
For i = 0 To ThumbList.Count - 1
If ThumbList.ItemData(i) > 0 Then _
Call FreeImage_Unload(ThumbList.ItemData(i))
Next i
For i = 0 To ThumbList1.Count - 1
If ThumbList1.ItemData(i) > 0 Then _
Call FreeImage_Unload(ThumbList1.ItemData(i))
Next i
Open App.Path & "\savelist.dll" For Output As #1:
Close #1
FreeLibrary hLib
'If InProc Then End 'Never use End
End Sub
Better soloution:
This will require you to shift some code around a bit...
Declare a variable at the top, so it's visible to all procedures, e.g.
Code:
Private bExiting As Boolean
Then when Form_Unload is called, JUST set bExiting to true. Move all the code currently in Form_Unload into Form_Terminate for now.
Then in your loop you need to check if the user has clicked exit:
Code:
If dOnFlyThumbs = 1 Then Exit Sub
InProc = True
For i = ThumbList.Count - File.ListCount To ThumbList.Count - 1
If Not InProc Or bExiting Then Exit For 'EDITED HERE
Call CreateThumbnail(i) This is the code for loading
Call DoEventz
Next i
lbl_inf = ""
InProc = False:
Exit Sub
1: MsgBox Err.Description, vbExclamation, "OpenFolder"
End Sub
In fact, you might get away with leaving the code in Form_Unload.
-
I have changed code from form_unload to form_terminate
and I have added the boolean variable also.
Even though my close button is not working if I click. The control is not getting into the event until all images get loaded.
I debugged the code. But the event starts working after all the images getting loaded.
The close button is highlighted. But the event code associated is not working.
-
Which soloution did you use?
-
I have set the boolean variable and set the follwoing code for loading images,
If Not InProc Or bExiting Then Exit For
Then in form_terminate I set bExiting=true
The close is button highlighting but it is not working to execute the associated code.
Similar Threads
-
By krishna in forum Careers
Replies: 0
Last Post: 11-25-2002, 11:05 PM
-
By Michael Shutt in forum Web
Replies: 0
Last Post: 06-26-2001, 02:25 PM
-
By Ben CoopeR in forum Java
Replies: 0
Last Post: 05-17-2001, 10:58 AM
-
Replies: 0
Last Post: 11-30-2000, 10:08 AM
-
By Al Bowen in forum Java
Replies: 1
Last Post: 08-15-2000, 10:58 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks