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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to enable events for a single control

Status
Not open for further replies.

hennep

Programmer
Dec 10, 2000
429
I am trying to make a command button on a form respond to events. It is not an option to disable all controls on the form but one, too much code.
Is there a way to do an Application->ProcessMessages() for just one control?
 
I know you said too much code to disable all controls on the form but the following code is not that big.

sorry can't remember all the code for the C++ Builder version, so some of it may be wrong. (not done c++ for a while!)

You should be able to alter it to suit your needs. You could use name instead of classname to get the control name.

Code:
Delphi
     for i:=0 to ControlCount do
     begin
          if (controls[i] is TEdit) then 
          Controls[i].Enabled:=FALSE;
     end

C++
     for (int i;i=0;i<=ControlCount)
     {
          if Controls[i]->ClassName='TEdit' then
               Controls[i]->Enabled=FALSE;
     }

With this code you are able to disable all the controls and filter out the one you want to be enabled. You may need to filter TPanels etc out as well, just make sure you disable only the controls you need too.

But as you can see not a lot of code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top