1

I am struggling to make a simple receive WM_DISPLAYCHANGE informing my Win32::GUI app that the Windows Screen Resolution has changed, since the results for this question here is "0" accordingly informed by the search engine.

Could you provide a simple working example of a simple Win32::GUI program that detects a WM_DISPLAYCHANGE message and prints some info about that change in resolution?

2 Answers 2

2

From user "beech" at PerlMonks: http://perlmonks.org/index.pl?node_id=1171819

Try using the Hook method:

something like

$main->Hook( WM_DISPLAYCHANGE(), \&onDisplayChange );
sub onDisplayChange {
    my( $object, $wParam, $lParam, $type, $msgcode) = @_;
    print "Click handler called!\n";
}
Sign up to request clarification or add additional context in comments.

1 Comment

When quoting, it would be nice to provide a reference alongside proper attribution. Otherwise it will look like plagiarism.
0

Give a name to your window. Let's call it Main.

$main = Win32::GUI::Window->new(
                -name   => 'Main',
                -width  => 100,
                -height => 100,
        );

Now, define an event handler for the window. It should be of below pattern:

<window name>_<event name>

For example, for Resize event the event handler should be Main_Resize.

sub Main_Resize {
    my $mw = $main->ScaleWidth();
    my $mh = $main->ScaleHeight();
    my $lw = $label->Width();
    my $lh = $label->Height();
    #print the height/width or whatever you want
}

I would suggest going through Win32::GUI::Tutorial.

2 Comments

This doesn't address the question. Please pay attention, when editing a question to not ask a different one. The question is (was) asking about receiving the WM_DISPLAYCHANGE message.
Hi Chankey, thanks for your interest in this matter. WM_DISPLAYCHANGE is a message sent by Windows through the system to inform a screen resolution change. For example: change your screen resolution from 1024x768 to 800x600, then WM_DISPLAYCHANGE is sent. I am trying to detect inside a Win32::GUI perl app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.