Can not add control based variable in Add Variable wizard

I have a wierd problem.

For some reason I am unable to add a member variable that is a control.. the check box is disabled when I click add variable.

Some context here:

I have a project that has a rc file included in the projects rc file.
i.e.
resource.h
myprojectname.rc

The commonresource.rc is included in the myprojectname.rc file.

commonresource.h
commonresource.rc

Also the to prevent compliling the commonresource.rc we have it set in the project as exculde from build as it gets built when myprojectname.rc is built.

I have tried the normal checks to see if the appropriate files are checked out / read only etc...

Any help would be appreciated.

So the question is what all controls the availability of the Control Variable check box...



Answer this question

Can not add control based variable in Add Variable wizard

  • Caitriona96

    You can't add a member variable TO a control, or you can't add one where the type of the variable IS a control

    Either way, why do you need a wizard to add a member variable In my experience, those wizards sometimes make a mess of things, and if you've always used them, when they do, you won't know how to fix it. This was in VC6, I've added variables, methods and event handlers entirely by hand ever since, and it's just as quick IMO.



  • earl yuen

    Thanks all for your help.

    Indeed the problem is as I suspected. VisualStudio 2005 is getting confused when seeing the two RC files.

    I disliked the way this project was setup, so this was a catalyst for me getting rid of the second RC file.

    After getting rid of the second RC file I was able to add the control as a variable.

    Thanks for all your help...


  • LongNguyen

    I learned how to add event handlers by hand after using the VC6 wizard for ages, and when it made a mess of things, I had to quickly learn how it all worked, to repair my project. That experience would leave me inclined to encourage people to write their own code where-ever possible. It would not occur to me to use a wizard to add a variable, mostly because I prefer to have control over how my class is laid out, for visibility reasons. However, if you guys prefer to use wizards, then that's cool - I hope you can work out why it's broken in this case.



  • HIE

    cgraus, I do agree with you to a point, e.g. for regular member variables I do the same, but in the case of associated variables, you have to remember to add the correct DDX macro, etc.
  • MattC CLR Documentation Team

    I can't add one where the type of variable is a control.

    I realize I can add them manually, but it's much easier to add it via the wizard.


  • TheWodka

    Ted. wrote:
    cgraus, I do agree with you to a point, e.g. for regular member variables I do the same, but in the case of associated variables, you have to remember to add the correct DDX macro, etc.

    Perhaps, having your rc file include another rc file is confusing the add-member wizard. If so, there's not much you can do about it I guess. Try deleting the ncb and other files and do a rebuild. I am not hopeful that'll work, but since you don't have other options, it's worth a try.



  • Adjustedrace

    I'm not sure what is causing your problem Ian, but the only thing I can recommend is try generating a new class, by creating a new dialog resource and then double clicking on it. Then if that allows you to add control variables to it, then copy your code from your old class into the newly generated one. It's the only thing that may get it working again.
  • kannan_poem1984

    cgraus, it's not an answer, in previous versions people use this stuff for years and it all works.  Doing it by hand is the painful way to do it. 

    I have seen the problem before, where the "control variable" checkbox is greyed out, even though the dialog class is associated with the resource (via the enum IDD value)

    I'm not sure what causes it in all cases, but one case I saw was where the base class of the dialog or form class that was associated with the dialog id, was not one of the standard ones, such as CDialog, CFormView, etc. 


  • stopor

    No just this specific project. Other project with single rc file works fine.
  • Jochen Kalmbach -MVP-

    Does this happen with all projects Or just this one

  • BoroDrummer

    Hi Ted,

    Thanks for the info.

    I have the same problem and you pointed me directly to the cause: I have a CDialog dervied class.

    Do you know of any way I can add control variables using a dervied class

    Cheers.


  • Can not add control based variable in Add Variable wizard