From: Glenn L. <pe...@ne...> - 2003-11-21 18:54:46
|
Yes, this looks better to me too. For whatever my opinion is worth. On approximately 11/21/2003 10:31 AM, came the following characters from the keyboard of Laurent ROCHER: > 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" <st...@ba...> > To: "Win32 GUI Hackers" <per...@li...> > 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 > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers > > -- Glenn -- http://nevcal.com/ =========================== Like almost everyone, I receive a lot of spam every day, much of it offering to help me get out of debt or get rich quick. It's ridiculous. -- Bill Gates And here is why it is ridiculous: The division that includes Windows posted an operating profit of $2.26 billion on revenue of $2.81 billion. --from Reuters via http://biz.yahoo.com/rc/031113/tech_microsoft_msn_1.html So that's profit of over 400% of investment... with a bit more investment in Windows technology, particularly in the area of reliability, the profit percentage might go down, but so might the bugs and security problems? Seems like it would be a reasonable tradeoff. WalMart earnings are 3.4% of investment. |