From: Len W. <le...@we...> - 2009-07-18 01:17:53
|
perl-win32-gui-users list,<br /><br />I wrote:<br />> But how do I find and read the [COPYDATASTRUCT] structure pointed <br />> to by the integer $lParam ?<br /><br />Well, I figured it out.<br />Here's a sub, not completely general, but handles the case<br />of a scalar message string.<br /><br />Thanks for your indulgence.<br />(Maybe this will be useful for someone else searching the list archive.)<br /><br />Cheers,<br />-Len<br /><br />use Tie::Array::Pointer ;<br /><br />sub read_COPYDATASTRUCT {<br /> ## input: $CopyData_p (eg from an lParam)<br /> ## output (scalar): $Msg (list): ($Msg, dwData_p)<br /> my $CopyData_p = shift ;<br /><br /> my @CopyData_a ;<br /> tie @CopyData_a, 'Tie::Array::Pointer',<br /> {length => 3, type => 'L', address => $CopyData_p } ;<br /> my ($dwData_p, $cbData_len, $lpData_p) = @CopyData_a ;<br /><br /> my @Msg_a ;<br /> tie @Msg_a, 'Tie::Array::Pointer',<br /> {length => $cbData_len, type => 'C', address => $lpData_p } ;<br /><br /> pop @Msg_a if @Msg_a[-1] eq "\0" ; ## pop off trailing null (more??)<br /> my $Msg = pack "C$#Msg_a", @Msg_a ;<br /> wantarray ? ($Msg, $dwData_p) : $Msg ;<br />}<br /><br /><br /><br /> <p>On Jul 17, 2009, <strong>le...@we...</strong> wrote:</p> <div class="replyBody"> <blockquote class="email_quote" style="border-left: 2px solid #267fdb; margin: 0pt 0pt 0pt 1.8ex; padding-left: 1ex;">I am trying to use Win32::GUI from a Perl/Tk program<br />to receive and interpret a message sent from another window.<br /><br />I have successfully set up a window to receive and a hook to<br /> handle the message.<br /> Using the example in Win32::GUI::Reference/Methods.pod, I have<br /><br /> sub msg_handler {<br /> ($object, $wParam, $lParam, $type, $msgcode) = @_;<br /> print "Click handler called!\n";<br /> }<br /><br />The result looks reasonable in the debugger, <br />and $lParam is supposed to be a pointer to a WM_COPYDATA structure.<br /><br />But how do I find and read the structure pointed to by the integer $lParam ?<br />I have a hunch that Win32::API::Struct could help, but I don't quite see how.<br /><br />Thanks,<br />-Len<br /></blockquote> </div> |