I think you may be looking in the wrong direction! The key to
updating is in handling the Paint event triggered whenever
Windows thinks a window (or part thereof) should be repainted.
This covers the situations you describe.
Win32::GUI uses an approach that means you must redraw *everything*
that is displayed. In theory, you can get away with redrawing just
part of the window, but it is much easier to simply re-run the whole
display routine each time.
In the code snippets below, showall(); does all the drawing, which in my
program is quite an extensive operation. Nevertheless, the update is
very smooth and looks just like real Windows - and better than some
commercial programs I have encountered.
NB. The $dc->Validate(); is very important.
-------------------------------------------
# this is a graphic "canvas" where everything is displayed
$Win2 = new Win32::GUI::Graphic(
-parent,$Win,
-name, 'workwin',
-left, 0,
-top, $win2top,
-height, $Win->Height(),
-width, $Win->Width(),
);
# this is the DC for the graphic
my $dc = $Win2->GetDC;
# this fires every time window needs repainting
# (Windows sends the notification)
sub workwin_Paint {
showall(); # all the display activity
$dc->Validate(); # very important
}
-------------------------------
Alan
Original message:
From: Jonathan Southwick <jsouthwi@...>
Subject: [perl-win32-gui-users] need subroutine to run when Window gets focus
Is there any way to get a routine to run when a window is brought to the
top or receives focus? That seems to be the only way I can get a DC object
to refresh after it is covered by another window.
Jonathan

At 16:31 2002-11-13 -0500, Jonathan Southwick wrote:
>How difficult is it to paint on a Graphics control? The graphics stuff is
>new to me.
It's the same thing as paiting on a DC (because that's what you actually do
:).
The Graphics control doesn't seem too well documented (and I have forgot
the exact syntax), but this is the Design window in The GUI Loft (slightly
edited):
sub ::grCanvas_Paint {
my($dcDev) = @_;
#Now you paint on the $dcDev which is a DC object.
Look at the documentation for the DC control, and at the Win32::GUI::AdHoc
module for additional ways to paint stuff on a DC. The Win32 SDK
documentation is also useful to read.
/J
-------- ------ ---- --- -- -- -- - - - - -
Johan Lindström Sourcerer @ Boss Casinos johanl@...
Latest bookmark: "Perfect Productivity - Tony Bowden Understandin..."
http://www.tmtm.com/insanity/2002/11/12.html
dmoz (1 of 22): /Society/Activism/Media/Radio/ 63

Thanks. That worked. I just wish the stuff would stay on the graphic=20
window as I drag other windows away from the face of it. But this works as=
=20
a work-around.
How difficult is it to paint on a Graphics control? The graphics stuff is=
=20
new to me.
Thanks again.
Jonathan
At 11/13/2002 10:04 PM, you wrote:
>At 11:45 2002-11-13 -0500, Jonathan Southwick wrote:
>>Is there any way to get a routine to run when a window is brought to the=
=20
>>top or receives focus? That seems to be the only way I can get a DC=20
>>object to refresh after it is covered by another window.
>
>The event Activate is triggered when the window is activated.
>
>sub yourWindowName_Activate {
> refreshMyStuff();
> return(1);
>}
>
>But if you drag another window over your DC, it won't be repainted like=20
>this (the event will never trigger). For that you need to paint on a=20
>Graphics control and use the Paint event to trigger the refresh.
>
>
>/J
>
>-------- ------ ---- --- -- -- -- - - - - -
>Johan Lindstr=F6m Sourcerer @ Boss Casinos johanl@...
>
>Latest bookmark: "Perfect Productivity - Tony Bowden Understandin..."
>http://www.tmtm.com/insanity/2002/11/12.html
>dmoz (1 of 22): /Society/Activism/Media/Radio/ 63
>
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by: Are you worried about your web server=20
>security? Click here for a FREE Thawte Apache SSL Guide and answer your=20
>Apache SSL security needs: http://www.gothawte.com/rd523.html
>_______________________________________________
>Perl-Win32-GUI-Users mailing list
>Perl-Win32-GUI-Users@...
>https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users

At 11:45 2002-11-13 -0500, Jonathan Southwick wrote:
>Is there any way to get a routine to run when a window is brought to the
>top or receives focus? That seems to be the only way I can get a DC
>object to refresh after it is covered by another window.
The event Activate is triggered when the window is activated.
sub yourWindowName_Activate {
refreshMyStuff();
return(1);
}
But if you drag another window over your DC, it won't be repainted like
this (the event will never trigger). For that you need to paint on a
Graphics control and use the Paint event to trigger the refresh.
/J
-------- ------ ---- --- -- -- -- - - - - -
Johan Lindström Sourcerer @ Boss Casinos johanl@...
Latest bookmark: "Perfect Productivity - Tony Bowden Understandin..."
http://www.tmtm.com/insanity/2002/11/12.html
dmoz (1 of 22): /Society/Activism/Media/Radio/ 63

Not sure of the exact syntax but it would be something like:
if ($Window->GetFocus())
{
&do_something;
}
> -----Original Message-----
> From: Jonathan Southwick [mailto:jsouthwi@...]
> Sent: Wednesday, November 13, 2002 11:45
> To: perl-win32-gui-users@...
> Subject: [perl-win32-gui-users] need subroutine to run when
> Window gets
> focus
>
>
>
> Is there any way to get a routine to run when a window is
> brought to the
> top or receives focus? That seems to be the only way I can
> get a DC object
> to refresh after it is covered by another window.
>
> Jonathan
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Are you worried about
> your web server security? Click here for a FREE Thawte
> Apache SSL Guide and answer your Apache SSL security
> needs: http://www.gothawte.com/rd523.html
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
>

Is there any way to get a routine to run when a window is brought to the
top or receives focus? That seems to be the only way I can get a DC object
to refresh after it is covered by another window.
Jonathan

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

CountryState

JavaScript is required for this form.

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details