Hi All,

Firstly a hearty congratulations to those involved in contributing and
releasing 0.0.670

I have a rather large GUI app that can take 20 seconds or more to load, once
turned into an executable using ActiveStates PerlApp 5.2

During this time I wish to display a splash screen, provided by a
preliminary exe, which launches the main application exe, then dies once the
main exe is visible... similar to a lot of other major applications.

I've got most of it working but can't quite get the timing to display the
splash until the main application is visible. Despite seaching the web and
many lists I can't find anyone else attempting to do this. Any assistance
appreciated, and perhaps a candidate for the examples section on the 'The
Win32GUI Documentation Project'.

Chris Wearn
=================================================================

use Win32::GUI;
use Win32::Process;
#
$screen_width  = Win32::GUI::GetSystemMetrics(0);
$screen_height = Win32::GUI::GetSystemMetrics(1);
#
$window_minwidth  = 400;
$window_minheight = 300;
#
# hwnd is a handle to a window
my ($hWnd,$hInstance) = GUI::GetPerlWindow();
#
#====================================================================
# Splash Screen Bitmap
$imgSplash  = new Win32::GUI::Bitmap("./gfx/splash.bmp");
# Set Cursor
$curBusy        = new Win32::GUI::Cursor("./gfx/wait.cur");
Win32::GUI::SetCursor($curBusy);

# Construct the main window
$splashWin = new Win32::GUI::Window(
#====================================
        -name                   => "splashWin",
        -title          => "Splash",
        -left                   => ($screen_width - $window_minwidth) / 2,
        -top                    => ($screen_height - $window_minheight) / 2,
        -width          => $window_minwidth,
        -height         => $window_minheight,
        -minwidth               => $window_minwidth,
        -minheight              => $window_minheight,
        -style          => WS_POPUP,
);

$bmpSplash = $splashWin->AddLabel(
#====================================
        -left           => 0,
        -top            => 0,
        -width  => 400,
        -height => 300,
        -style  => 14,
        -name           => "Bitmap",
        -visible        => 1,
        -text           => "splash",
);
$bmpSplash->SetImage($imgSplash);

# Do the window thing...
$splashWin->Show;
$splashWin->Show;       # twice to avoid being preset by a 'start minimized'
shortcut

LaunchMainApp();
my $retcode = Win32::GUI::Dialog();

# Launch Prog2 then die
sub LaunchMainApp {
        $newProc = Win32::Process::Create($ProcessObj,
                        "c:\\progra~1\\app\\MainApp.exe",
                        "",
                        0,
                        NORMAL_PRIORITY_CLASS,
                        ".") || die ErrorReport();
        Win32::GUI::DoEvents();
        sleep 1;
        $desktop = GUI::GetDesktopWindow();
        $window = GUI::GetWindow($desktop, GW_CHILD);
        while($window) {
                $title = GUI::Text($window);
                if (($title eq "MainApp") and GUI::IsVisible($window)) {
                        printf("%16d: %s\n", $window, $title);
                        mainwin_Terminate();
                }
                $window = GUI::GetWindow($window, GW_HWNDNEXT);
        }
}

# Kill Application
sub mainwin_Terminate {
#====================================
        $splashWin->Disable();
        $splashWin->Hide();
        die;
}

sub ErrorReport {
        print Win32::FormatMessage( Win32::GetLastError() );
}


Reply via email to