DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: ... Changing a Private variable with the contents of an Edit Box (MFC) ? ...

  1. #1
    Guest

    ... Changing a Private variable with the contents of an Edit Box (MFC) ? ...

    Hello everybody,

    I have a class that i will call Class A, with protected variables.

    I've got a problem. I have a program with MFC, and in the dialog box 3
    values in Edit Box have to be saved in 3 protected values in a Class A ? How
    can I do ?

    Ok, you could say that in the constructor of the Class A, i just have to get
    the values from the 3 Edit box ... Right ! ...

    -> But at any time, the user can change the value in the dialog box
    (modeless) and i'd like to change the private variables of the 'Class A'
    during the 'ChangeText event', the problem is that the class is already
    created !

    How can i do to access these variables ? Any suggestion please ...

    Thank's for you help.

    Driss.








  2. #2
    ch0rlt0n Guest

    Re: ... Changing a Private variable with the contents of an Edit Box (MFC) ? ...


    If the member variables have been declared as protected then there's probably
    a very good reason why this was done. Someone didn't intend these variables
    to be altered once the class was created.

    Solutions: If you have access to the code for class A then you can add public
    modifier methods
    public:
    void setMember1(int i) { m_i1 = i; }
    void setMember2(int i) { m_i2 = i; }

    Alternatively, if you are not able to modify class A itself, you could inherit
    class B from class A and add the modifier methods there. (The member variables
    MUST be protected, not private in this case!)

    ch0rlt0n

    <ndriss@club-internet.fr> wrote:
    >Hello everybody,
    >
    >I have a class that i will call Class A, with protected variables.
    >
    >I've got a problem. I have a program with MFC, and in the dialog box 3
    >values in Edit Box have to be saved in 3 protected values in a Class A ?

    How
    >can I do ?
    >
    >Ok, you could say that in the constructor of the Class A, i just have to

    get
    >the values from the 3 Edit box ... Right ! ...
    >
    >-> But at any time, the user can change the value in the dialog box
    >(modeless) and i'd like to change the private variables of the 'Class A'
    >during the 'ChangeText event', the problem is that the class is already
    >created !
    >
    >How can i do to access these variables ? Any suggestion please ...
    >
    >Thank's for you help.
    >
    >Driss.
    >
    >
    >
    >
    >
    >
    >



  3. #3
    Guest

    Re: ... Changing a Private variable with the contents of an Edit Box (MFC) ? ...

    Thank's for your fast answer.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center