Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Little question: set color in form

Status
Not open for further replies.

hstijnen

Programmer
Nov 13, 2002
172
NL
I've made the following code to set a color for alle edit fields in a form:

TComponent *cp;
int nc = ComponentCount;
for (int i=0; i<nc; i++) {
cp = Components;
if(cp->InheritsFrom(__classid(TCustomEdit)))
((TCustomEdit*)cp)->Color = clBtnFace;
}

Got compile error in last line:
TControl::Color is not accessible.

What's wrong?
 
In order to do this with all edit fields. use TEdit, not TCustomEdit. TCustomEdit is the base class for several components:

Code:
  TComponent *cp;
  int nc = ComponentCount;
  for (int i=0; i<nc; i++)  {
    cp = Components[i];
    if(cp->InheritsFrom(__classid(TEdit)))
      ((TEdit*)cp)->Color = clBtnFace;
  }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top