Glenn Linderman wrote:

"Console" is the correct name for what you are calling a "DOS window". That might help you find relevant documentation.

However, consoles are quite different in behavior than other windows, apparently even having their own process to handle them, and the message sequence is quite different than for other windows.

Minimized and hidden are, indeed, two different attributes of a window. Seems like if you want to "minimize to a tray icon" you'd want to hide the console whether or not it had already been minimized.

There is Win32::GUI::Hide and Win32::GUI::Show, which, when passed the result of Win32::GUI::GetPerlWindow, will hide and show it, respectively. I think it takes as many Shows as Hides to make a console reappear.

If IsVisible works on the console, I think you have a sufficient solution. If not, show some code, preferably a complete but not quite working test application that can be run on anyone's machine, and describe a use case that fails.

I've already got the Win32::GUI::Hide and Win32::GUI::Show methods and they work great. That is not what I'm looking for. Okay here is a program that uses Hide and Show on a 'console' window:

#!usr/bin/perl

use strict;
use Win32::GUI;

# Get DOS handle
my ($DOS) = Win32::GUI::GetPerlWindow();

# Tray Icon
my $window = new Win32::GUI::Window;
my $systray_icon = $window->AddNotifyIcon( -name => "_Systray", -id => 1, -icon => new Win32::GUI::Icon('mypic.ico'), -tip => "Test" );

# Main Loop
while (1) {
   $window->DoEvents();
}

# Tray Icon Sub
sub _Systray_Click {
   if(Win32::GUI::IsVisible($DOS)) { Win32::GUI::Hide($DOS); }
   else { Win32::GUI::Show($DOS); }
}

This script uses an icon file, you'll have to provide one to play with it. Now, this works fine. When you click the tray icon, the console disappears, when you click it again, it reappears. What I want to do know is test whether the console window has been minimized so that I can then hide the window ie: minimize to tray.

if ($DOS = minimized) { Win32::GUI::Hide($DOS); }

Roger Mayfield

Reply via email to