PowerShell Out-GridView doesn't appear the first time
Brought to you by:
bozho
After launching Console running PowerShell 2, the Out-GridView cmdlet is supposed to launch another GUI window (not a console window) with output. On my Vista SP2 system, it works correctly in the built-in console window, but not Console 2.00.145 beta. A button appears in the Taskbar, but no window. You can right-click and choose to Maximize this window and it will appear maximized, but restoring it will hide it again. Making the PowerShell console window visible does not change this.
However, the second and all subsequent times you run Out-GridView, the grid window appears normally.
I don't know if this is an issue with PowerShell 2 specifically, or launching GUI windows in general.
David,
By any chance do you have Start Windows console hidden checked in Console section of Settings dialog? If so, does it work better if you uncheck it?
--
Kirill.
No, "Start Windows console hidden" is not checked.
David,
could you please try to check that checkbox? (Yes, I know it sounds counter-intuitive :)
Marko,
the problem seems to relate to the initial shell position. After I commented out
si.dwFlags = STARTF_USEPOSITION;
in ConsoleHandler::StartShellProcess, I could not reproduce David's problem.
I think we should remove that else block and just live with blinking console window (unless you want to specify the initial position in settings).
This actually may explain why checking that checkbox helped Derrel (https://sourceforge.net/projects/console/forums/forum/143117/topic/3538376 )
--
Kirill.
I forgot that child process' initial position can depend on its parent's initial position. We can try two things:
1. not use STARTF_USEPOSITION flag
2. USe tha flag, but move the hidden window after it's been created.
Huh. Checking the box makes it work: the Out-GridView window appears on the first try.
David,
The problem here is the way GUI windows are created from a child process.
Console has two options when starting a child process:
1. Start a process with its console window hidden
2. Start a process with its console window off the screen
No. 1 has the advantage that a user doesn't see a console window flash in the taskbar when opening a new tab. A problem occurs if the child process opens a new GUI window and doesn't explicitly set GUI window's state to visible. In that case, the GUI window inherits its parent's startup visibility setting, i.e. hidden. I think 4NT had problems with that...
No. 2 solves the GUI window problem, but a user will see console window button flash in the taskbar. Another problem is the one you encountered, where child window placement depends on its parent's position (i.e. offscreen :-) We might be able to fix that.
As I don't have a lot of experience with PowerShell, could you attach an example that illustrates the problem?
Thank you,
Marko