I agree ----- Original Message ----- From: "Laurent ROCHER" <[EMAIL PROTECTED]> To: "Steve Pick" <[EMAIL PROTECTED]>; "Win32 GUI Hackers" <perl-win32-gui-hackers@lists.sourceforge.net> Sent: Friday, November 21, 2003 6:31 PM Subject: Re: [perl-win32-gui-hackers] Fix for PeekMessage
> > For "A" problem, i don't think it's a else problem. > > You can call PeekMessage without a message parameter. > In this case message == &PL_sv_undef, and no warming it's necessary. > > If you specify a message parameter, then we need a reference (SvROK) and > must be a Array reference. > I think it's better to move SvROK(message) in inner if, like this : > > BOOL > PeekMessage(handle, min=0, max=0, message=&PL_sv_undef) > HWND handle > UINT min > UINT max > SV* message > PREINIT: > MSG msg; > CODE: > ZeroMemory(&msg, sizeof(msg)); > RETVAL = PeekMessage(&msg, handle, min, max, PM_NOREMOVE); > if(message != &PL_sv_undef) { > if(SvROK(message) && SvTYPE(SvRV(message)) == SVt_PVAV) { > av_clear((AV*) SvRV(message)); > av_push((AV*) SvRV(message), newSViv((long) msg.hwnd)); > av_push((AV*) SvRV(message), newSViv(msg.message)); > av_push((AV*) SvRV(message), newSViv(msg.wParam)); > av_push((AV*) SvRV(message), newSViv(msg.lParam)); > av_push((AV*) SvRV(message), newSViv(msg.time)); > av_push((AV*) SvRV(message), newSViv(msg.pt.x)); > av_push((AV*) SvRV(message), newSViv(msg.pt.y)); > } else { > if(PL_dowarn) warn("Win32::GUI: fourth parameter to PeekMessage > is not an array reference"); > } > } > OUTPUT: > RETVAL > > Laurent. > > ----- Original Message ----- > From: "Steve Pick" <[EMAIL PROTECTED]> > To: "Win32 GUI Hackers" <perl-win32-gui-hackers@lists.sourceforge.net> > Sent: Friday, November 21, 2003 2:50 AM > Subject: [perl-win32-gui-hackers] Fix for PeekMessage > > > > > > You'll notice PeekMessage A) doesnt warn about non-references even though > > the warning code is there and B) Yields a ton of "attempt to free > > unreferenced scalar" errors. The problem was an else{} in the wrong place, > > and making array values mortal so they got cleaned up before they ever hit > > your perl program, so here's it fixed. > > > > > ########################################################################### > > # (@)METHOD:PeekMessage([MIN, MAX, MESSAGE]) > > # Inspects the window's message queue and eventually returns data > > # about the message it contains; it can optionally check only for > > message > > # identifiers in the range MIN..MAX; the last MESSAGE parameter, if > > # specified, must be an array reference. > > # If a message is found, the function puts in that array 7 elements > > # containing: > > # - the handle of the window to which the message is addressed > > # - the message identifier > > # - the wParam argument > > # - the lParam argument > > # - the time when message occurs > > # - the x coordinate at which message occurs > > # - the y coordinate at which message occurs > > # > > BOOL > > PeekMessage(handle, min=0, max=0, message=&PL_sv_undef) > > HWND handle > > UINT min > > UINT max > > SV* message > > PREINIT: > > MSG msg; > > CODE: > > ZeroMemory(&msg, sizeof(msg)); > > RETVAL = PeekMessage(&msg, handle, min, max, PM_NOREMOVE); > > if(message != &PL_sv_undef && SvROK(message)) { > > if(SvTYPE(SvRV(message)) == SVt_PVAV) { > > av_clear((AV*) SvRV(message)); > > av_push((AV*) SvRV(message), newSViv((long) msg.hwnd)); > > av_push((AV*) SvRV(message), newSViv(msg.message)); > > av_push((AV*) SvRV(message), newSViv(msg.wParam)); > > av_push((AV*) SvRV(message), newSViv(msg.lParam)); > > av_push((AV*) SvRV(message), newSViv(msg.time)); > > av_push((AV*) SvRV(message), newSViv(msg.pt.x)); > > av_push((AV*) SvRV(message), newSViv(msg.pt.y)); > > } > > } > > else { > > if(PL_dowarn) warn("Win32::GUI: fourth parameter to PeekMessage is > > not an array reference"); > > } > > OUTPUT: > > RETVAL > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Perl-Win32-GUI-Hackers mailing list > Perl-Win32-GUI-Hackers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers >