Re: Question about addStyle() and UpDown controls
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 22, 2004
- 496 views
Christian Cuvier wrote: > > Under win98, win32lib 0.60.3: > > }}} <eucode> > constant c0=create(Window,"",0,100,100,100,100,0), > c1=create(EditText,"20",c0,20,20,50,20,0), > c2=create(UpDown,"",c0,50,20,5,20,UDS_AUTOBUDDY) > addStyle(c2,UDS_SETBUDDYINT) > WinMain(c0,Normal) > </eucode> {{{ > does create the expected, c1 is the buddy of c2, but doesn't get updated on > clicking c2. > Now: > }}} <eucode> > constant c0=create(Window,"",0,100,100,100,100,0), > c1=create(EditText,"20",c0,20,20,50,20,0), > c2=create(UpDown,"",c0,50,20,5,20,UDS_AUTOBUDDY+UDS_SETBUDDYINT) > WinMain(c0,Normal) > </eucode> {{{ > does create the expected, and c1 gets updated when clickung c2. > > I'd have expected both snippets to behave the same; what's wrong with the > first one? Microsoft, in their wisdom, has not seen it fit to allow every style flag to be 'added' after the control has been created. Some flags can only be set at the time of creation, and some flags can only be set using specialized messages rather than the general 'add-style' message. In this case, the UDS_SETBUDDYINT flag can only be effectively set at control creation time. It does no harm to set this flag if there is no 'buddy' control attached to the UpDown so maybe I should make it one of the default flags for UpDowns. So in your case I'd actually do this instead ...
constant c0=create(Window,"", 0,100,100,100,100, 0), c1=create(EditText,"20",c0, 20, 20, 50, 20, 0), c2=create(UpDown,"", c0, 70, 20, 5, 20, UDS_SETBUDDYINT) setBuddy(c2,c1) WinMain(c0,Normal)
By the way, I assume the '50' as left position of the UpDown in your example is a mistype. -- Derek Parnell Melbourne, Australia