I'm not sure is it PB or Windows problem, tested with PB 5.5 and WinXP/7.
I was using console window to display some info from DLL and that was not funny when closing that window with button crashed whole host-processs ^^
Code: Select all
EnableExplicit
Define isConsole, WasOpened
Define StartTime = ElapsedMilliseconds()
Repeat
; here just opening console once if it was not opened already
If Not isConsole And Not WasOpened
isConsole = OpenConsole("test")
PrintN("Press any key to close console (NOT TO QUIT APP)...")
WasOpened = 1
EndIf
; checking console input and close console window if any key pressed
If isConsole
Inkey()
If RawKey()
CloseConsole()
isConsole = 0
; now console window is closed and all is fine, loop continues to work
EndIf
EndIf
; simulate application quit after 30 seconds
If Abs(ElapsedMilliseconds() - StartTime) >= 30000
Break
;
EndIf
Delay(128)
ForEver
; BUG: process terminated and this is never called if user closed console using "close" button instead of pressing any key
MessageRequester("Quitting", "")
; clean up on quit
If isConsole
CloseConsole()
isConsole = 0
EndIf
