Prev: Building a Mobile or Embedded Device/System? Tell VDC about your experiences for a chance to Win!
Next: How to maintain consistency with MFC-Macros
From: Joseph M. Newcomer on 18 May 2010 17:46 ..and no defined values for those integer offsets! Very sad. It also assumes that I know button 5 is always the one I want, no matter what it means; not robust under maintenance. One of the poorer designs of MFC. In a sane world, the buttons would have symbolic IDs and we would get those symbolic IDs, which we could then map to our desired representation. Oh wait, I can do that already, without using the horrible DDX interface! I can actually ask each button if it is checked, and take an action, and it doesn't even depend on my knowing the ID of the button! [Note that it is a requirement of Windows that the radio button IDs form a dense set of integers for each radio button group, that is, I can have radio buttons with IDs assigned as ( ) 105 WS_GROUP (*) 106 ( ) 107 ? WS_GROUP (any control) but the following are ALSO legal, where they are shown in their Z-order (tab order): (*) 106 WS_GROUP ( ) 105 ( ) 107 ? WS_GROUP ( ) 107 WS_GROUP (*) 106 ( ) 105 ? WS_GROUP (*) 106 WS_GROUP ( ) 107 ( ) 105 ? WS_GROUP ( ) 107 WS_GROUP ( ) 105 (*) 106 ? WS_GROUP ( ) 105 WS_GROUP ( ) 107 (*) 106 ? WS_GROUP There is no requirement that they be in ascending order relative to their screen position or Z-order. But there should be no gaps in the numeric sequence (the "dense" part of the phrase "dense integer set") joe On Tue, 18 May 2010 10:42:19 -0700, "David Ching" <dc(a)remove-this.dcsoft.com> wrote: > >"Cameron_C" <CameronC(a)discussions.microsoft.com> wrote in message >news:8B1F94DE-57E8-4091-BAA4-4AED8ECB0F06(a)microsoft.com... >> That the "auto" part of auto-radio-buttons does not apply to programattic >> selection of the buttons. >> And to be honest, I have avoided the CheckRadioButtons call, because I >> could >> never be sure that the Control IDs were sequential, unless I hand massaged >> the resource file. >> > >Ahem... dare I say DDX data variables work great with radio buttons; it >assigns an int member variable which you give a 0-based number to assign >check the radio button within a group. > >-- David > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Ching on 18 May 2010 19:06 "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message news:1326v591jcprmiao843f7a43s6imnrs2ag(a)4ax.com... > .and no defined values for those integer offsets! Very sad. It also > assumes that I know > button 5 is always the one I want, no matter what it means; not robust > under maintenance. > One of the poorer designs of MFC. > The original complaint was there was no programmatic way of checking just one radio button while unchecking the others, other than manual iteration. I gave a solution for that. Instead of acknowledging that, you go off on something else. Oh well. -- David
From: Joseph M. Newcomer on 18 May 2010 19:59 The assumption that setting button "5" has the same meaning today as it did a year ago is not a valid assumption. The number of times I've had to fix problems like this ("But we just added a couple more options to the radio buttons and now nothing works!") is frighteningly high. joe On Tue, 18 May 2010 16:06:39 -0700, "David Ching" <dc(a)remove-this.dcsoft.com> wrote: >"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message >news:1326v591jcprmiao843f7a43s6imnrs2ag(a)4ax.com... >> .and no defined values for those integer offsets! Very sad. It also >> assumes that I know >> button 5 is always the one I want, no matter what it means; not robust >> under maintenance. >> One of the poorer designs of MFC. >> > >The original complaint was there was no programmatic way of checking just >one radio button while unchecking the others, other than manual iteration. >I gave a solution for that. Instead of acknowledging that, you go off on >something else. Oh well. > >-- David Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Ching on 18 May 2010 21:37 "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message news:8ca6v51u3nau8ooquktpq20rh02j7cr08g(a)4ax.com... > The assumption that setting button "5" has the same meaning today as it > did a year ago is > not a valid assumption. The number of times I've had to fix problems like > this ("But we > just added a couple more options to the radio buttons and now nothing > works!") is > frighteningly high. I have an enum for that and don't use '5'. The enum must be kept in sync with the dialog controls, but at least it's a symbolic reference. It's could be more elegant, but MFC isn't elegant anyway, as I always find myself doing things like renumbering resource.h (so things like ON_CONTROL_RANGE work), now how elegant is that? Lipstick on a pig, at any rate DDX for a radio button does indeed serve a purpose. -- David
From: Joseph M. Newcomer on 18 May 2010 22:42
When I was still believing there was something viable about the radio button interface design, I, too, used an enum, but you and I seem to be notable exceptions in this technique. Too often I just find a switch statement with non-symbolic cases. The need to hand-edit resource.h is a pretty serious defect, because while we know how to do it, most programmers don't, and it results in serious problem. joe \On Tue, 18 May 2010 18:37:57 -0700, "David Ching" <dc(a)remove-this.dcsoft.com> wrote >"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message >news:8ca6v51u3nau8ooquktpq20rh02j7cr08g(a)4ax.com... >> The assumption that setting button "5" has the same meaning today as it >> did a year ago is >> not a valid assumption. The number of times I've had to fix problems like >> this ("But we >> just added a couple more options to the radio buttons and now nothing >> works!") is >> frighteningly high. > >I have an enum for that and don't use '5'. The enum must be kept in sync >with the dialog controls, but at least it's a symbolic reference. It's >could be more elegant, but MFC isn't elegant anyway, as I always find myself >doing things like renumbering resource.h (so things like ON_CONTROL_RANGE >work), now how elegant is that? Lipstick on a pig, at any rate DDX for a >radio button does indeed serve a purpose. > >-- David > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm |