1. RE: onChange Bug
- Posted by Jonas Temple <jktemple at yhti.net> Aug 07, 2002
- 440 views
Jon, I've run into this as well. I'm not sure it's a bug and here's why. The onchange event is fired whenever the control is changed. In your routine, you're changing the edit control, which fires the onchange event, which changes the control, which fires the event, etc., etc. and eventually makes exw crash because of the large call stack. I've gotten around this in the past (and if someone has a better idea, please) by putting a flag in my program that I set and then not change if it is set. For example: atom changing changing = False procedure onChangeEditBox() if not changing then changing = True setText( EDIT_BOX, "new text") changing = False end if end procedure onChange[ EDIT_BOX] = routine_id( "onChangeEditBox") This stops the recursive call. It may not be the best way around the problem but it works for me. Jonas Jon Snyder wrote: > > > There is a bug in Win32Lib v57 with trying to call setText( within a > onChange event. > > Is there a way to fix this or should i just use the older win32lib? Or > is there a newer version that doesn't have this bug? > > Here is an example.. > > -- This is not the actual code > procedure onChangeEditBox() > > setText( EDIT_BOX, "new text") > > end procedure > onChange[ EDIT_BOX] = routine_id( "onChangeEditBox") > > This makes an error in exw.exe > > Thanks, Jon > >
2. RE: onChange Bug
- Posted by munchr at mac.com Aug 08, 2002
- 445 views
At 08:07 PM 07/08/2002 +0000, Jonas wrote: Jonas is correct. This is not a bug in with win32lib, it is a fundamental issue with the way the win32 message que works. I have seen the same thing discussed in many VB forums. Basically, any code that fires when a control changes states (message fields, buttons, etc) should not also modify the state of that control without a way to prevent a recursive loop. James Powell >Jon, > >I've run into this as well. I'm not sure it's a bug and here's why. >The onchange event is fired whenever the control is changed. In your >routine, you're changing the edit control, which fires the onchange >event, which changes the control, which fires the event, etc., etc. and >eventually makes exw crash because of the large call stack. > >I've gotten around this in the past (and if someone has a better idea, >please) by putting a flag in my program that I set and then not change >if it is set. For example: > >atom changing >changing = False > >procedure onChangeEditBox() > >if not changing then >changing = True >setText( EDIT_BOX, "new text") >changing = False >end if > >end procedure >onChange[ EDIT_BOX] = routine_id( "onChangeEditBox") > >This stops the recursive call. It may not be the best way around the >problem but it works for me. > >Jonas > >Jon Snyder wrote: > > > > > > There is a bug in Win32Lib v57 with trying to call setText( within a > > onChange event. > > > > Is there a way to fix this or should i just use the older win32lib? Or > > is there a newer version that doesn't have this bug? > > > > Here is an example.. > > > > -- This is not the actual code > > procedure onChangeEditBox() > > > > setText( EDIT_BOX, "new text") > > > > end procedure > > onChange[ EDIT_BOX] = routine_id( "onChangeEditBox") > > > > This makes an error in exw.exe > > > > Thanks, Jon
3. RE: onChange Bug
- Posted by Don Phillips <Graebel at hotmail.com> Aug 08, 2002
- 448 views
> I've run into this as well. I'm not sure it's a bug and here's why. > The onchange event is fired whenever the control is changed. In your > routine, you're changing the edit control, which fires the onchange > event, which changes the control, which fires the event, etc., etc. and > eventually makes exw crash because of the large call stack. > > I've gotten around this in the past (and if someone has a better idea, > please) by putting a flag in my program that I set and then not change > if it is set. For example: <SNIP> More than one way to skin a cat... Mmmmm cat! The more elegant solution is to unhook the procedure. This eliminates the need for a global variable and the conditional... procedure onChangeEditBox() onChange[EDIT_BOX] = 0 setText( EDIT_BOX, "new text") onChange[EDIT_BOX] = routine_id( "onChangeEditBox") end procedure onChange[EDIT_BOX] = routine_id( "onChangeEditBox") Don Phillips
4. RE: onChange Bug
- Posted by Don Phillips <Graebel at hotmail.com> Aug 11, 2002
- 437 views
Martin Stachon wrote: > Even better is set it to -1. > > onChange[EDIT_BOX] = -1 > > or in win32lib 0.57.9: > > setHandler(EDIT_BOX, w32HChange, -1) > > Martin Ahh yeah, I probably meant -1. Opps sorry for the confusion... Don