Re: [Win32Lib] Month Control "fires" on its own??
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 10, 2005
- 521 views
> > posted by: Derek Parnell <ddparnell at bigpond.com> > > danielmoyer wrote: > > > > I'm playing with the month control, and I have an "on change it" event get & > > write the date on a label; but I also allow the user to cause something else > > to write onto that label, (which I want to stay there until user does > > something to remove it), but for some reason the on change month control > > event seems to fire & re-write the date there, when the program is just > > "sitting there" doing nothing. > > > > Anyone know what's going on & how to stop it? > > I confirm your observations, but I don't know what is causing it. I suspect > it is WIndows updating the underlying MonthCalendar control and that is > triggering an implicit date selection event. > > Anyhow, the way to work with this is to check the length of the 'params' > parameter in your event handler. If this is zero, then it is an > implicit date selection (e.g. The Next/Prev month was pressed). If > the length is 2 then it is an explicit user selection. > > }}} <eucode> > procedure MonthCalendar2_onChange (integer self, integer event, sequence params) > object aDate > if length(params) > 0 then > aDate = getSelectedDate(MonthCalendar2) > setText(LText3, formatDate(aDate, LongDate)) > end if > end procedure > </eucode> {{{ > > -- > Derek Parnell > Melbourne, Australia > irc://irc.sorcery.net:9000/euphoria Thanks Derek, that's similar to what I did: I made a flag, set when user causes text to be written, & check that flag inside the "on change" event for the calendar. If user flag is set, date isn't written. Seems to work ok so far. I'll bear your test in mind in case I need it otherwise, looks like it could be handy. Dan