I'm using Win32::GUI and the LostFocus event. When the LostFocus event fires, I would like to know which object will get the focus next. I have searched, and searched and couldn't find anything definitive. The closest guess I had was Win32::GUI->GetMessage() but I'm not sure I understand how to use it. The docs say:
GetMessage([MIN=0, MAX=0]) Retrieves a message sent to the window, optionally considering only me +ssages identifiers in the range MIN..MAX. If a message is found, the function returns a 7 elements array contain +ing: - the result code of the message - the message identifier - the wParam argument - the lParam argument - the time when message occurred - the x coordinate at which message occurred - the y coordinate at which message occurred If the result code of the message was -1 the function returns undef. N +ote that this function should not be normally used unless you know ve +ry well what you're doing.
I tried the following only printing the first four elements since I wasn't really interested in the time or click coordinates:
my @message = Win32::GUI->GetMessage(); print "MESSAGE: " . join(",",@message[0..3]) . "\n\n";
Which returned something like this:
MESSAGE: 1,49315,17,526238
So I get the result code which is always 1.
And the message identifier which is always 49315. I suppose this means LostFocus since that is the event that is being triggered.
Also the wParam is always 17. I thought this would be the handle of the window that lost focus but I'm obiviously mistaken and I have no idea what this means.
And the lParam which seems to correspond to the window that will get the focus. My main problem here is that I always thought you got the window handle from $object->{-handle} but that does not correspond to the value returned as lParam from Win32::GUI->GetMessage(). If I use Win32::GUI->GetFocus(), I get the same value returned as lParam. How do I get the handle of a window in a manner that will match the value returned by Win32::GUI->GetFocus() so that I can match it it up during the LostFocus event?

I may be, and probably am, totaly off track on this so I am very open to suggestions of a completely different way to handle this.

Thanks,
Chris


In reply to Win32 - Where will the focus go? by ChrisR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.