ADSin wrote...
Actually I'm referring to the process not being unloaded on the form, which I just checked now that I'm home and it's the main form, what are you using for the exit code? are you making sure to unload it properly?
*edit: just had a quick look and the menutoolbar's exit successfully unloads the form(s), so I'm going to assume you just need to throw it into the actual unload function and not a click. I haven't touched VB in years, but this much is basic:
[code:1]Private Sub Form_Unload()
Unload Whatever_Form_You_Have //unload these forms first
Unload Another_Form_You_Have //see above
Unload Me //unload the current form when done unloading the others
End Sub[/code:1]
When im exiting the application is use the
End keyword, which Unloads everything and ends the app. I think I know why the Main Form is still loaded. When the Main Form is being unloaded, i call the unhook function without checking if the hook was initialized. In other words, I had this:
[code:1]
'Form: frmMain
Private Sub Form_Unload(Cancel As Integer): On Error Resume Next
Call mWndProcAndSideBar.hideSibeBar
Call mWndProcAndSideBar.unhookWindowHook
End
End Sub
'Module: mWndProcAndSideBar
Public Function unhookWindowHook()
Call UnhookWindowsHookEx(hHook)
End Function
[/code:1]
instead of this:
[code:1]
Public Function unhookWindowHook()
If (hHook <> 0) Then
Call UnhookWindowsHookEx(hHook)
hHook = 0
End If
End Function
[/code:1]
[size=12]VB becomes very "delicate" with things like hooks and threads. During the Unload event, it errored out (even with Resume Next) before End was called which led to the "improper unloads." Hell, I tried using CreateThread() for async calls and the app totally crashed. The Exit button in the menu bar worked properly because i just called End. The reason why I just put End in the the Exit button event was because it was now legacy, aka old code. The End button code was there from the beginning since the only thing it did was end the app. There was no need for cleanup since all the forms were modal. I only added the unhook code to the Unload event. I didnt remember anything about the End click event. Anyway, thanks for pointing this out. Another step in the elimination of bugz! LOL! +1 rep 4 u! Btw, I know what "event-driven code" means.[/h]
ADSin wrote...
You're working with a lot of forms so you have to make sure to unload them all, I'm guessing the startup splash with music is the first one and maybe that's the one that isn't unloading since it seems you're just hiding it and loading the 2nd form...
No. When im done with a Form I unload it.
[code:1]
Call Unload(Me) 'Unload login form
Call frmStartup.makeUnloadReady 'Sets a variable to allow Unload
Call Unload(frmStartup) 'Unload startup form
Call frmMain.Show 'Show main form
[/code:1]
ADSin wrote...
It's not such a big deal, but I noticed some CPU usage, and realized you were loaded 8 times in my list from improper unloads.
The CPU usage you saw was probably because I prefer Synchronous code. The code becomes more structured that way and is easier to read primarily because it uses more local than global vars. Even though I said sync, i dont mean actually sync code. I add some DoEvents and in some cases Sleep (from Kernel32.dll). I may need to increase the sleep time and add some more calls to it. Example:
[code:1]
Public Function getPageSource(ByVal add As String, ByVal toFind As String, ByVal startTag As String, _
ByVal endTag As String) As String: On Error GoTo ERR
strToFind = toFind
strStartTag = startTag
strEndTag = endTag
strHTML = ""
Call itcMain.Cancel
itcMain.protocol = icHTTP
itcMain.url = add
Call itcMain.execute
While ((itcMain.StillExecuting = True) And (strHTML = ""))
Call Sleep(100)
DoEvents
Wend
getPageSource = strHTML
Exit Function
ERR:
getPageSource = ""
End Function
[/code:1]
ADSin wrote...
As for the joke, I'm sort of a gundam fan, sort of a star wars fan, but not so much on Deathnote :P
I liked the music though, it's a good loader.
Why thank you.