Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

The problem is that you are tryiong to hook into a system/module defined API without understanding the rules and requirements of that API.

Each window can have multiple timers associated with it. This, when the timer triggers and it sends the WM_TIMER message, it *must* also send some additional information as a part of that message that identifies which timer routine should be invoked to handle it. This is easily demonstrated by the following modification of your code which sets up two independent timers for the main window::

Which when run produces the following output:

C:\test>\perl32\bin\perl 1013733.pl bless({ "-handle" => 3213678, "-id" => 1, "-interval" => 10000, "-name +" => "Timer1" }, "Win32::GUI::Timer") bless({ "-handle" => 3213678, "-id" => 2, "-interval" => 20000, "-name +" => "Timer2" }, "Win32::GUI::Timer") [ bless({ # tied Win32::GUI::Window "-accel" => 0, "-handle" => 3213678, "-name" => "Main", "-timers" => { 1 => "Timer1", 2 => "Timer2" }, "-type" => 0, Timer1 => bless({ "-handle" => 3213678, "-id" => 1, "-interval" + => 10000, "-name" => "Timer1" }, "Win32::GUI::Timer"), Timer2 => bless({ "-handle" => 3213678, "-id" => 2, "-interval" + => 20000, "-name" => "Timer2" }, "Win32::GUI::Timer"), }, "Win32::GUI::Window"), "Timer1", ] Timer fired [ bless({ # tied Win32::GUI::Window "-accel" => 0, "-handle" => 3213678, "-name" => "Main", "-timers" => { 1 => "Timer1", 2 => "Timer2" }, "-type" => 0, Timer1 => bless({ "-handle" => 3213678, "-id" => 1, "-interval" + => 10000, "-name" => "Timer1" }, "Win32::GUI::Timer"), Timer2 => bless({ "-handle" => 3213678, "-id" => 2, "-interval" + => 20000, "-name" => "Timer2" }, "Win32::GUI::Timer"), }, "Win32::GUI::Window"), "Timer2", ] Timer fired [ bless({ # tied Win32::GUI::Window "-accel" => 0, "-handle" => 3213678, "-name" => "Main", "-timers" => { 1 => "Timer1", 2 => "Timer2" }, "-type" => 0, Timer1 => bless({ "-handle" => 3213678, "-id" => 1, "-interval" + => 10000, "-name" => "Timer1" }, "Win32::GUI::Timer"), Timer2 => bless({ "-handle" => 3213678, "-id" => 2, "-interval" + => 20000, "-name" => "Timer2" }, "Win32::GUI::Timer"), }, "Win32::GUI::Window"), "Timer1", ] Timer fired

That suggests the possibility that the (Win32::GUI defined) window procedure arranges for the system defined timer to include a numerical 'timer id' as a part of the WM_TIMER message. It then looks up that id in the -timers hash associated with the target window to obtain the name of the blessed timer object, and then uses that to obtain the information passed onto the -onTimer callback routine.

I've tried passing various combinations of id and name on the SendMessage WM_TIMER caller, but have yet to find the correct combination to allow me to trigger tha callback. I suspect that if you dug around in the Win32::GUI sources -- the only reliable documentation I have found for that module -- you might be able to discover the correct magic to allow you to manually trigger the callback, but sending a bare WM_TIMER will not do it. And is not intended to do so.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Win32::GUI sending Windows messages between threads by BrowserUk
in thread Win32::GUI sending Windows messages between threads [solved] by shadrack

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (7)
    As of 2014-09-21 21:15 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (176 votes), past polls