1. [Win32Lib] Month Control "fires" on its own??
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 09, 2005
- 558 views
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? Dan Moyer stub program follows. To see the action described, select a date, click the button, & then wait a while; within a minute or so, the text put into the label by the button should disappear, replaced by the date, without any user action after clicking the button. -- code generated by Win32Lib IDE v0.18.9e include Win32lib.ew without warning ---------------------------------------------------------------------------- ---- -- Window Window1 constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400, 300, 0, 0 ) constant MonthCalendar2 = createEx( MonthCalendar, "MonthCalendar2", Window1, 64, 64, 248, 200, 0, 0 ) constant LText3 = createEx( LText, "LText3", Window1, 64, 24, 248, 28, 0, 0 ) constant PushButton4 = createEx( PushButton, "Click", Window1, 4, 24, 52, 24, 0, 0 ) --------------------------------------------------------- ---------------------------------------------------------------------------- ---- procedure PushButton4_onClick (integer self, integer event, sequence params)--params is () setText(LText3, "you clicked it") end procedure setHandler( PushButton4, w32HClick, routine_id("PushButton4_onClick")) ---------------------------------------------------------------------------- ---- procedure MonthCalendar2_onChange (integer self, integer event, sequence params)--params is () object aDate aDate = getSelectedDate(MonthCalendar2) setText(LText3, formatDate(aDate, LongDate)) end procedure setHandler( MonthCalendar2, w32HChange, routine_id("MonthCalendar2_onChange")) WinMain( Window1,Normal )
2. Re: [Win32Lib] Month Control "fires" on its own??
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 09, 2005
- 657 views
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.
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
-- Derek Parnell Melbourne, Australia irc://irc.sorcery.net:9000/euphoria
3. 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