Re: [perl-win32-gui-hackers] [win32-gui] Re: Win32::GUI::Console

2006-06-08 Thread Reini Urban

2006/6/7, Robert May <[EMAIL PROTECTED]>:

Glenn Linderman wrote:
> On approximately 6/6/2006 2:08 PM, came the following characters from
> the keyboard of Robert May:
>> Reini Urban wrote:
>>> Robert May schrieb:
>>> ...
 If only there was a way to ask AllocWindow() to create a hidden console,
 but I read that it's impossible.  (I do want to explore the possibility
 of using a global hook to see if I can catch one of the messages that
 happens early during window creation, and fiddle the WS_VISIBLE style,
 but I'm not hopeful!)

I can confirm that as I read elsewhere, it does not seem possible to
either subclass or hook (SetWindowsHookEx(WH_CBT, ...)) a console window.

>>> You can create it offscreen, to the right or left.
>>> So you can use CreateProcess() with
>>> dwCreationFlags += CREATE_NEW_CONSOLE, instead of AllocConsole()
>>>
>>> And STARTUPINFO.dwX holds the offscreen position.
>> Interesting idea, but I don't think I'm following you here.
>> CreateProcess() will create me a new process, and I can't see how I'd
>> read/write to that process's console from my perl script.
>>
>> Regards,
>> Rob.
>
> It seems that Reini's idea might be useful to stop flashing consoles for
> subprograms, but not for the original program?

That was my thinking too - but perhaps Reini is
hinting at something that I do not understand?


No, I mixed it up.
perl2app --gui / pp --gui  created apps, have no console.
So I create them with AllocConsole or CreateProcess and
redirect STDERR/STDOUT to this window, and display it only when requested.
To work around the flashing issue I can
1) create it only when requested, but then I loose the previous output,
2) or create it hidden or offscreen and show/move it when requested.
Menu: View - Messages...

But better is to create the app without --gui and hide the console as
discussed here.


If you want to start a sub-process hidden, then
   Win32::SetChildShowWindow(SW_HIDE);
is probably easier :-)


Correct.

--
Reini Urban
http://phpwiki.org/
http://spacemovie.mur.at/   http://helsinki.at/



Re: [perl-win32-gui-hackers] [win32-gui] Re: Win32::GUI::Console

2006-06-08 Thread Robert May

Reini Urban wrote:

Robert May schrieb:
...
If only there was a way to ask AllocWindow() to create a hidden console


[huge snip]


perl2app --gui / pp --gui  created apps, have no console.
So I create them with AllocConsole or CreateProcess and
redirect STDERR/STDOUT to this window, and display it only when requested.


Can I check I understand what you are saying here:

(1) If I create an app with 'pp --gui', and then run it by clicking the 
exe, I get my window app, without a console.


(2) At some point in my program I want to use print() to output a text 
string.


(2) I understand how, at that point, I can use AllocConsole(), along 
with a redirection of STDOUT to get the print()ed output to appear on a 
console.


(3) Now, say that I don't want to show the console when I create it - 
there is no way to achieve this with AllocConsole(), so I create the 
console, and immediately hide it, but get a console 'flash'.


You seen to be saying that I can use CreateProcess() to create a console 
that I can then redirect STD(IN|OUT|ERR) to in order to see my output. 
If so, then can you give me a bit more detail about the CreateProcess 
mechanism you use here.  I don't understand what I would pass as the 
CreateProcess() parameters to achieve this.



To work around the flashing issue I can
1) create it only when requested, but then I loose the previous output,


I intend that Win32::GUI::Console will have an "on-demand" mechanism to 
create a console when the first write to STD(OUT|ERR) happens.


Regards,
Rob.