Close console without terminating application
Close console without terminating application
Hello
Is there a way to prevent terminating the whole application when closing a console opened with Openconsole() ?
Thanks
Is there a way to prevent terminating the whole application when closing a console opened with Openconsole() ?
Thanks
Re: Close console without terminating application
https://www.purebasic.fr/english/viewtopic.php?t=21334
https://www.purebasic.fr/english/viewtopic.php?t=82733
...and numerous more...
https://www.purebasic.fr/english/viewtopic.php?t=82733
...and numerous more...
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Close console without terminating application
Thanks. But they doesn't answer my question, otherwise I wouldn't have postedjacdelad wrote: Tue Jan 23, 2024 12:22 am https://www.purebasic.fr/english/viewtopic.php?t=21334
https://www.purebasic.fr/english/viewtopic.php?t=82733
...and numerous more...
Re: Close console without terminating application
I'm quite sure they do answer your question. But someone may correct me if I'm wrong.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Close console without terminating application
He don't want to avoid to close the console.
He want to avoid that the whole program is terminated if he use CloseConsole().
Am I right?
He want to avoid that the whole program is terminated if he use CloseConsole().
Am I right?
Re: Close console without terminating application
Exactly. the mentioned examples detect when the console is being closed but doesn't prevent the app from closing.infratec wrote: Tue Jan 23, 2024 7:48 am He don't want to avoid to close the console.
He want to avoid that the whole program is terminated if he use CloseConsole().
Am I right?
Re: Close console without terminating application
they don't. those examples detect when the console is being closed but don't prevent the whole app (GUI, windows, etc) from terminatingjacdelad wrote: Tue Jan 23, 2024 6:26 am I'm quite sure they do answer your question. But someone may correct me if I'm wrong.
Re: Close console without terminating application
Yepp. Afaik it's not possible to do this. Closing the console always closes the application too. The onlY way would be preventing to close the console which is also between hard to do and impossible.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Close console without terminating application
I tried hiding the console window, which doesn't work neitherjacdelad wrote: Tue Jan 23, 2024 2:41 pm Yepp. Afaik it's not possible to do this. Closing the console always closes the application too. The onlY way would be preventing to close the console which is also between hard to do and impossible.
Re: Close console without terminating application
CloseConsole() not end the program ... Stop the console input, but close not close the terminal window
You can hide the window
Update
You can hide the window
Update
Code: Select all
CompilerIf #PB_Compiler_ExecutableFormat <> #PB_Compiler_Console
CompilerError "Set Compiler Option Console!"
CompilerEndIf
Import ""
GetConsoleWindow()
EndImport
If OpenConsole()
Print("Input 1: ")
a$ = Input()
CloseConsole()
EndIf
hWnd = GetConsoleWindow()
ShowWindow_(hWnd, #SW_HIDE)
Delay(2000)
ShowWindow_(hWnd, #SW_NORMAL)
If OpenConsole()
Print("Input 2: ")
a$ = Input()
CloseConsole()
EndIf
ShowWindow_(hWnd, #SW_HIDE)
For i = 1 To 10
Debug i
Delay(500)
Next
Last edited by mk-soft on Tue Jan 23, 2024 7:00 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Close console without terminating application
it does. try opening a windowmk-soft wrote: Tue Jan 23, 2024 6:46 pm CloseConsole() not end the program ...
Code: Select all
If OpenConsole() Print("Input: ") a$ = Input() CloseConsole() EndIf Delay(1000) If OpenConsole() Print("Input 2: ") a$ = Input() CloseConsole() EndIf For i = 1 To 10 Debug i Delay(500) Next
Re: Close console without terminating application
You write a console program or a window application.
You should not mix them.
P.S. Update my example with hide console
You should not mix them.
P.S. Update my example with hide console
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Close console without terminating application
Simple with one linejacdelad wrote: Tue Jan 23, 2024 2:41 pm Yepp. Afaik it's not possible to do this. Closing the console always closes the application too. The onlY way would be preventing to close the console which is also between hard to do and impossible.
Code: Select all
DeleteMenu_(GetSystemMenu_(GetConsoleWindow(), #False),#SC_CLOSE, #MF_BYCOMMAND);
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Close console without terminating application
...only on Windows.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD


