[Home]Vanishing Titlebar

WikiHome | RecentChanges | Preferences | Index | Win32::GUI Home

No diff available--this is the first major revision. (minor diff, author diff)

The code below shows how to dynamically change window decorations at run time. The trick is the call to the windows API SetWindowPos? with the SWP_FRAMECHANGED flag set. In this example the window title bar is removed when the mouse enters the window.

The example also shows the usage of the Win32::GUI::TrackMouseEvent?() methods to enable the MouseOver? and MouseOut? events.

#!perl -w use strict; use warnings; use Win32::API; use Win32::GUI qw(WS_CAPTION); my $SetWindowPos = Win32::API->new("user32","SetWindowPos", "LLLLLLL", "L") or die "Failed to load SetWindowPos"; sub TME_HOVER() {1} sub TME_LEAVE() {2} sub HOVER_DEFAULT() {0xFFFFFFFF} sub SWP_FRAMECHANGED() {32} sub SWP_NOMOVE() {2} sub SWP_NOSIZE() {1} sub SWP_NOZORDER() {4} sub SWP_NOACTIVATE() {16} my $state = 0; # 0 - out; 1 - in; my $mw = Win32::GUI::Window->new( -title => "Vanishing Title Bar", -pos => [100,100], -size => [400,300], -onMouseOver => sub {print "Hover\n"; return 0;}, -onMouseOut => \&Out, -onMouseMove => \&Move, ); $mw->Show(); Win32::GUI::Dialog(); exit(0); sub Out { print "Out\n"; $mw->Change(-pushstyle => WS_CAPTION), $SetWindowPos->Call($mw->{-handle}, 0, 0, 0, 0, 0, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); $state = 0; return 0; } sub Move { return unless $state == 0; $mw->Change(-popstyle => WS_CAPTION), $SetWindowPos->Call($mw->{-handle}, 0, 0, 0, 0, 0, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); print "In\n"; $state = 1; $mw->TrackMouse(1000,TME_HOVER|TME_LEAVE); return 1; }

WikiHome | RecentChanges | Preferences | Index | Win32::GUI Home
This page is read-only | View other revisions
Last edited February 16, 2006 7:48 am by inspire.msi.vxu.se (diff)
Search: