Page 1 of 1
OpenConsole() to return window handle if successful
Posted: Sat Nov 24, 2007 7:55 am
by Mistrel
The console handle can be obtained through this method already
Code: Select all
OpenConsole()
*hwndConsole = GetForegroundWindow_()
Print("Console Window Handle = " + Str(*hwndConsole))
Input()
But it would be much more convenient if the handle were returned upon creation.
Re: OpenConsole() to return window handle if successful
Posted: Mon Feb 11, 2008 9:29 am
by horst
I support this suggestion.
The GetForegroundWindow_() method is not safe, because it assumes that the console window is in the foreground. I just managed to crash the PB IDE, just because it happened to be in the foreground (it was not involved in the testing of the compiled console program).
I use this method:
Code: Select all
ConTitle$ = Space(300)
If GetConsoleTitle_(@ConTitle$,300)
ConsoleHandle = FindWindow_(0,@ConTitle$)
EndIf
which will at least avoid catching a non-console window.
@PB team:
Is there any reason why OpenConsole() does not return the console handle?
Posted: Mon Feb 11, 2008 12:19 pm
by hallodri
On win 2000,xp and vista can can you use GetConsoleWindow().
Code: Select all
Import ""
GetConsoleWindow()
EndImport
OpenConsole()
hwndConsole = GetConsoleWindow()
Print("Console Window Handle = " + Str(hwndConsole))
Input()
Posted: Wed Feb 13, 2008 8:50 am
by horst
hallodri wrote:On win 2000,xp and vista can can you use GetConsoleWindow().
Code: Select all
Import ""
GetConsoleWindow()
EndImport
OpenConsole()
hwndConsole = GetConsoleWindow()
Print("Console Window Handle = " + Str(hwndConsole))
Input()
Thanks, but what the heck is
Import "" ? I could not find any documentation about importing nothing.