A boolean value for what? The only boolean value related to an edit box I can think of would be whether it is enabled or not...if that is what you are looking for just set a
bool value = m_EditBox.IsWindowEnabled();
I need a flag to be set when the content of the edit box meets some criteria for which I check, i.e. if the input is valid (by some rules, which I have defined myself). So far I've been working with bool values for every edit box,
(ON_EN_UPDATE i check the new input and if it's ok i set my variable to true),
but currently I have 6 such boxes and it is kind of awkward.
I am going to have another dialog box with 8 edit boxes in it, so that's going to be even worse. (Btw, the edit boxes are for coordinates of points, in case u were wondering).
Anyway, to cut a long story short, is this possible?
Thanks. Avendeval
Manually, add flags that associated to each edit box (outside the ClassWizard created area). For example:
class CMyDilaog : public CDialog
{
protected:
bool m_bMyEdit1Valid;
bool m_bMyEdit2Valid;
...
that's what I have at the moment.
What I need is to be able to kind of add another member variable to the CWnd class from which each edit box is created, so that I can have the following syntax
GetDlgItem(MY_IDENTIFIER)->Valid = true;
Where Valid is my bool variable.
I know it's a big thing I'm asking for, I mean I need to modify the CWnd class. I guess it's impossible. I was just thinking of in the class there is some 'room' left to create your own flags and access and modify them thorugh each and every obj from that class.
> that's what I have at the moment.
> What I need is to be able to kind of add another member
> variable to the CWnd class from which each edit box is
> created, so that I can have the following syntax
It only make sense if the member is also associated to the control. It also depends on the type of control. For example in CEdit class, you can associate it with either CString or int, or many others. But that means you're expecting or restricting the input to be of that type. Not necessary what you're looking for.
From your description, you just need a flag to indicate whether the entry in the edit box is valid. One way is what you are currently doing, I list another way at the end. Associate a new BOOL type to your edit box does not do what you want. It just means you can only enter a BOOL value into the edit box.
> GetDlgItem(MY_IDENTIFIER)->Valid = true;
First of all, there is not member function Valid in any CWnd and CWnd derived class. CEdit has many properties, but user defined property such as BOOL does not exist.
> Where Valid is my bool variable.
> I know it's a big thing I'm asking for, I mean I need to
> modify the CWnd class. I guess it's impossible. I was
> just thinking of in the class there is some 'room' left
> to create your own flags and access and modify them
> thorugh each and every obj from that class.
Some control has internal storage for additional user defined data. Normally a DWORD. One example is a list box control. Set/GetItemData set and retrieve user data that is associated to a specific item. But that is part of the control.
> Is that possible?
If you really want the CEdit object to carry extra information, one way is to derived you own class based on CEdit:
class CMyValidateEdit : public CEdit
{
protected:
bool m_bValid;
public:
bool IsValid(void) const;
void SetValid(const bool bValid);
};
Manually change the ClassWizard generated code:
CEdit m_Edit1;
to:
CMyValidateEdit m_Edit1;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.